# Differences

This shows you the differences between two versions of the page.

 public:mathematica_common_expressions [2016/10/10 11:47]Fufu Fang [Taylor Series] public:mathematica_common_expressions [2018/03/31 00:38] (current) Both sides previous revision Previous revision 2016/10/10 15:28 Fufu Fang [Taylor Series] 2016/10/10 11:47 Fufu Fang [Taylor Series] 2016/10/10 11:46 Fufu Fang created Next revision Previous revision 2016/10/10 15:28 Fufu Fang [Taylor Series] 2016/10/10 11:47 Fufu Fang [Taylor Series] 2016/10/10 11:46 Fufu Fang created Line 1: Line 1: + ====== 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:= TaylorSeries[Function[x,​ Sqrt[x + 1]], x, 0, 10] + Out= 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 +
• public/mathematica_common_expressions.txt