41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import matplotlib.pyplot as plt
|
|
|
|
# plt.rc('text', usetex=True)
|
|
# plt.rc('font', family='serif')
|
|
|
|
def main():
|
|
for i in range(7):
|
|
x = []
|
|
abs_err = []
|
|
rel_err = []
|
|
with open(f"output/error/out_{10**(i+1)}.txt", "r") as f:
|
|
lines = f.readlines()
|
|
for line in lines:
|
|
x_i, abs_err_i, rel_err_i = line.strip().split(",")
|
|
x.append(float(x_i))
|
|
abs_err.append(float(abs_err_i))
|
|
rel_err.append(float(rel_err_i))
|
|
|
|
plt.figure(1)
|
|
plt.plot(x, abs_err, label=f"n$_{{steps}} = 10^{i+1}$")
|
|
plt.figure(2)
|
|
plt.plot(x, rel_err, label=f"n$_{{steps}} = 10^{i+1}$")
|
|
|
|
plt.figure(3)
|
|
plt.plot(i+1, max(rel_err), marker="o", markersize=10)
|
|
|
|
plt.figure(1)
|
|
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
|
|
plt.figure(2)
|
|
plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
|
|
|
|
plt.figure(1)
|
|
plt.savefig("../latex/images/problem8_a.pdf", bbox_inches="tight")
|
|
plt.figure(2)
|
|
plt.savefig("../latex/images/problem8_b.pdf", bbox_inches="tight")
|
|
plt.figure(3)
|
|
plt.savefig("../latex/images/problem8_c.pdf", bbox_inches="tight")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|