The following test indicates that ode accuracy order is only 3 (i.e., the Runge Kutta approximation is exact for polynomials only of degree 3). The documentation says the algorithm is "Runge-Kutta (4,5) formula, the Dormand-Prince pair". Shouldn't this have higher accuracy order?
figure, hold on options = odeset('MaxStep',1); for p = 1:6 [t,y] = ode45(@(t,f) 1-(p+1)*t^p,[0,1],0,options); y_ = t-t.^(p+1); plot(t,[y,y_],'+-'); disp([num2str(p),' ',num2str(max(abs(y-y_)))]) end output: 1 3.3307e-16 2 2.2204e-16 3 7.2164e-16 4 0.00038174 5 0.0014764 6 0.00083657
Best Answer