Kind help to solve the below problem via maxima program
Find the extremal of the functional $\int_0^1((y^{'})^{2} + x^2)dx$ under the constraint $\int_0^1 y^2 dx\,=\,2$ and having $y(0)\,=\,0$ and $y(1)\,=\,1.$ Using Maxima programming.
I tried Like the below code kind help not coming
kill(all)$
ratprint: false$
depends(f,[x,y])$
depends(g,[x,y])$
depends(y,x)$
declare(P,real)$
assume(P>0)$ (As positive or negative or zero error was giving)
z: diff(y,x);
f:z^2+x^2;
g:y^2;
h:f+P*g;
h1:diff(h,y);
h2:diff(h,z);
h3:h1-diff(h2,x);
h4:ode2(h3,y,x);
h5: bc2(h4,x=0,y=0,x=1,y=1);
hr: trigrat(h5);
h6:integrate((rhs(hr))^2,x,0,1);
h7:solve(trigrat(h6)=2,P);
trigrat(rhs(h7[1]));
Need help
Answer expected from maxima
y= %k1*%e^(sqrt(l)*x)+%k2*%e^(-sqrt(l)*x)
This problem can be handled easily without the help of a symbolic processor so calling
$$ f(x,y,y',\lambda) = (y')^2+x^2+\lambda y^2 $$
we have
$$ f_y-\left(f_{y'}\right)'=y''-\lambda y = 0 $$
and after solving the ODE we have
$$ y = c_1 e^{\sqrt \lambda x}+c_2 e^{-\sqrt\lambda x} $$
with the boundary and integral conditions we need to solve
$$ \begin{array}{rcl} c_1+c_2 & = & 0\\ c_1 e^{\sqrt \lambda}+c_2 e^{-\sqrt\lambda} & = & 1\\ \frac{e^{-\sqrt{\lambda }} \left(e^{\sqrt{\lambda }}-1\right) \left(c_1 e^{\sqrt{\lambda }}+c_2\right)}{\sqrt{\lambda }} & = & 2 \end{array} $$
thus obtaining the constants $c_1, c_2, \lambda$ Here making the substitution $c_2 =-c_1$ we have
$$ \begin{array}{rcl} c_1 & = & -c_2\\2 c_1 \cosh \left(\sqrt{\lambda }\right) & = & 1\\ \frac{2 c_1 \left(\cosh \left(\sqrt{\lambda }\right)-1\right)}{\sqrt{\lambda }} & = & 2 \end{array} $$
This last step should be concluded using an iterative process which is not explicit in the MAXIMA script.
I hope this helps.