# Homework Help: Rayleigh-Ritz Approximation (Obtaining the constants)

1. Sep 18, 2011

### roldy

1. The problem statement, all variables and given/known data
Consider the differential equation

$$-\frac{d^2u}{dx^2}=cos\pi x$$ for 0<x<1

subject to the boundary condition

u(0)=0, u(1)=0

Determine a three-parameter solution, with trigonometric functions the least-squares method

Given: $$u=\phi_0 + c_1\phi_1 + c_2\phi_2 + c_3\phi_3$$

$$\phi_0=0, \phi_1=sin\pi x, \phi_2=sin2\pi x, \phi_3=sin3\pi x$$

2. Relevant equations
1st and 2nd derivatives of u with respect to x
Derivative of R with respect to ci

$$0=\int_0^1R\frac{\partial R}{\partial c_i}dx$$

3. The attempt at a solution

$$u=c_1sin\pi x + c_2sin2\pi x + c_3sin3\pi x=\Sigma_{i=1}^n c_isin(i\pi x)$$

$$\frac{d^2u}{dx^2}=-\Sigma_{i=1}^n c_i(i\pi)^2sin(i\pi x)$$

and

$$\frac{\partial R}{\partial c_i}=(i\pi)^2sin(i\pi x)$$

so then,

$$R=-\frac{d^2u}{dx^2}-cos(\pi x)=\Sigma_{i=1}^n c_i(i\pi)^2sin(i\pi x)-cos(\pi x)$$
$$0=\int_0^1R\frac{\partial R}{\partial c_i}dx=\int_0^1\left[\Sigma_{i=1}^n c_i(i\pi)^2sin(i\pi x)-cos(\pi x)\right]\left[(i\pi)^2sin(i\pi x)\right]dx$$

The term,
$$(i\pi)^2$$ is dropped out because it's just a multiplicative factor.

So then I arrive here, at which point I'm stuck
$$0=\int_0^1\left[\Sigma_{i=1}^n c_i(i\pi)^2sin(i\pi x)-cos(\pi x)\right]sin(i\pi x)dx$$

I know that I need to somehow get $$c_1, c_2, c_3$$
If I integrate the above integral across the summation, I'll end up with one equation with the three constants.

I would think that I need three equations. Do I perform the summation from i=1,2,3 and then integrate, which would give me one equation, or do I integrate and then do the summation? If I remember correctly I can take the summation out before the integral. Is this correct?