Implicit Trapezoidal Integration Method for ODE
|
02-20-2024, 10:37 PM
(This post was last modified: 02-21-2024 12:40 PM by Namir.)
Post: #1
|
|||
|
|||
Implicit Trapezoidal Integration Method for ODE
Implicit Trapezoidal Integration Method for ODE
================================================ Given f(x,y) and (x0,y0) as the initial point, xf as the final point, h is the integration step, toler as the tolerance value. The function to solve for y1 is: F(y1) = y1 - y0 - h/2*(f(x0,y0) + f(x1,y1)) The loop to calculate y at x=xf is: Code: While x0 < xf Example ======= given the ODE dy/dx = -2*y, x0=0, y0=1, xf=1, h=0.1, tolerance=1e-6. Use matrix M1 to store the rows of (x, y) values, skipping every 9 values. The command is: M1:=TRODE(0,1,1,0.1,0.000001,M1,9) The value of y at xf (te last row of matrix M1) is calculated as 0.135335193015. The exact value is obtained using the command: fxExact(1) Which yields the value 0.135335283237. Program Listing =============== Code: EXPORT fx(x,y) |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Implicit Trapezoidal Integration Method for ODE - Namir - 02-20-2024 10:37 PM
|
User(s) browsing this thread: 1 Guest(s)