How to solve this simple nonlinear ODE using the Galerkin's Method

526 Views Asked by At

I'm trying to solve a more complicated differential equation using the Galerkin's Method, but before that, I'm trying to understand how I would solve this simpler one:

$$ \cfrac{d^2u}{dx^2} + u^2 = 1;\quad\text{where} \;u(-1) = u(1) = 0.$$

I have to use the basis functions $\;\phi_j(x) = \sin(j\pi x)\;$.

Therefore, an approximation to the solution has the form:

$$ u(x) \approx \sum_{j=1}^{N} c_j \phi_j(x)$$

I notice that this choice of basis functions automatically satisfies the boundary conditions.

If I plug this approximation into the equation, I get:

$$ \sum_{j=1}^{N} c_j \phi_j''(x) + \left(\sum_{j=1}^{N} c_j \phi_j(x)\right)^{\!2} = 1.$$

So the residual can be defined as:

$$ r(x) = \sum_{j=1}^{N} c_j \phi_j''(x) + \left(\sum_{j=1}^{N} c_j \phi_j(x)\right)^{\!2} - 1$$

and the Galerkin's Method imposes that ${\displaystyle \int_{-1}^{1}} r(x) \cdot \phi_i(x)\,dx \:=\:0,\;$ for $i = 1,2,\dots,N$.

When I substitute the residual in the integral above, however, I face the nonlinear term

$$ \int_{-1}^{1} \left(\sum_{j=1}^{N} c_j \phi_j(x)\right)^{\!2} \cdot \phi_i(x)\,dx,$$

which evaluates to zero for any $i$ and $j$.

So this means that the nonlinear term $u^2$ at the original equation doesn't make any difference at all?

I'm pretty sure to be missing something here...

1

There are 1 best solutions below

5
On BEST ANSWER

As can be observed, the numerical solution to

$$ u''-u^2=1, \ \ u(-1) = u(1) = 0 $$

looks like an even function

enter image description here

and $\sum_{k=1}^N c_k \phi_k(x)$ with $\phi_k = \sin(k\pi x)$ is a sum of odd functions. As a result, the residue conditions establishes $c_k = 0$ as the best solution. Using instead $\phi_k(x) = \cos\left(\frac{(2k-1)}{2}\pi x\right)$ we will overcome this problem obtaining for $N = 3$

$$ u(x) = 3.30587 \cos \left(\frac{\pi x}{2}\right)+0.126786 \cos \left(\frac{3 \pi x}{2}\right)-0.00597599 \cos \left(\frac{5 \pi x}{2}\right) $$

with an absolute error as shown below

enter image description here