The Dormand–Prince method for ODEs Version 2
|
02-18-2024, 01:03 PM
Post: #1
|
|||
|
|||
The Dormand–Prince method for ODEs Version 2
The Dormand–Prince method for ODEs Version 2
The Dormand–Prince method is more accurate than the Runge–Kutta–Fehlberg method and it is used by the MATLAB ode45 solver. NOTE: Make sure you supply the ODE function with a clear matrix that returns the columns of x and y values. NOTES2: This version will alter the integation steps between a user-specified range of steps, given a range of min/max tolernce error values for y. The parameters of function ODE are: 1. The parameters x0 and y0 represent the initial integration point. 2. The parameter xf is the final x value where integratin stops. 3. The parameter h is the integration step. 4. The parameter hMinMax is the array of minimum and maximum integration steps. 5. The parameter hReduceFactor is the reducion factor for the integration step h. 6. The parameter tolerMinMax is the array of minimu and maximum error tolerances for the variable y. 7. The parameter resMat is the matrix that returns the columns of sampled x and y values. 8. The parameter skipSampling specifies the number of (x, y) point to exclude from appearing in the resMat matrix. To include all point supply an argument of zero. To skip a sequence of n points supply an argument of n. The function uses an IF statement to ensure that (xf, y) is included in the resMat matrix. The function returns the matrix resMat populated with (x, y) values. Example ======= To integrate fx2(x,y) = x+y from (1,2) to xf = 2 in steps of 0.01, minimum step of 0.001, maximum step of 0.05, step reduction factor of 2, minimum tolerance of 1e-6, maximum tolernce of 1e-4, and sampling all values of (x, y): M1 := ODE2(1,2,2,0.01,[0.001,0.05],2,[1e-6,1e-4],M1,0) The program creates a matrix with the x, y values. The last value of y at x=2 is calculate as 7.79079503593. Reference ========= Mathematical Modeling in Chemical Engineering, by Anders Rasmuson, Bengt Andersson, Louise Olsson, and Ronnie Andersson, published by Cambridge University Press 2014. See page 89. Program Listing =============== Code: EXPORT fx2(x,y) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)