0
$\begingroup$

Given the problem

\begin{align} &u''− x^2u(u − 1) = 0,\\ &u(1) = 2,\\ &u(3) = 4, \end{align}

solve it with a finite difference method with the interval divided into $N+1$ equal intervals between $1 \leq x \leq 3$.

  • First in detail write the equations when $N=3$.
  • Draw the interval and mark the discretization points for the differential equation in the $N$ inner points for arbitrary $N$-value.
  • Write the equations $f(u) = 0$. Write a MATLAB function that for a given $u$ calculates $f(u)$.
  • Use global values for the boundary values.

What I can do is transform the differential equation to first order:

$ v_1=u,\\ v_2=u',\\ v_2'=u''. $

Hence

$ v_2'-x^2v_1(v_1-1)=0\\ v_1(1)=2\\ v_1(3)=4 $

But I don't know how to continue.

2 Answers 2

2

Solving a boundary value problem using finite differences requires that you reduce your differential equation to a system of linear equations.

For this particular problem we're solving a differential equation on the interval $[1,3]$ split into $N+1$ equal subintervals. Thus we are looking for a vector $\textbf{u} = [ u(x_{0}),u(x_{1}),\ldots,u(x_{n+1})]$ containing the function values at the points $x_{i} = 1 + i(\frac{2}{n+1})$.

Recall the finite difference formula for the second derivative of a function: $ f''(x) = \frac{f(x+h) - 2f(x) + f(x-h)}{h^{2}}$

If you let $h$ be the space between successive values $x_{i}$ then the differential equation can be rewritten as the following system of linear equations: $ [u_{i+1} - 2u_{i} + u_{i-1}]/h^2 + x_{i}^{2}u_{i}(u_{i} - 1) = 0, \quad 1\leq i \leq n $ $ \textrm{and}\quad u_{0} = 2, \quad u_{n+1} = 4.$ This system is easily solved in MATLAB.

  • 0
    Many thanks for this good answer.2012-09-21
1

I think your first order differential equation is incorrect. Where is the $u_2 ''$? And why don't you use the finite difference quotient for the second derivative?

  • 0
    Thank you for the answer. I updated and corrected the question. It should be u2'' like you said and I've now corrected it. And I now remember that for the FDM I use the finite difference quotient but I didn't remember that on top of my head, now I realize that the next step to take is to apporximate the derivatives with difference quotients.2012-09-21