Run the following code to see how to compute a one-dimensional Taylor series with Sage.
var('x,k') colors=['red', 'black', 'green', 'magenta'] x1 = pi/2 xmin = x1 - pi; xmax = x1 + pi f(x) = sin(x) p1 = plot(f, (xmin, xmax), color='blue') Taylor_series_3(x) = f.taylor(x, x1, 3) p1 += plot(Taylor_series_3, (xmin, xmax), legend_label='3', color='red') Taylor_series_5(x) = f.taylor(x, x1, 5) p1 += plot(Taylor_series_5, (xmin, xmax), legend_label='5', color='green') Taylor_series_7(x) = f.taylor(x, x1, 7) p1 += plot(Taylor_series_7, (xmin, xmax), legend_label='7', color='black') Taylor_series_7.show() show(p1)
The results are shown in the following screenshot: