kill(all)$

maxima : brachistochron problem,version 1.0
peter.vlasschaert@gmail.com, 17/12/2020

info : Euler Lagrange Equation = (ELE),minimize (= "Functional")

load packages , option.
==================

load(lrats)$ ratprint:false $
load(contrib_ode)$

step 1: Mathematical model : brachistochron
-----------------------------------------------------------

path under influence of gravity A to B

a) basic : physics
==============

→ v = ds/dt

find :ds

p1a:ds^2= dx^2+dy^2;
p1b:expand(p1a/(dx)^2);
p1c:sqrt(p1b);
p1d:subst([abs(ds)=ds,abs(dx)=dx],p1c)*dx;

→ dy/dx = diff(y,x),maxima conversion p1d

p1e:lhs(p1d)=lratsubst([dy/dx='diff(y,x)],rhs(p1d));

→ maxima :conversion p1d

assume(B>0);

p1f:integrate(1,s,0,s)=integrate(part(rhs(p1e),2),x,0,B);

p1f1:part(rhs(p1f),1);

conversion :  maxima v0=0 @ point A

find : v , influence of gravity during the motion A to B

p1aa:v=ds/dt;
p1bb:p1aa*dv;

→ dv/dt =g 

p1cc:lhs(p1bb)=lratsubst([dv/dt=g],rhs(p1bb));

→ conversion :  maxima v0=0 @ point A

p1dd:integrate(v,v,v0,v)=integrate(g,y,0,y);

p1ee:subst([v0=0],p1dd);

p1ff:rootscontract(solve(p1ee,v)[2]);

p1ff1:rhs(p1ff);

minimize :time (=t), build functional
use ;

p1ff2:F=rootscontract(p1f1/p1ff1);

listofvars(rhs(p1ff2));

p1gg:solve(p1bb,dt);

Minimize : 'y'   : y =y(x)

p1gg1:integrate(1,t,0,t)=integrate(rhs(p1ff2)*d(x),x,0,B);

rem : d(x) no meaning only representation: d(x)=1

general Form
===========

Minimize : 'y'   : y =y(x)

p2:I =integrate(F(x,y,'diff(y,x))*d(x),x,x1,x2);

rem :diff(y,x) =df

p2a:subst([diff(y,x) =df],p2);

→ brachistochron , find  F
use :F=F(x,y,df)

depends(y,x);

p2b:rootscontract(p1ff2);

equation :minimize , integral:p2a, problem : p1gg1

p3a:ELE(ff,yy,dyy):=diff(ff,yy)-diff(diff(ff,dyy),x);

p3b:ELE(rhs(p2b),y,diff(y,x));

p4b:ratsimp(p3b);

p5b:(2*y*sqrt(('diff(y,x,1))^2+1)*('diff(y,x,2))+(('diff(y,x,1))^2+1)^(3/2))*(-1);

p6b:solve(p5b=0,diff(y,x,2));

solve :differential equations ,p6b

p7:p6b[1];

p7a1:ode2(p7,y,x);

p7a2:contrib_ode(p7,y,x);

step:1     dy/dx =u
---------

p8a:diff(y,x)=u;

p8a1:reverse(p8a);

depends(u,y);

p8b:diff(p8a,x);

p8c:lhs(p8b)=lratsubst([p8a],rhs(p8b));

step:2  into p7 ( from step 1)
--------

p9a:lratsubst([p8a,p8c],p7);

step:3 (solve : ode p9a)
----------

p10a:ode2(p9a,u,y);

p10b:-(1)*p10a;

p10c:[part(rhs(p10b),2)=log(c1)];

p10d:lratsubst(p10c,p10b);

p10e:p10d-part(rhs(p10d),2);

p10f:logcontract(p10e);

p10g:solve(p10f,u);

p10h:ratsimp(p10g[2]);

step:4 (find :x)
----------

p11a:ratsimp(subst([p8a1],p10h));

→ set :y = c1*(sin(t/2))^2  into p11b

p11b:y = c1*(sin(t/2))^2;

solution : A to B 

theoretical : math
dx/dy =sqrt(y)/sqrt(c1-y),upside down (=p11a), (*)

→  dy : differential element for integration (*)
use :p11b

p11c:diff(p11b);

reason : c1 :constant ( =del(c1))

p11c1:[diff(y,x)=del(y)/del(x),del(c1)=0];

p11c2:lratsubst(p11c1,p11c);

p11c3:ratsimp(p11c2/del(t));

p11c4:rhs(p11c3);

→ reverse : dy/dx  → dx/dy from rhs(p11a)

p11d1:m=sqrt(y)/sqrt(c1-y);

use :p11b 

p11e1:trigsimp(subst([p11b],p11d1));

p11e1a:subst([abs(sin(t/2))=sin(t/2),abs(cos(t/2))=cos(t/2)],p11e1);

→ integrandum (with respect :t)

ig:rhs(p11e1a)*p11c4;

→ x (= find)

igral:x=factorsum(integrate(ig,t)+c2);

→ initial condition t= 0 , x=0 and y=0, particle
    start from origin

p12a:igral;
p12b:p11b;

p12c:[t=0,x=0,y=0];

x :value

p13a:reverse(subst(p12c,p12a));

p13b:subst([p13a],p12a);

select: c1=2

p13b1:subst([c1=2],p13b);

y:value

p14a:p12b;

select: c1=2

p14a1:subst([c1=2],p14a);

rem : t parameter , hypocycloid

How to get plot :
=============

Menu : Plot: Plot2d:special ( choose :parametric)

wxplot2d(['parametric, rhs(p13b1), rhs(p14a1), [t, 0, 40]],
 [nticks, 30], [x,0,40]
,grid2d)$

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