Files

83 KiB

In [1]:
import matplotlib.pyplot as plt

# Data
n_values = [10, 100, 1000]
forward_elimination_times = [
    [0.001633, 0.001544, 0.001593, 0.001633, 0.001430],
    [0.095059, 0.090941, 0.087520, 0.092816, 0.099994],
    [12.931657, 13.024221, 12.957925, 12.753179, 13.095672]
]
backsolve_times = [
    [0.000352, 0.000303, 0.000289, 0.000289, 0.000427],
    [0.003582, 0.003233, 0.003795, 0.003512, 0.003431],
    [0.034218, 0.032342, 0.032653, 0.032123, 0.034295]
]

# Calculate average times
average_forward_elimination_times = [sum(times) / len(times) for times in forward_elimination_times]
average_backsolve_times = [sum(times) / len(times) for times in backsolve_times]

# Plot Forward Elimination
plt.figure(figsize=(10, 5))
plt.plot(n_values, average_forward_elimination_times, marker='o')
plt.xlabel('Number of Unknown Variables (N)')
plt.ylabel('Time (seconds)')
plt.title('Forward Elimination Scaling')
plt.xticks(n_values)
plt.grid(True)
plt.show()


In [2]:
# Plot Backsolve
plt.figure(figsize=(10, 5))
plt.plot(n_values, average_backsolve_times, marker='o')
plt.xlabel('Number of Unknown Variables (N)')
plt.ylabel('Time (seconds)')
plt.title('Backsolve Scaling')
plt.xticks(n_values)
plt.grid(True)
plt.show()