2
$\begingroup$

I wrote a function to calculate how long of a period has past when a planet traverses an angle theta from perihelion in an orbit of a given eccentricity.

Integrate[(1 - 0.0167^2)^1.5/(2 Pi)  1/(1 + 0.0167 Cos [theta])^2, theta]
0.159088 (2.00084 ArcTan[0.983437 Tan[0.5 theta]] - (1.00028 Sin[theta]) /  
   (59.8802 + 1. Cos[theta]))

The domain around the origin of the formula above is -Pi ~ Pi so I defined

s[theta_] := formula above /; 0 <= theta < Pi; 
s[theta_] := formula above + 1 /; Pi < theta <= 2Pi;

To get how the angle varies with time, I applied InverseFunction to s and got the inverse function theta[t]. When I input theta[0.25], I get a numerical result but a s^{-1}[0.99] when input theta[0.99].

Where's the point?

enter image description here

$\endgroup$
2
$\begingroup$

It's strange that InverseFunction[s][0.99] doesn't work here, but the following seems to work fine:

s = Function[theta, Piecewise[
  {{0.159088*(2.00084*ArcTan[0.983437*Tan[0.5*theta]] - (1.00028*Sin[theta])/
       (59.8802 + 1.*Cos[theta])), Inequality[0, LessEqual, theta, Less, Pi]}, 
   {1 + 0.159088*(2.00084*ArcTan[0.983437*Tan[0.5*theta]] - (1.00028*Sin[theta])/
        (59.8802 + 1.*Cos[theta])), Inequality[Pi, Less, theta, LessEqual, 2*Pi]}}, 0]];

InverseFunction[s] /@ {0.99, 0.25}

Out[27]= {6.21821, 1.60419}

If you want to inject your formula into the Function without having to copy-paste, this is how you can do it:

s = Block[{
   formula := 0.159088 (2.00084 ArcTan[0.983437 Tan[0.5 theta]] - (1.00028 Sin[theta])/(59.8802 + 1. Cos[theta])),
   theta
  },
  Function[theta,
   Evaluate@Piecewise[{
      {
       formula, 
       0 <= theta < Pi
       },
      {
       formula + 1, 
       Pi < theta <= 2 Pi
       }
      }
     ]
   ]
  ]
$\endgroup$
  • $\begingroup$ Many thanks! It indeed works! I hope one day the problem can be solved. $\endgroup$ – Protesticon May 31 '18 at 14:01

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.