Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:mathematica_common_expressions [2016/10/10 12:47]
Fufu Fang [Taylor Series]
public:mathematica_common_expressions [2018/03/31 01:38] (current)
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: ​
 +<code mathematica>​
 +TaylorTerm[fx_,​ x_, a_, n_] := (((Evaluate[D[fx,​ {x, n}]]) /. x -> a)/n!) (x - a)^n
 +</​code>​
  
 +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:
 +<code mathematica>​
 +TaylorSeries[fx_,​ x_, a_, n_] :=  Evaluate[Normal[Series[fx[y],​ {y, a, n}]]] /. y -> x
 +</​code>​
 +Note that you may have to use a pure function as the first argument, e.g.
 +<code mathematica>​
 +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
 +</​code>​
  • public/mathematica_common_expressions.txt
  • Last modified: 2018/03/31 01:38
  • (external edit)