Message Boards Message Boards

1
|
5329 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Get edited series expansions with the Wolfram Language?

Posted 9 years ago

It is very easy using Series to get series expansion but the output is never in the way we see them in math textbooks where they are more understandable. Il' take take 2 examples

$e^{x}~=~1+~x~+\frac{x^{2}}{2!}~+~\frac{x^{3}}{3!}~+~~\frac{x^{3}}{4!}~+...$.

$\arcsin x~=~x~+~\frac{x^{3}}{2 \cdot3}~+~\frac{1 \cdot 3 }{2 \cdot4 \cdot 5}~ x^{5}~+~\frac{1 \cdot 3 \cdot5}{2 \cdot4 \cdot 6 \cdot7}~ x^{7}~+~....$

I tried to get the above output using MMA, with not much success

My first idea was to start with the summation of the general term of a MacLaurin series

gterm[f_, x_, n_] :=  x^(n - 1) (D[f[x], {x, n - 1}] /. x -> 0)/(n - 1)!
exp = Sum[gterm[Exp, x, k], {k, 1, 5}]

No way to put a Hold or HoldForm somewhere in the definition of my function gterm to prevent the evaluation of the factorial.

So I started toying then with patterns and I came out with something which works with $e^x$ but leaves me unsastified as hardly generalisable.

fx[a_] := 
Module[{}, maj = Cases[a, Times[_, Power[x, e_]] :> HoldForm[e!]]; 
pos = Position[a, _Rational]; ReplacePart[a, Thread[pos -> 1/maj]]]
exp //  fx

And my knowdledge of MMA is not good enough to handle the ArcSin case in such a way ..

Is there a better solution than the one I'm not satisfied with and could be adapted with minimal effort to handle more elaborate cases ? Thanks.

POSTED BY: Jan Potocki
2 Replies
Posted 9 years ago

Hello Gianluca

Your answers evaluate the factorials and I don't want this to take place. For Exp[x] I get 1+x+x^2/2+x^3/6+x^4/24+x^5/120 .

You gave me anyway an idea by using this rather new MMA function that I didn't know about until I read you.

genterm = SeriesCoefficient[Exp[x] , {x, 0, n}][[1, 1, 1]] x^  n /. {Factorial[n] -> Inactivate[Factorial[n]]} (* general term for Exp[x]  MacLaurin expansion*)
Sum[genterm , {n, 0, 5}] 

$\frac{1}{0!}+\frac{x}{1!}+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\frac{x^5}{5!}$
Easy to finish it by simply rep[lacing the two first terms by 1 + x

However this is not generalisable to ArcSin[x] because I want here the factorial in the denominator of the general term to be simplified in the way you see it in most textbooks and my course materials too.

  (x^n Pochhammer[1/2, 1/2 (-1 + n)])/(n (1/2 (-1 + n))!) /. {n -> 5}

gives me $\frac{3 x^{5}}{40} $ and I would like to have it expanded as $ \frac{1 \cdot 3}{2 \cdot 4 \cdot 5}~ x^{5}$

POSTED BY: Jan Potocki

A couple of attempts using Inactive:

Inactive[Plus] @@ 
 Table[Inactive[Times][SeriesCoefficient[Exp[x], {x, 0, k}], 
   Power[x, k]], {k, 0, 5}]
Inactive[Plus] @@ 
 Table[Times[SeriesCoefficient[Exp[x], {x, 0, k}], Power[x, k]], {k, 
   0, 5}]

The formatting is less satisfying when the coefficients are negative.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract