fprint:=proc(ncase,neqn,t,u) # # Procedure fprint displays the numerical and # exact solutions to the 1 x 1 ODE problem # # Type variables local u0, alpha, lambda, ue, diff, i: # # Problem parameters u0:=1.0: alpha:=1.0: lambda:=1.0: # # Define arrays ue:=array(1..neqn): diff:=array(1..neqn): # # Print a heading for the solution at t = 0 if (t <= 0.0) then # # Label for ODE integrator # # Fixed step modified Euler if (ncase = 1) then printf(`\n\n euler2a integrator\n\n`); # # Variable step modified Euler elif (ncase = 2) then printf(`\n\n euler2b integrator\n\n`); # # Fixed step classical fourth order RK elif (ncase = 3) then printf(`\n\n rkc4a integrator\n\n`); # # Variable step classical fourth order RK elif (ncase = 4) then printf(`\n\n rkc4b integrator\n\n`); # # Fixed step RK Fehlberg 45 elif (ncase = 5) then printf(`\n\n rkc45a integrator\n\n`); # # Variable step RK Fehlberg 45 elif (ncase = 6) then printf(`\n\n rkc45b integrator\n\n`); end if: # # Heading printf(` t u1 u1e u1-u1e\n`): # # End of t = 0 heading end if: # # Numerical and analytical solution output # # Analytical solution ue[1]:=u0*exp(lambda/alpha*(1.0-exp(-alpha*t))): # # Difference between exact and numerical solutions for i from 1 to neqn do diff[i]:=u[i]-ue[i]: end do: # # Display the numerical and exact solutions, and their difference printf(`%10.2f %10.5f %10.5f %10.5f \n`,t,u[1],ue[1],diff[1]); # # End of fprint end: