0% found this document useful (0 votes)
124 views1 page

Maple Modified Euler Method Modified Euler

This document solves an ordinary differential equation (ODE) using the modified Euler method to approximate the solution numerically. It defines the ODE as the rate of change of concentration C with respect to time equaling -k*C. The initial condition is C(0)=C0. The analytical solution is found to be C(x)=C0*e^(-kx). The modified Euler method is then used in a loop to calculate approximate C values from deltat=1 to 100 seconds, comparing the error to the analytical solution.

Uploaded by

Leo Kuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views1 page

Maple Modified Euler Method Modified Euler

This document solves an ordinary differential equation (ODE) using the modified Euler method to approximate the solution numerically. It defines the ODE as the rate of change of concentration C with respect to time equaling -k*C. The initial condition is C(0)=C0. The analytical solution is found to be C(x)=C0*e^(-kx). The modified Euler method is then used in a loop to calculate approximate C values from deltat=1 to 100 seconds, comparing the error to the analytical solution.

Uploaded by

Leo Kuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

> restart;

> ode:= diff(C(x),x) = -k*C(x);


d
ode := C( x ) = k C( x )
dx
> ics := C(0)=C[0];
Solve the ODE (for comparison only)
ics := C( 0 ) = C0
> dsolve({ode, ics});
( k x )
C( x ) = C0 e
> C100:=C[0]*exp(-k*100);
( 100 k )
C100 := C0 e

Modified Euler Method


> k:=.01:C[0]:=1:printf("deltat/s C/C[0] %%error
Time"):
for j from 0 to 4 do
deltat:=1/(10^j);
Ccalc:=C[0]:
icount:=0;
starttime:=time():
for i from deltat to 100 by deltat do
icount:=icount+1;
ytemp:=Ccalc*(1-0.5*k*deltat);
yprimeavg:=-k*ytemp;
Ccalc:=Ccalc+deltat*yprimeavg:
end do:
P_error:=100*(C100-Ccalc)/C100;
calctime:=time()-starttime:
printf("%8.6lf %8.6lf %8.6lf
%7.4lf\n",deltat,Ccalc,P_error,calctime):
end do:
deltat/s C/C[0] %error Time
1.000000 0.367886 -0.001679 0.0000
0.100000 0.367880 -0.000017 0.0160
0.010000 0.367879 -0.000001 0.1720
0.001000 0.367879 0.000001 1.8120
0.000100 0.367879 -0.000001 17.3290
>
>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy