%matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
! cargo run --release --example accuracy
Finished release [optimized] target(s) in 0.0 secs Running `target/release/examples/accuracy`
euler = pd.read_csv("euler.csv").dropna().set_index("dt")
heun = pd.read_csv("heun.csv").dropna().set_index("dt")
rk4 = pd.read_csv("rk4.csv").dropna().set_index("dt")
diag_rk4 = pd.read_csv("diag_rk4.csv").dropna().set_index("dt")
plt.plot(euler, "b+-", label="Euler")
plt.plot(heun, "g+-", label="Heun")
plt.plot(rk4, "r+-", label="RK4")
plt.plot(diag_rk4, "+-", label="RK4(si)", color="orange")
plt.plot(euler.index, 200*euler.index, "b:", label=r"$\propto dt^1$")
plt.plot(heun.index, 1000*heun.index**2, "g:", label=r"$\propto dt^2$")
plt.plot(rk4.index, 80000*rk4.index**4, "r:", label=r"$\propto dt^4$")
plt.xscale("log")
plt.yscale("log")
plt.xlabel("dt")
plt.ylabel("accuray (deviation from truth)")
plt.axis("tight")
plt.legend(loc=4, ncol=2)
<matplotlib.legend.Legend at 0x7f82a1714f60>
(si) means semi-implicit scheme