Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
Many thanks for this good answer. –  909 Niklas Sep 21 '12 at 11:33
add comment

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?

share|improve this answer
    
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. –  909 Niklas Sep 21 '12 at 11:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.