Python Difference in numerical approach for PDE vs ODE

AI Thread Summary
The discussion centers on the differences between algorithms used to solve partial differential equations (PDEs) and ordinary differential equations (ODEs), particularly focusing on finite difference methods. The key distinction lies in the treatment of derivatives: PDEs involve partial derivatives with respect to multiple variables, while ODEs involve total derivatives with respect to a single variable. The numerical implementation for both methods involves setting up a grid, defining boundary and initial conditions, and iterating to compute values.A significant challenge with finite difference methods for PDEs is the potential for numerical instability, where errors can grow exponentially over time. This instability necessitates the use of more sophisticated schemes, such as Crank-Nicolson and semi-implicit methods, to ensure stable solutions. In contrast, while ODEs can also exhibit instability, particularly in "stiff" cases, it is less common. The discussion highlights the importance of understanding stability in numerical methods when solving these types of equations.
TheCanadian
Messages
361
Reaction score
13
I think I am missing something painfully obvious, but what exactly is the difference in algorithms used to solve PDEs vs ODEs? For example, I've been looking at finite difference methods and the general steps (from what I've seen, although particular approaches may vary) used to numerically solve PDEs and ODEs using this method is to set up a grid for your domain, define boundary/initial conditions, and then take the total (partial) derivative and add it to the previous step's value to find adjacent values.

For example (after initializing values), if I have a function P composed of two variables (t and z) with the total (partial) derivative operator given by Dt for the time derivative and Dz for the spatial derivative, then I set up a loop and it might look something like this:

Code:
j = 0
i = 0
while i < len(t):
    DtP = Dt(P[j,i])
    P[j,i+1] = P[j,i] + ht*DtP

    while j < len(z):
       DzP = Dz(P[j,i])
       P[j+1,i] = P[j,i] + hz*DzP
       j = j + 1

    i = i + 1

Please correct my huge misunderstanding here (or if my basic code is incredibly wrong in its approach), but how exactly is the finite difference method different for the two approaches, besides using a partial or total derivative to iterate the next step?

If you have any other methods besides finite difference methods that could also help distinguish the two approaches to solving ODEs and PDEs, that would be helpful as well.[/code]
 
Last edited:
Technology news on Phys.org
If you use the straightforward finite differencing for a PDE, you usually encounter numerically unstable behavior, which means that the numerical errors in your solution grow exponentially as a function of the time variable t. That is why there are Crank-Nicolson schemes and semi-implicit schemes for solution of PDE:s.
 
  • Like
Likes TheCanadian
hilbert2 said:
If you use the straightforward finite differencing for a PDE, you usually encounter numerically unstable behavior, which means that the numerical errors in your solution grow exponentially as a function of the time variable t. That is why there are Crank-Nicolson schemes and semi-implicit schemes for solution of PDE:s.

Thank you for the clarifying that. I'll definitely read more about the stability of the different approaches for PDE solvers. In case I'm misinterpreting you, why do ODE not encounter the same unstable behaviour for the different approaches?
 
Sometimes the finite difference method can be unstable for ODE:s too, but it's more rare. When it happens, the equation is called a "stiff" ODE.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Back
Top