| > | restart; with(plots): with(inttrans): alias(Y(s)=laplace(y(t),t,s)): |
Warning, the name changecoords has been redefined
Cold pills: Periodic impulses and Laplace transforms
About this worksheet
Author and Date
Matthias Kawski
Arizona State University
http://math.asu.edu/~kawski
| > |
Original version MAPLE release 8.
June 2007.
| > |
Content, Purpose and Use
This worksheet illustrates a naive applications of Laplace transforms to solve
linear differential equations driven by a periodic pulses -- here interpreted as
taking medicine.
| > |
A good part of the worksheet experiments with MAPLE's capabilities of
working with infinite series, or simply long series --- but in the end we take
a pragmatic approach, and type in the expected solution by hand when MAPLE's
invlaplace balks.
Suitable for demos, inviting simple modifications ... and some questions such as
how will the final level change when one doubles the daily dose, or takes twice
the dose every other day. The last sections contains a quick analysis of the
quasi-steady state as a function of dosage and schedule.
| > |
Updates and log of modifications.
none yet..
Starting from the differential equation
A finite number of days in the treatment
| > | de0a:=diff(y(t),t)=sum(Dirac(t-'k'),'k'=1..7):de0a; AE0a:=subs(y(0)=0,laplace(de0a,t,s)): AE0a; Y(s)=solve(AE0a,Y(s)); |
The infinite treatment
| > | de0:=diff(y(t),t)=sum(Dirac(t-'k'),'k'=1..infinity):de0; AE0:=subs(y(0)=0,laplace(de0,t,s)): AE0; Y(s)=solve(AE0,Y(s)); |
Adding decay (excretion) to the model
| > | de1:=diff(y(t),t)-y(t)=sum(Dirac(t-'k'),'k'=1..7): de1; AE1:=subs(y(0)=0,laplace(de1,t,s)): AE1; Y(s)=solve(AE1,Y(s)); |
| > |
| > |
Restart in the frequency domain (sign error)
This is what the geometric series (almost) correctly sums to ... did not want to bother
to try to get MAPLE do it to above formula (but made a sign mistake)
| > | Y1:=1/s/(1+exp(-s)); y1:=invlaplace(Y1,s,t); |
Just for illustration, we make MAPLE expand the periodic delays into a series
-- the sign erro becomes obvious here.
| > | Y1=subs(exp(-s)=x,Y1); series(subs(exp(-s)=x,Y1),x=0,12); Y1=simplify(subs(x=exp(-1),series(subs(exp(-s)=x,Y1),x=0,7))); |
| > | display([ plot(y1,t=0..12,-3..3,thickness=3,discont=true), plot(y1,t=0..12,-3..3,thickness=1) ],xtickmarks=2,ytickmarks=3); |
Of course the pills always add, never subtract medicine in the body
| > |
Restart in the frequency domain with correct sign
This is what the geometric series correctly sums to ... did not want to bother
to try to get MAPLE do it to above formula
| > | Y2:=1/s/(1-exp(-s)); y2:=invlaplace(Y2,s,t); |
Just for illustration, we make MAPLE expand the periodic delays into a series
| > | Y2=subs(exp(-s)=x,Y2); series(subs(exp(-s)=x,Y2),x=0,12); Y2=simplify(subs(x=exp(-s),series(subs(exp(-s)=x,Y2),x=0,7))); |
| > | display([ plot(y2,t=0..12,-2..12,thickness=3,discont=true), plot(y2,t=0..12,-2..12,thickness=1) ],xtickmarks=2,ytickmarks=3); |
This is the correct picture for every day adding another dose, none ever metabolized/excreted
| > |
Now add some decay (metabolization / excretion)
| > | Y3:=1/(s+1)/(1-exp(-s)); y3:=invlaplace(Y3,s,t); |
| > | Y3=subs(exp(-s)=x,Y3); series(subs(exp(-s)=x,Y3),x=0,8); Y3a:=convert( simplify(subs(x=exp(-s),series(subs(exp(-s)=x,Y3),x=0,11))), polynom); |
| > | y3a:=invlaplace(Y3a,s,t); |
| > | display([ plot(y3a,t=0..10,-2..5,thickness=3,discont=true), plot(y3a,t=0..10,-2..5,thickness=1) ],xtickmarks=2,ytickmarks=3); |
| > |
A slight improvement, utilize series, add parameters
Metabolization rate beta, period between taking pills, and amounts taken each time.
| > | beta:=-1/5; p:=1; a:=1; |
| > | a:='a'; p:='p'; beta:='beta'; |
| > | Y40:=a/(s-beta)*sum(exp(-'k'*p*s),'k'=1..infinity); |
Showing the first few terms for illustration
| > | Y4a:=a/(s-beta)*sum(exp(-'k'*p*s),'k'=1..7); Y4:=a/(s-beta)*sum(exp(-'k'*p*s),'k'=1..25): |
| > | y4a:=invlaplace(Y4a,s,t); y4:=invlaplace(Y4,s,t): |
My MAPLE does not like these many terms -- thus let us define the solution by hand.
| > | y4:=a*sum(Heaviside(t-'k'*p)*exp(beta*(t-'k'*p)),k=1..7); check=y4-y4a; |
OK, then let us contionue this for a long time....
| > | y4:=a*sum(Heaviside(t-'k'*p)*exp(beta*(t-'k'*p)),k=1..100): |
| > | y41:=subs(beta=-1/5,p=1,a=1,y4): |
| > | display([ plot(y41,t=0..10,thickness=3,discont=true), plot(y41,t=0..10,thickness=1) ],view=-1..12,xtickmarks=2,ytickmarks=3, title=`One pill daily. How high will it go.`, titlefont=[TIMES,BOLD,14]); |
| > | display([ plot(y41,t=0..20,thickness=3,discont=true), plot(y41,t=0..20,thickness=1) ],view=-1..12,xtickmarks=2,ytickmarks=3, title=`One pill every day. Metabolization rate 1/5.`, titlefont=[TIMES,BOLD,14]); |
| > | y42:=subs(beta=-1/5,p=2,a=2,y4): |
| > | display([ plot(y41,t=0..20,thickness=3,discont=true), plot(y41,t=0..20,thickness=1), plot(y42,t=0..20,thickness=3,color=blue,discont=true), plot(y42,t=0..20,thickness=1,color=blue) ],view=-1..12,xtickmarks=2,ytickmarks=3, title=`Two pills every other day. Metabolization rate 1/5.`, titlefont=[TIMES,BOLD,14]); |
| > | y43:=subs(beta=-1/5,p=1,a=2,y4): |
| > | display([ plot([y41,y43],t=0..40,thickness=3,color=[red,blue], discont=true,numpoints=600), plot([5,10,y41,y43],t=0..40,thickness=1,color=[black,black,red,blue]) ],view=-1..12,xtickmarks=2,ytickmarks=3, title=`Double daily dosage -- new level? Metabolization rate 1/5.`, titlefont=[TIMES,BOLD,14]); |
| > |
Steady state analysis
A quasi steady-state is characterized by the amount that is metabolized in one time
period is equal to the new dose added. This means that the quasi-steady state ys
must satisfy the following condition:
| > | sseq:=ys-ys*exp(-beta*p)=a: sseq; |
| > | yssol:=ys=solve(sseq,ys): yssol; |
In our case we considered thefixed metabolization rate
| > | mrate:=beta=1/5: mrate; |
and it is clear that the quasi steady state depends linearly on the dosage,
i.e. we should cosider the ratio
| > | ssp:=subs(mrate,yssol/a): ssp; |
| > | display([ plot([rhs(ssp),rhs(ssp)-1],p=1/5..3,color=[red,blue]), seq(plot([[T,0],[T,5/T],[0,5/T]],0..T,color=gray), T=[1/2,1,2,3]) ],view=[0..3,0..30]); |
| > |
| > |