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.

I try to use this simple algorithm (paper) to calculate the Eccentric Anomaly expansion:

a[0]=0;
Do [
t1 = 1-a[k-1]^2/2+a[k-1]^4/24;
t2 = a[k-1]-a[k-1]^3/6;
a[k]=Expand[e*Sin[u]*t1+e*Cos[u]*t2,Trig->True];
Simplify[a[k]];
TeXForm[a[k]] >>"tex.01";
Print [a[k],k], {k,2}]

The result should be this one from Paper

but maybe because the algorithm is write with an old version of Mathematica I have as an output this different (in terms of trigonometric function) result

How can I re-arrange it to have the one in the paper? And when I have the result of the paper is it possible, then, to regroup the equation in terms of power series of sin(u), something like that:

equation

Thanks a lot !

share|improve this question

2 Answers 2

up vote 5 down vote accepted
Clear[a]

a[0] = 0;
a[k_] := a[k] =
  e*Sin[u]*(1 - a[k - 1]^2/2 + a[k - 1]^4/24) +
     e*Cos[u]*(a[k - 1] - a[k - 1]^3/6) // 
 TrigReduce // Expand; 

TraditionalForm /@ a[2]

enter image description here

TraditionalForm /@ (a[2] // Collect[#, Table[Sin[n*u], {n, 5}]] &)

enter image description here

share|improve this answer
    
This is what I'am looking for! Thanks a lot ! –  Panichi Pattumeros PapaCastoro Jul 26 at 13:51

There seem to be several issues here.

  1. The Mathematica code seems strange, arguably miswritten, though it appears you transcribed it correctly.

    • Simplify[a[k]]; doesn't appear to do anything; it's output is never assigned
    • Placing TeXForm[a[k]] >>"tex.01"; within the loop writes that file, then overwrites it in the next iteration. Perhaps >>> (PutAppend) was intended?
  2. TeXForm reorders terms as a result of using TraditionalForm, and it seems you do not want that reordering

  3. Even when Simplify is actually applied the results (using v10) differ from what you show. Expand seems to help.

Perhaps this gets you close enough:

a[0] = 0;

Do[t1 = 1 - a[k - 1]^2/2 + a[k - 1]^4/24;
 t2 = a[k - 1] - a[k - 1]^3/6;
 a[k] = Expand[e*Sin[u]*t1 + e*Cos[u]*t2, Trig -> True];
 a[k] = Simplify @ a[k],
 {k, 2}
]

TeXForm[HoldForm @@ {Expand @ a[2]}]

$e \sin (u)-\frac{1}{4} e^3 \sin (u)+\frac{1}{64} e^5 \sin (u)+e^2 \cos (u) \sin (u)-\frac{1}{24} e^4 \cos (u) \sin (u)+\frac{1}{4} e^3 \cos (2 u) \sin (u)-\frac{1}{48} e^5 \cos (2 u) \sin (u)+\frac{1}{24} e^4 \cos (3 u) \sin (u)+\frac{1}{192} e^5 \cos (4 u) \sin (u)$

share|improve this answer

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.