Back to Expand your Knowledge

 

Mathematica Tutorial on Taylor Series Expansion.

Commands used are. Series , // Normal and /. ( slash and dot next to it ).

The following mathemathica commands computes the Taylor Series expansion of a function f[x]
about a point x=a up to order n.


Series[f[x],{x,a,n}]



Example 1. Compute the Taylor series expansion of e^x near the point x=0 up to order 3
Solution. Enter the fowllowing command and hit enter.

 

s1=Series[E^x,{x,0,5}]

              2    3    4    5
             x    x    x    x         6
     1 + x + -- + -- + -- + --- + O[x]
             2    6    24   120

The command , Double slash Normal. ie. // Normal is used to get rid of correction of order 6.

 

s2=s1//Normal

              2    3    4    5
             x    x    x    x
     1 + x + -- + -- + -- + ---
             2    6    24   120

Note. The letter s1 and s2 on the left of the equal sign has no effect on the actual calculations.
These are just symbols assigined by us. We could if we want to call them cow 1 and cow 2.

Example 2. Compute the Taylor series expansion of Sin x near the point x=0 up to order 10
Solution. Enter the fowllowing command and hit enter.
Solution. Enter the fowllowing command and hit enter.

 

s3=Series[Sin[x],{x,0,10}]//Normal

          3    5      7       9
         x    x      x       x
     x - -- + --- - ---- + ------
         6    120   5040   362880

The command /. x->1 means substitute x=1 . The command //N means we want numerical answer.

s4=s3/.x->1//N

     0.841471

Note: Get your calculator and try the fowllowing. 1) Change degree to radian.
2) Punch in sin 1 and hit equal sign.Did you get the same value as s4 ?.

Example 3. a) Substitute x=Cos[y+a] in Sin x . Then substitute a=2 and then y=1 into the each answer.
b) Use part a and do all of the substitutions in one command.

solution a)

s5=Sin[x]/.x->Cos[y+a]

     Sin[Cos[a + y]]


s6=s5/.a->2

     Sin[Cos[2 + y]]

s7=s6/.y->1//N

     -0.836022

Solution b)

s8=Sin[x]/.x->Cos[y+a]/.a->2/.y->1//N

     -0.836022

 

Back to Expand your Knowledge