\documentclass{article}[12pt]
\begin{document}
{\large{\bf HW 4. Numerical solutions}}

~

~

{\bf 1. Approximation methods}



Approximate solution and the cost of the problems:
$$
I_1=\min_{u(x0, ~u(0)=0, u(\pi)=0}
\int_0^\pi \sin(\pi x)  (u')^2+  (u)^2 dx ~\mbox{if }\int_0^\pi   u \. dx=1
$$
and
$$
I_2=\min_{u(x0, ~u(0)=0, u(\pi)=0}
\frac{\int_0^\pi x (u')^2 dx}{\int_0^\pi(1- x) (u)^2 dx}
$$
representing $u(x)$ as a polynomial or trigonometric polynomial of the second order and finding the coefficients. 

~

To check, apply same procedure to the problem 
$$
\min_{u(x0, ~u(0)=0, u(\pi)=0}
\frac{\int_0^\pi  (u')^2 dx}{\int_0^\pi (u)^2 dx}
$$
with the known answer.

~

{\bf 2. Gradient method}

Let  $u(x)$ be the solution of  brachistochrome problem
$$ \min{u(x)} \int_0^1 F(u, u')dx, \quad F= \frac{\sqrt{1+u'^2}}{\sqrt{2 g\, u}}$$
and $u(0)=a$ and $u(1)=b$.

 Compute the first iteration $u_1(x)$ of U(x)  using representation 
$$u_0(x)= (b-a)x+a, \quad u_1(x) = u_0(x) - \epsilon x\,(1-x) S(u_0)$$
where $S(u)$ is the functional derivative:
 $$
S(u)= \frac{\partial F}{\partial u}- 
\frac{d}{d \, x} \frac{\partial F}{\partial u'}
$$ 
Notice that multipliers $ x\,(1-x)$  fix the boundary conditions. 
Compare with the known solution choosing $a$ and $b$. Try different values of $\epsilon$. 

Compute the next iteration. 
\end{document}
