![]() Note that for the function fhermite, we must supply both the first and second derivatives of y with respect to t. The script e4s510.m implements these comparisons. % Set up matrices for Runge-Kutta methodsī = d = Ĭ = % 3 steps of Runge-Kutta are required so that hermite can start. % The function f(t,y) and its derivative must be defined by the user. % Initial value of y is given by startval, step size is given by step. % The initial and final values of t are given by tspan =. % Example call: = fhermite(f,tspan,startval,step) % first order differential equation dy/dt = f(t,y). Note that in this function, the function f must provide both the first and second derivatives of y.įunction = fhermite(f,tspan,startval,step) The Matlab function fhermite implements this method, and the script is given below. This is a reflection of the fact that integration is a well-conditioned process, whereas differentiation is ill-conditioned.Īnd thus y n ″, etc., are easily calculated as the first derivative of f. It should be noted that, in contrast to numerical differentiation, the order of a numerical integration method is greater than that of the interpolation or approximation formula from which it is derived. In situations where f( x) cannot be evaluated but is tabulated for given values of x, integration of the spline interpolation formulas or of the approximation formulas obtained in the previous section may be used. At each stage of mesh refinement, a combination of results can be used to further reduce the error in a manner similar (but not necessarily identical) to T 1,1. The pattern is continued with successive halving of the intervals, except that whenever two successive results for a particular interval are sufficiently close, that interval is no longer reduced and the current value of the integral over that interval is held constant until the final result is obtained. If not, each of the two intervals is again halved and the procedure is repeated for both intervals. The difference between the two results is also compared with a predetermined tolerance, and if it is sufficiently small T 1,1 is taken as the final result. Which has the effect of eliminating the principal part of the error.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |