Approximating a solution to Poisson's equation

Consider an approximation of the solution to the steady state heat problem

$$u''(x) = 6, \: u(0)=0, \: u(2)=0.$$

We wish to approximate the solution by dividing the interval $[0,2]$ up into $n=4$ equal sub-intervals.

  1. Write down the system of equations that results.
  2. Use your favorite numerical environment to solve the system.
  3. plot your approximation together with the actual solution.

Comments

  • AbSAbS
    edited March 2021

    (1) First, we find the exact solution to compare our numerical approximation to. Integrating $u''(x)=6$ twice yields $$u(x)=3x^2+Cx+D.$$ Now we plug in our initial conditions: $$u(0)=D=0$$, and $$u(2)=3(2)^2+2C=0.$$ Therefore, $$u(x)=3x^2-6x.$$ Now we find an approximate numerical solution using the difference quotient $$u''(x) \approx \frac{u(x+h)-2u(x)+u(x-h)}{h^2} \approx \frac{u_{i+1}-2u_i+u_{i-1}}{\left(\frac{b-a}{n}\right)^2}.$$ Here, $a=0$, $b=2$, $n=4$, and $u''(x)=6$, so our system of equations is $$4(u_{i+1}-2u_i+u_{i-1})=+,$$ where $0 \leq i \leq 4$ and $$u_0=u_4=0.$$ Or, in matrix form, $$\begin{pmatrix} -8 & 4 & 0 & \\ 4 & -8 & 4 \\  0 & 4 & -8 \end{pmatrix} \begin{pmatrix} u_{1} \\ u_{2} \\  u_{3} \end{pmatrix} = \begin{pmatrix} 6 \\ 6 \\  6 \end{pmatrix}.$$

    (2) Using a modified fork of the "Numerical solution of 1D, linear BVP" Observable page, we find that the solution to the system of equations above is $$\begin{pmatrix} u_0 \\ u_1 \\ u_2 \\  u_3 \\ u_4 \end{pmatrix} = \begin{pmatrix} 0 \\ -2.25 \\ -3 \\  -2.25 \\ 0 \end{pmatrix}.$$

    (3) Below are graphs of the numerical approximations and the exact solution, created through the same fork as above:


Sign In or Register to comment.