Compute the first and second derivatives of a polynomial using (forward/central/backward) finite difference formulas and compare with the exact values.
import pandas as pd
from matplotlib import pyplot as plt
from matplotlib import rcParams
rcParams["figure.dpi"] = 200
dframe = pd.read_csv("build/poly-data.csv",header=0,comment="#")
plt.plot(dframe["X"],dframe["DFDX"], 'x', label="f'(x)")
plt.plot(dframe["X"],dframe["DFDX_CDS"], '.', label="f'(x) CDS")
plt.legend()
<matplotlib.legend.Legend at 0x7f3a296b6c80>
plt.plot(dframe["X"],dframe["D2FDX2"], 'x', label="f''(x)")
plt.plot(dframe["X"],dframe["D2FDX2_CDS"], '.', label="f''(x) CDS")
plt.legend()
<matplotlib.legend.Legend at 0x7f3a295dd8d0>