using Pkg Pkg.add("Plots") using Plots ENV["PLOTS_TEST"] = false Pkg.add("BenchmarkTools") using BenchmarkTools Pkg.add("SymPy") using SymPy x = Sym(:x) function padesin1(x) (x - 7/60*x^3)/(1 + 1/20*x^2) end padesin1(x) simplify(padesin1(x)) t = collect(-pi:0.01:pi) y = [padesin1(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y) function padesin2(x) (x - 426/3024*x^3 + 25/6048*x^5)/(1 + 13/504*x^2 + 1/10080*x^4) end padesin2(x) simplify(padesin2(x)) t = collect(-pi:0.01:pi) y = [padesin2(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y) function padesin3(x) # (x - 1/7*x^3 + 11/2520*x^5)/(1 + 1/42*x^2) # 計算が少なくなりそうに式変形 x2 = x^2 x*(11.0/60.0*x2 - 137.0/10.0 + 37044.0/60.0/(x2+42.0)); end padesin3(x) simplify(padesin3(x)) t = collect(-pi:0.01:pi) y = [padesin3(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y) function padesin4(angle) angle2 = angle^2 return (11*angle2-252)*(angle2-10)*angle / (2520 + 60 * angle2) end padesin4(x) t = collect(-pi:0.01:pi) y = [padesin4(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y) function padesin5(angle) angle2 = angle^2 return (10.8*angle2-252)*(angle2-10)*angle / (2520 + 60 * angle2) end padesin5(x) t = collect(-pi:0.01:pi) y = [padesin5(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y) a = [1 0 0 0 0 ; 0 1 0 -1 0 ; 0 0 1 1/6 -1 ; 1 2*pi^2 5*pi^4 0 0 ; 1 pi^2 pi^4 0 0 ] b = [1, -1/6, 1/120, -1, 0] xs = a\b function padesin6(x) global xs x2 = x^2 x * (xs[1] + x2*xs[2])/(1 + x2*(xs[4]+ xs[5]*x2)) end t = collect(-pi:0.01:pi) y = [padesin6(i) for i in t] y = hcat(y, [sin(i) for i in t]) plot(t, y)