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

Do [
t1 = 1-a[k-1]^2/2+a[k-1]^4/24;
t2 = a[k-1]-a[k-1]^3/6;
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:


Thanks a lot !


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

| improve this answer | |

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)$

| improve this answer | |

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.