taylor_cosine

> t:=taylor(cos(x),x=0,5+1); Sets up the Taylor series in a formal way.

t := series(1-1/2*x^2+1/24*x^4+O(x^6),x,6)

> P5:=convert(t,polynom); Converts it to a polynomial.

P5 := 1-1/2*x^2+1/24*x^4

> P1:=convert(taylor(cos(x),x=0,2),polynom); First order approximation.

P1 := 1

> P2:=convert(taylor(cos(x),x=0,3),polynom); Second order approximation.

P2 := 1-1/2*x^2

> plot({cos(x),P1,P2,P5},x=-6..6,y=-1.5..1.5); Plot all four together.

[Maple Plot]

> P10:=convert(taylor(cos(x),x=0,11),polynom); Tenth order approximation.

P10 := 1-1/2*x^2+1/24*x^4-1/720*x^6+1/40320*x^8-1/3...

> plot({cos(x),P10},x=-6..6,y=-1.5..1.5);

[Maple Plot]