Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Following this question/answer I discovered and played with SeriesCoefficient. In particular, I tried

SeriesCoefficient[Exp[λ x - x^2], {x, 0, n}] 

which nicely returns

(* Piecewise[{{HermiteH[n, λ/2]/n!, n >= 0}}, 0] *)

Question

On the other hand, why does

SeriesCoefficient[Exp[ x - x^2], {x, 0, n}] 

(a special case of the above) returns

(* Piecewise[
 {{DifferenceRoot[Function[
      {\[FormalY], \[FormalN]}, 
      {2*\[FormalY][\[FormalN]] - \[FormalY][1 + \[FormalN]] + 
         (2 + \[FormalN])*\[FormalY][2 + \[FormalN]] == 
        0, \[FormalY][0] == 1, \[FormalY][1] == 
        1}]][n], n >= 0}}, 0] *)
share|improve this question
add comment

2 Answers 2

An interesting observation is that the difference in output doesn't even depend on the value of the parameter $\lambda$. Instead, it depends on the form of the exponential:

SeriesCoefficient[Exp[(λ - x) x], {x, 0, n}]

enter image description here

SeriesCoefficient[Exp@Expand[(λ - x) x], {x, 0, n}]

enter image description here

So it looks like SeriesCoefficient picks different solution methods right from the start based on the form of the input, even though it doesn't have attribute Holdall or similar. The reason for this may have to do with the fact that there are different methods for special functions, and which of them is recognized as the most promising at the start depends on the initial form. That's all I can come up with. The upshot: for this functionality, $e^{x(\lambda -x)}$ is not the same as $e^{\lambda x-x^2}$.

share|improve this answer
    
+1 Thanks for your observations. I was hoping someone from Wolfram would acknowledge this as a bizarre feature. –  chris Mar 21 '13 at 21:46
add comment

This is strange - because I haven't seen so many dots as the ones spat out in the DifferenceRoot (they are, documentation tells me, formal parameters never to be assigned a value. If anyone can add an answer with a mini-tutorial on how they are used, it would be appreciated. There's a few answers here with further explanation).

In any case, it doesn't seem to be wrong:

h1[n_]:=HermiteH[n, 1/2]/(n!)

which is what you expect as a special solution of your second case, and

h2[n_]:=DifferenceRoot[
    Function[{\[FormalY], \[FormalN]}, {2 \[FormalY][\[FormalN]] - \[FormalY][
         1 + \[FormalN]] + (2 + \[FormalN]) \[FormalY][
          2 + \[FormalN]] == 0, \[FormalY][0] == 1, \[FormalY][1] == 
       1}]][n]

which is what you actually get and looks intimidatingly like

Mathematica graphics

seem to agree:

Table[h1[n] == h2[n], {n, 0, 100}]

Mathematica graphics

Looking a bit at the documentation and the form of the second output, it seems that the DifferenceRoot expression is a recursive definition for the Hermite polynomial at the specific point but I can't offer you a proof more than the fact that they agree for the first few hundred values of n.

---EDIT---

As per your comments, I have no clue why this doesn't get "seen" as a Hermite polynomial. My guess was that at x=1/2, n! gets suspiciously cancelled at all terms of the series but it would be strange for Mathematica to not hold the expression before doing any pattern matching.

For the record, I insist this is not a wrong result mathematically (the recursive definition for Hermite at x=1/2 would be

    myh[n_] := DifferenceRoot[
          Function[{\[FormalY], \[FormalN]}, 
                 {\[FormalY][\[FormalN] + 1] - \[FormalY][\[FormalN]] + 2 (\[FormalN]) \[FormalY][\[FormalN] - 1] == 0, 
                  \[FormalY][0] == 1, \[FormalY][1] == 1}]][n]

and the series given is myh[n]/n! but I think I see your point and I agree - in terms of Mathematica evaluation the result is, well... wrong. Evaluating the second expression takes twenty+ times longer:

Divide @@ ({AbsoluteTiming[h2[i];], AbsoluteTiming[h1[i];]} /. 
i -> 1000) // First
(*24.*)

I'll keep the answer up for a couple of days and then delete.

share|improve this answer
    
Re: formal symbols, these posts should give you a good idea of the applications: (search result) –  Mr.Wizard Mar 20 '13 at 10:27
1  
I'm not voting for this answer, yet, because I think the real question is why doesn't Mathematica simplify the DifferenceRoot object to the shorter HermiteH form. –  Mr.Wizard Mar 20 '13 at 10:30
    
Thanks for checking! I am after why it fails to give a closed form. It seems to me its a sort of shortcoming? –  chris Mar 20 '13 at 11:08
    
@Mr.Wizard thanks for the link - searching for "formal parameters" gave poorer results than "formal symbols".I've edited accordingly –  gpap Mar 20 '13 at 11:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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