3
$\begingroup$

I am trying to visualize the Euler numbers coming from the generating function:

\begin{align*} \sum_{n\geq0}E_{n}\frac{x^{n}}{n!} & =\text{sec}(x)+\text{tan}(x)\\ & =1+x+\frac{x^{2}}{2!}+2\frac{x^{3}}{3!}+5\frac{x^{4}}{4!}+16\frac{x^{5}}{5!}+61\frac{x^{6}}{6!}+272\frac{x^{7}}{7!}+1385\frac{x^{8}}{8!}+7936\frac{x^{9}}{9!}\cdots \end{align*}

But, when treated as usual, Series[Sec[x] + Tan[x], {x, 0, 9}] , Mathematica simplifies $\frac{E_{n}}{n!}$ when possible so we cannot identify coefficients neatly. Should it be enough to multiply $n!$, but

n = 9; Take[Range[0, n]!]*Series[Sec[x] + Tan[x], {x, 0, n}]

generates a list of $i$ polynomials, where only the $i^{th}$ term is the correct one I am looking for.

Is there a way to sieve them and thus get the desired polyomial expansion? or, Is there an easier way to keep the term $\frac{1}{n!}$ without simplification in the coefficient of $x^{n}?$

$\endgroup$
2
  • 1
    $\begingroup$ SeriesCoefficient[Sec[x] + Tan[x], {x, 0, n}] // Simplify $\endgroup$
    – Bob Hanlon
    Mar 6 at 16:46
  • 1
    $\begingroup$ Here is a similar post. $\endgroup$ Mar 6 at 21:35
4
$\begingroup$

If it's a question of output formatting, then perhaps this:

n = 9;
Block[{x},
   x /: Power[x, k_?Positive] := Defer[x^k/k!];
   Normal@ReplacePart[#,
     3 :> Range[#[[4]], #[[4]] + Length@#[[3]] - 1]! #[[3]]]
   ] &@Series[Sec[x] + Tan[x], {x, 0, n}]
$\endgroup$
5
  • 1
    $\begingroup$ Thank you @Michael, definitely retrieves the Euler numbers!! Just a question, this seems specially suited for the function $\text{sec}(x)+\text{tan}(x)$ but for other functions we do not get the general form $1+a_{1}x+a_{2}\frac{x^{2}}{2!}+a_{3}\frac{x^{3}}{3!}+a_{4}\frac{x^{4}}{4!}+etc.$ Consider that our even powers are generated by sec$(x)=1+\frac{x^{2}}{2!}+5\frac{x^{4}}{4!}+61\frac{x^{6}}{6!}+etc.$ whereas odd powers are generated by tan$(x)=x+2\frac{x^{3}}{3!}+16\frac{x^{5}}{5!}+etc.$ But I do not understand, why this program fails to get those series separately? $\endgroup$ Mar 6 at 18:57
  • 1
    $\begingroup$ @FélixdelaFuente The 3rd part of output of Series is the list of coefficients. If the last coefficient is zero, as the degree-9 coefficient of Sec[x] is, it is truncated. The list of coefficients is shorter than Range[0, n]. I've updated it to calculate the correct length. $\endgroup$
    – Michael E2
    Mar 6 at 19:08
  • 1
    $\begingroup$ It works now for sec$(n)$, but somehow for tan$(x)$ it gives "almost" the correct polynomial form, but divided by the power index: $\frac{a_n\frac{x^{n}}{n!}}{n}$. Why could this happen? $\endgroup$ Mar 6 at 19:25
  • $\begingroup$ @FélixdelaFuente Testing revealed it needed one more tweak. $\endgroup$
    – Michael E2
    Mar 6 at 20:31
  • $\begingroup$ Thank you, now it works perfecly with all Trig functions! It is nice to have them with this representation. $\endgroup$ Mar 6 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.