Taylor Series defined recursively

Leo asked after class on Monday whether Taylor Series could be defined recursively. Here they are.

Thanks for asking, Leo: I love talking about Taylor Polynomials!:)

taylor[f_,x_,x0_,n_]:=
If[n==0,(* Base case: the (0^th) degree Taylor polynomial is the function evaluated at (Subscript[x, 0]): *)
f[x0], 
(* Inductive step: 
the (n^th) degree Taylor polynomial is the (((n-1))^th) Taylor polynomial, plus one more term: (f^((n)))((Subscript[x, 0]))((((x-(Subscript[x, 0])))^n)/(n!)): *)
Module[{fn},
fn[y_]=D[f[y],{y,n}]; (* the (n^th) derivative function. 
If I try to use "x" for the variable in the definition of fn, Mathematica complains because it's unhappy about me using an x within the scope of something which already uses an x....*)
taylor[f,x,x0,n-1](* the previous Taylor polynomial *)
+ fn[x0](x-x0)^n/Factorial[n] (* the new term. *)
]
]

Let’s use polynomials to approximate the Sine function on the interval [0,(π/2)] (which is exactly what your calculator does, by the way):

f[x_]=Sin[x]
x0=Pi/4 (* we'll expand about the midpoint of the interval *)

Degree 0: gets the function exactly right at (Subscript[x, 0])=(π/4):

taylorConstant=taylor[f,x,x0,0]
Plot[{f[x],taylorConstant},{x,0,Pi/2},PlotLabels->Automatic]

Degree 1: Tangent line approximation at (Subscript[x, 0])=(π/4):

taylorLinear=taylor[f,x,x0,1]
Plot[{f[x],taylorLinear},{x,0,Pi/2},PlotLabels->Automatic]

Degree 2: Tangent Quadratic approximation

taylorQuadratic=taylor[f,x,x0,2]
Plot[{f[x],taylorQuadratic},{x,0,Pi/2},PlotLabels->Automatic]

Degree 3: Tangent Cubic approximation

taylorCubic=taylor[f,x,x0,3]
Plot[{f[x],taylorCubic},{x,0,Pi/2}]

Degree 4: Tangent Quartic approximation

taylorQuartic=taylor[f,x,x0,4]
Plot[{f[x],taylorQuartic},{x,0,Pi/2}]

Degree 5: Tangent Quintic approximation

taylorQuintic=taylor[f,x,x0,5]
Plot[{f[x],taylorQuintic},{x,0,Pi/2},PlotLabel->"Any difference?"]
Plot[{f[x]-taylorQuintic},{x,0,Pi/2},PlotLabel->"Error: Difference between f and the quintic"]

By the way, the form of each of the expressions for the Taylor polynomials above is a bad way to evaluate them. 

Why? And how could we improve the expressions?