# Mathematica Common Expressions

## Taylor Series

The $n^th$ term of the Taylor series expansion for the function $f(x)$ at $a$ can be obtained by the following function:

TaylorTerm[fx_, x_, a_, n_] := (((Evaluate[D[fx, {x, n}]]) /. x -> a)/n!) (x - a)^n

The sum of the first n terms for the Taylor series expansion for the function $f(x) at $a$ can be obtained by the following function:

TaylorSeries[fx_, x_, a_, n_] := Evaluate[Normal[Series[fx[y], {y, a, n}]]] /. y -> x

Note that you may have to use a pure function as the first argument, e.g.

In[1]:= TaylorSeries[Function[x, Sqrt[x + 1]], x, 0, 10] Out[1]= 1 + x/2 - x^2/8 + x^3/16 - (5 x^4)/128 + (7 x^5)/256 - ( 21 x^6)/1024 + (33 x^7)/2048 - (429 x^8)/32768 + (715 x^9)/65536 - ( 2431 x^10)/262144