Finite difference method-convergence

Click For Summary

Discussion Overview

The discussion revolves around the implementation of the finite difference method for solving a fourth-order differential equation. Participants explore the rate of convergence, error behavior with varying step sizes, and specific formulations of the finite difference equations. The conversation includes technical details about the method, error calculations, and the correctness of given functions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant seeks clarification on the formula for the rate of convergence and how to determine values for \( J_1 \) and \( J_2 \).
  • Another participant questions how the error behaves as the step size decreases, wondering if it increases or decreases.
  • Several participants discuss the specific fourth-order problem they are trying to solve, including boundary conditions and the formulation of the differential equation.
  • There is a claim that halving the step size results in the error being divided by 4, but this is challenged by another participant who suggests that a difference equation must be derived first.
  • Participants share the finite difference equations they derived for both the original problem and the transformed problem involving \( w(x) \).
  • One participant suggests a possible error in the formulation of the function \( f(x) \), leading to a verification process involving substitutions into the differential equation.
  • Another participant reports increasing errors when solving the difference equation with specific step sizes, suggesting numerical instability.
  • After confirming a correction to the function \( f(x) \), one participant asks if others know how to solve the difference equation.
  • Participants share their error calculations from their implementations of the finite difference method, comparing results and discussing the reference points used for these errors.

Areas of Agreement / Disagreement

There is no consensus on the behavior of the error with respect to step size, and participants express differing views on the correctness of the function \( f(x) \). The discussion remains unresolved regarding the implications of the derived equations and the stability of the numerical method.

Contextual Notes

Participants reference specific mathematical formulations and numerical methods without fully resolving the implications of their findings. There are indications of potential errors in the problem setup and numerical instability, but these issues remain open for further exploration.

Who May Find This Useful

This discussion may be useful for those interested in numerical methods for differential equations, particularly in the context of finite difference methods and convergence analysis.

  • #31
I like Serena said:
You have measurements at $x_0, x_1, ..., x_J$.
That are $(J+1)$ measurements.
However, you can leave out $x_0$ and $x_J$ since they are both given as boundary conditions: they are 0.
The leaves you with $(J-1)$ measurements.
So your matrix should be $(J-1) \times (J-1)$, your $b$ should have $(J-1)$ entries, and your resulting $w$ should have $(J-1)$ entries.

However, your "fix" gives you $J$ entries instead of $(J-1)$ entries.
That is $1$ off.
If it helps you to get the right answer, it means that later on you are also $1$ off.
So before you were probably calculating with an uninitialized variable.

Yes,you are right! :o

I looked again my code and realized that I didn't fix that $J$.
I have written the following in a function:
Code:
fun(b,J){
         for(j=0; j<J-1; j++)
		b[j]=f(X(j,J));	
         
 }

At the beginning I called the function fun(b,J-1) and that is wrong, since X is calculated in the function
Code:
X(j,J){
      x=(j+1)/J;
 }
Then I fixed it by calling the function by fun(b,J).
 
Last edited by a moderator:
Physics news on Phys.org
  • #32
mathmari said:
Yes,you are right! :o

I looked again my code and realized that I didn't fix that $J$.
I have written the following in a function, fun(b,J):
Code:
for(j=0; j<J-1; j++){
                x=(j+1)*h;
		b[j]=f(x);	
}

At the beginning I called the function fun(b,J-1) and in the function it was for(j=0; j<J; j++) and that is wrong.
Then I fixed it by calling the function by fun(b,J).

Aha!
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 17 ·
Replies
17
Views
4K
Replies
9
Views
2K
Replies
1
Views
11K
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 7 ·
Replies
7
Views
5K
Replies
0
Views
1K
  • · Replies 7 ·
Replies
7
Views
3K