kill(all)$

integral:  for ellipse.  ' version 1.0'
peter.vlasschaert@gmail.com,24/06/2018.

rem : circle ,'closed orbit', a1=a2.

load(lrats)$

assume(a1<a2);

assume (a1>0);

pa1:1/(a2+a1*cos(x)) = pa;

p1: 1/(a2+a1*cos(x))^2;

flight time integral  : ellipse , 'closed orbit'

p1a:'integrate(p1,x,0,x) ;

solve : 'p1a' , constraint from above.

p2:integrate(p1, x);

first      part : constant
=================

p3:part(p2,1);

second part : function(a1,a2,x)
========================

p4:part(p2,2);

second part :  1e from second part.
============================

p5:part(p2,2,1);

introduce : half angles. (google ,tan(x/2)),fig.

We want use formula ( fig 1)   θ => x ,tan(x/2) =sin(x)/(1+cos(x)) =q
=>  q=tan(x/2)

p5a :sin(x)/(1+cos(x)) =q ;

p5b :lratsubst([p5a],p5);

?? negdistrib;

negdistrib;

p5c:factor(p5b);

p5d:radcan(p5c);

p5e:coeff(p5c,atan(((a2-a1)*q)/sqrt(a2^2-a1^2)));

remove : a2 ,coef 'p5e'

p5f:p5e/a2;

second part : 2e from second part.
===========================

p6:part(p2,2,2);

p6a:trigsimp(p6);

p6b:factor(p6a);

How to find coef: sin(x) ,second part.

p6c:coeff(p6b,sin(x));

rem : ratcoeff :' expand equation,p6c  ' 

we  put everything to gether :

p7:p3*(p5c+p6b);

p7a:p3*(p5d+p6b);

p7b: p5f = φ*1/((a2-a1)*(a2+a1));

p7c:solve(p7b,φ);

p7c1:p7c[1];

compensate : sqrt(a2^2-a1^2) ,multplication by 1 'second part'

p7d:p5f*(p3*a2*atan((sqrt(a2-a1)*q)/sqrt(a2+a1))-rhs(1/p7c1)*a1*sin(x)*lhs(pa1));

! found : standard mathematical handbook,beyer ,1991,with above constraint.
=============================================================
constraint : a2>a1 ,a1 > 0
=============================================================

result : integral 'p1a' : use later for time in orbital position '

p8:p1a=p7d;

see above : see fig 1.

  final result 
==========
rem : q = tan(x/2)

p8a:subst(tan(x/2),q,p8);

don't : use  ratsubst , only subst.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------