Backwards difference matrix divided by negative delta x?

Click For Summary

Discussion Overview

The discussion revolves around generating a numeric solution to a second order differential equation using different difference matrices (forward, centered, and backward) in MATLAB. Participants are exploring the implications of using a backward difference matrix, particularly regarding the sign of delta x and the resulting solution vector.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant describes their experience generating solutions using forward and centered difference matrices, noting that they encountered issues with the backward difference matrix.
  • Concerns are raised about the resulting vector from the backward difference matrix being significantly larger than those from the forward and centered cases.
  • Another participant suggests that using a negative delta x for the backward difference might be appropriate, but this leads to confusion regarding the transposition of the solution vector.
  • There is a discussion about the general form of the backward difference and its relation to boundary conditions.
  • Two participants inquire about the second derivative used in the calculations, indicating a potential area of exploration or clarification.

Areas of Agreement / Disagreement

Participants express differing views on the appropriateness of using a negative delta x for the backward difference case, and the discussion remains unresolved regarding the implications of this choice on the solution vector's transposition.

Contextual Notes

There are unresolved questions about the assumptions made regarding delta x and its impact on the resulting matrices and solutions. The discussion also highlights potential dependencies on specific boundary conditions and the formulation of the second derivative.

kostoglotov
Messages
231
Reaction score
6
An exercise in my text requires me to (in MATLAB) generate a numeric solution to a given second order differential equation in three different ways using a forwards, centered and backwards difference matrix. I got reasonable answers for \vec{u} that agreed with each other (approximately) for the forward and centered cases, but I had problems getting the backwards case to work...I did get it to work, but I want to know if what I did to get it to work was correct or a fluke or incorrect.

Here is the exercise specifically:

d6QDYO1.jpg


imgur link: http://i.imgur.com/d6QDYO1.jpg

I used 10x10 difference matrices in MATLAB, but I will give 4x4 examples here below of the pattern I used in those matrices

Forward difference matrix

\begin{bmatrix}1 & 0 & 0 & 0\\ -1 & 1 & 0 & 0\\ 0 & -1 & 1 & 0\\ 0 & 0 & -1 & 1\end{bmatrix}

Centered difference matrix (with division by 2\Delta x)

\begin{bmatrix}1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ -1 & 0 & 1 & 0\\ 0 & -1 & 0 & 1\end{bmatrix}

Backward difference matrix

\begin{bmatrix}-1 & 1 & 0 & 0\\ 0 & -1 & 1 & 0\\ 0 & 0 & -1 & 1\\ 0 & 0 & 0 & -1\end{bmatrix}

For the forward and centered, like I said, I got reasonable results that agreed with each other approximately and agree trend wise when graphed.

Tow problems occurred when trying to apply the backwards difference matrix

1) first off, the resulting \vec{u} was some 5 orders of magnitude larger than the resulting \vec{u} obtained in the forward and centered cases.

I thought to myself that since it's a backwards difference, then in the same analogy to calculus, maybe the \Delta x should be negative as well. So to solve the given diff eq I then put the negative signs in the appropriate places. The second order differential term wouldn't have a negative sign in front since its equivalent second different matrix will be divided by (\Delta x)^2. This produced a very similar vector to the two solution vectors from forward and centered cases, BUT

2) the solution vector obtained after making the change \Delta x < 0 was a "transposed vector" compared to the other two solution vectors. Ie, the first and last, and second and second last, and third and third last, etc entries were swapped around...and I can't figure out why.

If in the backwards case I make \Delta x < 0 and apply a "vector transpose" to the solution vector then it agrees roughly with the forward and centered cases.

1) Am I correct about \Delta x < 0 for the backwards case?

and 2) why was the solution vector "transposed"?
 
Physics news on Phys.org
kostoglotov said:
An exercise in my text requires me to (in MATLAB) generate a numeric solution to a given second order differential equation in three different ways using a forwards, centered and backwards difference matrix. I got reasonable answers for \vec{u} that agreed with each other (approximately) for the forward and centered cases, but I had problems getting the backwards case to work...I did get it to work, but I want to know if what I did to get it to work was correct or a fluke or incorrect.

Forward difference matrix

\begin{bmatrix}1 & 0 & 0 & 0\\ -1 & 1 & 0 & 0\\ 0 & -1 & 1 & 0\\ 0 & 0 & -1 & 1\end{bmatrix}Backward difference matrix

\begin{bmatrix}-1 & 1 & 0 & 0\\ 0 & -1 & 1 & 0\\ 0 & 0 & -1 & 1\\ 0 & 0 & 0 & -1\end{bmatrix}

The general form for the backward difference is ## u'_{i} \approx \frac{ u_{i+1} - u_{i} }{\Delta x}, ## right?
So this would look like
##\frac{1}{\Delta x} \begin{bmatrix}-1 & 1 \end{bmatrix} \begin{bmatrix}u_1 \\ u_2\end{bmatrix} = u'_1##
This seems like the right backbone for the problem. Make sure that your stand-alone term in the bottom right corner is used to enforce a boundary condition or something.

As far as the negative to transpose business...if you change delta x to negative delta x ( you shouldn't ), then you will get the same as the transpose of your first matrix (forward difference).
 
Also, what were you using for your second derivative?
 
RUber said:
Also, what were you using for your second derivative?

A^TA
 

Similar threads

  • · Replies 33 ·
2
Replies
33
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 7 ·
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 27 ·
Replies
27
Views
3K
  • · Replies 16 ·
Replies
16
Views
4K
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K