I have $u(x) = e^x \in H^1 (\Omega)$ and $\Omega = (0,1)$ and should compute the solution $p \in \mathbb P^2$ of the minimization problem: $$|| u-p||_{H^1(\Omega)}^2 = inf ||u-q||_{H^1(\Omega)}^2$$ where $q \in \mathbb P^2$. In addition to that, I should determine the $H^1(\Omega)$- and the $L^2(\Omega)$-norm of the difference u-p.
My questions:
a) How does the linear system looks explicitly and how does the error representation look like?
b) The information of (a) should be enough to let the system solved by Maple / Mathematica / ... ?
Thanks for your help!
First method
Let $p=ax^2+bx+c$. Then as $p'(x)=2ax+b$ you have.
An explicit computation leads to (using wolfram alpha: $$\|u-p\|_{H^1}^2=\int_0^1 (e^x-ax^2-bx-c)^2+(e^x-2ax-b)^2 dx=\frac{23 a^2}{15}+a \left(\frac{5 b}{2}+\frac{2 c}{3}-2 e\right)+\frac{4 b^2}{3}+b (c-2 e)+c^2+2 c-2 e c+e^2-1$$
this is a quadratic function of tree variables so taking the gradient in $(a,b,c)$ leads to a system of 3 equations with 3 unknowns, more precisely: \begin{align}\frac{46}{15} a+\frac{5 b}{2}+\frac{2 c}{3}-2e=0\\ \frac{5}{2}a+\frac{8}{3} b+c-2e=0\\ \frac{2}{3}a +b+2c+(2-2e)=0 \end{align} Second method (the best one in my opinion)
Note that $H^1$ is an Hilbert space with the inner product: $$\langle u, v\rangle = \int_0^1 (u' v' +uv)(x) dx$$
So the question can be rewritten as:
You can then use usual tools of hilbertian spaces: with $q_0,q_1,q_2$ an orthonormal basis of $\mathbb{P}^2$ (you can find one from $(1,x,x^2)$ using Gram Schmidt ) you obtain: $$p=\langle q_0,u \rangle q_0+\langle q_1,u \rangle q_1+\langle q_2,u \rangle q_2$$ which directly leads to the expression of $p$ and of the distance.