Solving PDEs using the Ritz method on variational calculus problem (Student questions) I'm reading the book "Conduction Heat Transfer" by Vedat S. Arpaci. I'm currently at chapter 8 (I didn't read the rest of the book, though), which talks about the Variational Formulation - Solution by Approximate Profiles.
I have no background in Variational Calculus, but I think I understand the concept. The book shows an example of solving the following functional in order to obtain a function that minimizes the distance between two points:
$$
\int_{a}^{b}F(x, y, y^\prime) dx = \int_{a}^{b}(1 + y^{\prime^2})^{1/2}dx
$$
And then the book proceeds explaining how to get to the Euler equation associated with the variational problem:
$$
\frac{\partial F}{\partial y} - \frac{d}{dx}\Bigg{(}\frac{\partial F}{\partial y^\prime}\Bigg{)} = \frac{d}{dx}\Bigg{(}\frac{y^\prime}{(1 + y^{\prime^2})^{1/2}}\Bigg{)} = 0
$$
Finally, the book explains the difficulty on applying this method directly on physical problems. He proceeds explaining that, usually, what is done is the reverse: We consider the differential equation from our physical problem to be the Euler equation associated with the variational problem. So, for example, when solving the ODE:
$$
\frac{d^2 \theta}{dx^2} - m^2 \theta = 0
$$
Leas us to the following variational formulation:
$$
\delta \int_0^L \Bigg{(} \frac{d \theta}{d x} \Bigg{)} + m^2\theta^2 dx = 0
$$
Ok, so, as I understand, we now use the Ritz method to approximate a solution for $\theta$, by selecting an arbitrary function $y$ defined by
$$
y(x) = \sum_{n=0}^N a_n \cdot \phi(x)
$$
And for this particular problem, the book chooses
$$
\frac{\theta(\xi)}{\theta_0} = 1 - (1 - \xi^2)(a_0 + a_1\xi^2 + a_2\xi^4 + ...)
$$
Which leads me to some questions about this whole process, that I'm hoping someone can help me:
1) First of all, searching on the internet, I found this so called "Rayleigh–Ritz" method. Do anyone knows if it is the same method as the one I'm studying?
Ans.: As I found out, it seems that yes, they are related. Each author explains some things sightly different, though

2) For this Ritz method, how to choose a function $\phi(x)$ in general? How do I know if my choice is good?
Ans.: As I understand, any ortogonal basis should do. It is common to use polynomials.

3) Is there any relation between this method and the FEM or FEA?
Ans.: They seem related, but there are still more math to be done. It seems that FEM can be viewed as the Ritz method applied with some pre-defined $\phi$ functions. It is a different perspective from the weights in the Galerkins method.

I managed to find out some information about the above questions. I'm still having trouble with the bellow one, though:
4) I was trying a different example by solving the classic unidimensional steady state heat transfer equation using this method. I started with
$$
\frac{d^2u}{dx^2} = 0
$$
with boundary conditions
$$
u(0) = u_0, u(L) = u_L
$$
with $u_0$ and $u_L$ constants. And then I said that the variational problem associated with this problem is as follows (I can show my steps if necessary):
$$
\int_0^L \Bigg{(} \frac{du}{dx} \Bigg{)}^2 dx = 0
$$
My doubt here is if my approach is correct so far, and now should be the point where I should choose a trial function. I don't know which function should I choose, so I don't know how to proceed to use the Ritz method here...
Any help would be appreciated.
 A: I recently started looking into this as well, although from the point of view of FEM. I'm basing my stuff on the book "The Finite Element Method in Electromagnetics" by Jianming Jin. In 2.2.2 they have an example that is similar to yours.
I think the idea is that find your functional, which you have found as
$$I = \int_0^L \left( \frac{du}{dx}\right)^2 dx .$$
Then for Ritz, you try a trial function and try to minimize $I$ with respect to that. You are free to choose whatever trial function you want, so you could try for example a 3-rd order polynomial,
$$\tilde{u}(x) = c_0 + c_1 x + c_2 x^2 + c_3 x^3 .$$
Then you apply the boundary conditions. The first, $\tilde{u}(0) = u_0$ gives you $c_0 = u_0$. Then $\tilde{u}(L) = u_L$ leads to
$$u_0 + c_1 L + c_2 L^2 + c_3 L^3 = u_L\\
\Rightarrow c_1 = \frac{u_L-u_0}{L} - c_2 L - c_3 L^2 .$$
Thus your trial function with the correct boundary conditions is now
$$\tilde{u}(x) = u_0 + \frac{u_L-u_0}{L}x + c_2(x^2-L x) + c_3(x^3 - L^2 x) .$$
This you need to plug into $I$. After a whole bunch of calculations, you should get
$$I = \left(\frac{u_L-u_0}{L}\right)^2 L + \frac{1}{3} L^3 c_2^2+\frac{4}{5}L^5 c_3^2 + L^4 c_2 c_3 .$$
Now for the minimizing part, we want to find the values for which $I$ is minimal. So we need to differentiate with respect to $c_2$ and $c_3$ and set that to zero, leading to a system of equations to solve.
$$\frac{\partial I}{\partial c_2} = \frac{2}{3} L^3 c_2 + L^4 c_3 = 0\\
\frac{\partial I}{\partial c_3} = L^4 c_2 + \frac{8}{5} L^5 c_3 = 0 .$$
The solution to this is $c_2 = c_3 = 0$. So if you plug that back into the expression for the trial function, we are left with
$$\tilde{u}(x) = u_0 + \frac{u_L-u_0}{L}x ,$$
which is the exact solution for your steady-state heat problem.
It is exact because the solution happened to be a polynomial in the first place. If you would have picked another trial function you would only have been able to approximate it. Similar to how a polynomial is not an exact solution to the $\theta''-m^2\theta=0$ problem but it approximates the exact solution as best as it can.
