Implicit Trapezoidal Integration Method for ODE +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP Prime Software Library (/forum-15.html) +--- Thread: Implicit Trapezoidal Integration Method for ODE (/thread-21333.html) |
Implicit Trapezoidal Integration Method for ODE - Namir - 02-20-2024 05:37 PM 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) |