import numpy as np
from scipy.misc import derivative # 数値微分
import matplotlib.pyplot as plt
import scienceplots
#Warning : As of version 2.0.0, you need to add import scienceplots before setting the style (plt.style.use('science')).
plt.style.use(['science', 'notebook'])
nx = 7
xp = np.linspace(0.0, 10, nx)
yy1 = np.empty(nx)
yy1[:] = [my_diff1(func1, xp[i], h) for i in range(nx)]
print(f"{'diff1:':>11s}",end=' ')
[print(f"{yy1[i]:10.7f}",end=' ') for i in range(nx)]
print("")
xp2 = np.linspace(0.2, 10, nx)
yy2 = np.empty(nx)
yy2[:] = [my_diff2(func1, xp2[i], h) for i in range(nx)]
print(f"{'diff2:':>11s}",end=' ')
[print(f"{yy2[i]:10.7f}",end=' ') for i in range(nx)]
print("")
xp3 = np.linspace(0.4, 10, nx)
yy3 = np.empty(nx)
yy3[:] = [derivative(func1, xp3[i], h) for i in range(nx)]
print(f"{'derivative:':>11s}",end=' ')
[print(f"{yy3[i]:10.7f}",end=' ') for i in range(nx)]
print("")