| > | restart; |
Undetermined coefficients
About this worksheet
Author and Date
Matthias Kawski
Arizona State University
kawski@asu.edu
http://math.asu.edu/~kawki
Original version: July 2005. MAPLE release 8
| > |
Content, Purpose and Use
This worksheet develops a hands-on approach to the method of undetermined
coefficients to solve inhomogeneous costant coefficient linear differential equations
whose right hand sides are combinations of polynomial, sinusoids, and exponential
functions.
Except for some fancier commands to use MAPLE to extract coefficients of "like
terms" and for some display purposes an attempt is made to keep the MAPLE
commands simple and accessible to relative novices.
The main idea is invite to some "trial-and-error" approach, lots of experimentation.
of course, the main objective in the background is to develop the thinking in terms
of differential operators (as opposed to differential equations), encouraging the
thinking in terms of inputs and outputs. This should in particular strengthen the
understanding of the role of linearity in this method amd setting.
Updates and log of modifications.
None yet.
| > |
From a naive trial and error approach to linear algebra
Introduction
| > |
Define a differential operator
Define a linear differential operator -- here with constant coefficients.
Note that for this to be useful, one needs to substitute an expression dependingt on t for the
formal parameter u.
| > | L:=u->diff(u,t,t)+4*diff(u,t)+3*u; |
Note that MAPLE does not accept the formal parameter IN THE DEFINITION of this
procedure to be called u(t) -- however, when using the procedure, it should be called using
either an explicit formula depending on t, or using y(t).
| > | badL:=u(t)->diff(u(t),t,t)+4*diff(u(t),t)+3*u(t); |
Error, symbol or symbol::type expected in parameter list
A few brief tries
| > | L(y(t)); |
| > | L(exp(t)); |
| > | L(exp(r*t)); |
| > |
The problem: solve an inhomogeneous differential equation
The problem is to find the general solution of the inhomgeneous linear differential equation
| > | IDE:=L(y(t))=g(t): IDE; |
As we saw earlier, the general solution of this inhomogeneous DE is the sum of the
general solution of associated the homogeneous DE and any one solution of the
inhomogeneous DE.
| > | HDE:=L(y(t))=0: HDE; |
| > | homsol:=dsolve(HDE,y(t)): homsol; |
The problem thus is reduced to finding just one solution of the inhomogeneosu DE.
The method of undetermined coefficients works particulalry well with constant coefficient
linear differentail equations whose right side is a linear combination of (products of)
exponentials, sines and cosines, and polynomials.
| > |
The first example: linear combination of exponentials
Let us consider a simple example of a right hand side:
| > | exa1:=L(y(t))=3*exp(-2*t)-5*exp(-4*t): exa1; |
Start w/ trial and error, trying different functions which L may map to terms similar
to those on the right hand side:
| > | L(exp(-2*t)); |
| > | L(-3*exp(-2*t)); |
| > | L(exp(-4*t)); |
| > | L(-5/3*exp(-4*t)); |
| > | got_it:=-3*exp(-2*t)-5/3*exp(-4*t); L(got_it); |
Simple trial and error, and taking advantage of the linearity does the job.
A little more formal approach is to start with "UNDETERMINED COEFFICIENTS"
and equate the result to the right hand side of the differential equation
| > | L(A*exp(-2*t)+B*exp(-4*t))=rhs(exa1); |
In this case it is immediate to read of the coefficients which yield a solution. The general
solution then is
| > | sol1:=y(t)=rhs(homsol)+got_it: sol1; |
check it!
| > | L(rhs(sol1))-rhs(exa1);; |
| > |
The second example: polynomial right hand side
| > | exa2:=L(y(t))=15*t^4-7*t^2: exa2; |
Start w/ trial and error, trying different functions which L may map to terms similar
to those on the right hand side:
| > | L(t^4); |
| > | L(5*t^4); |
| > | L(t^3); |
| > | L(5*t^4-80/3*t^3); |
| > | L(t^2); |
| > | L(5*t^4-80/3*t^3+253/3*t^2); |
| > | L(t); |
| > | L(5*t^4-80/3*t^3+253/3*t^2-1544/9*t); |
| > | L(1); |
| > | got_it:=5*t^4-80/3*t^3+253/3*t^2-1544/9*t+4658/27; L(got_it); |
| > |
This step by step procedure should be enjoyable ... but it easy to again make this into a one-step
linear algebra problem.... (but its solution basically involves exactly the same amount of work as
above recursive procedure).
| > | try_t4:=A*t^4+B*t^3+C*t^2+D*t+E: L(try_t4)=rhs(exa2); |
For polynomials it is easy to make MAPLE colelct terms and equate coefficients to zero ... but many
novice users may prefer to read of the equati0on by hand, and re-eneter the systems to be solved
manually.
The following tries to use MAPLE to extract these equations:
| > | poleq:=collect(L(A*t^4+B*t^3+C*t^2+D*t+E)-rhs(exa2),t)=0: poleq; |
| > | algsys:={seq(coeff(lhs(poleq),t^k)=0,k=1..4),subs(t=0,poleq)}: for display purposes only: |
| > | array(map(q->[q],convert(algsys,list))); |
| > | algsol:=solve(algsys,{A,B,C,D,E}): algsol; |
| > | yp(t):=subs(algsol,try_t4); |
In this case it is immediate to read of the coefficients which yield a solution. The general
solution then is
| > | sol2:=y(t)=rhs(homsol)+yp(t): sol2; |
check it!
| > | L(rhs(sol2))-rhs(exa2);; |
| > |
The third example: sinusoids
Very typical for applications are (much longer) expressions of the following form
| > | f9:=1*sin(1*t)+1/3*sin(3*t)+1/5*sin(5*t)+1/7*sin(7*t)+1/9*sin(9*t): exa3:=L(y(t))=f9: exa3; |
These arise typically as Fourier expansions of naturally occurring "signals" -- we may get a little
more of this later. Just to get some idea look at the graph of this "9-th order Fourier approximation"
of a rectangular wave (just like an on-off digital signal, think digital TV or CD, or DVD, ...).
| > | plot(f9,t=-5..20,-3..3,numpoints=500); |
You can imagine what will happen if we take 100 more terms.... (overlaid in blue)
| > | plot([sum(1/(2*k-1)*sin((2*k-1)*t),k=1..50),f9],t=-5..20, -3..3,color=[blue,red],thickness=[2,1],numpoints=500); |
After all the previous work, we expect that a promising Ansatz should contain at leats a linear
combination of the terms of right hand side -- but for this class, in this exploration let us just look
at the first five terms....
| > | L(b[1]*sin(1*t)+b[3]*sin(3*t)+b[5]*sin(5*t)+b[7]*sin(7*t)+b[9]*sin(9*t)); |
Not a real big surpise, the output also includes many cosine terms. Thus let us improve our
Ansatz to:
| > | try3:=a[1]*cos(1*t)+a[3]*cos(3*t)+a[5]*cos(5*t)+a[7]*cos(7*t)+a[9]*cos(9*t)+ b[1]*sin(1*t)+b[3]*sin(3*t)+b[5]*sin(5*t)+b[7]*sin(7*t)+b[9]*sin(9*t); |
Evaluating L on this input and equating it to the given right hand side yields
| > | L(try3)=f9; |
or
| > | trig_eq:=L(try3)-f9=0: trig_eq; |
One may think that it is easy to just collect "like-terms" and equate coefficients to zero -- but it seems
to require more advanced thinking methods to do this nicely.
The novice user may prefer to do this step BY HAND, and then MANUALLY re-enter the system
of simultaneous linear equations to be solved.
But the author of this worksheet feels compelled to find some way to get these equations directly...
using brute-force computation of Fourier coefficients:
| > | algsys:={ seq(simplify(1/Pi*int(lhs(trig_eq)*sin((2*k-1)*t),t=0..2*Pi))=0,k=1..5), seq(simplify(1/Pi*int(lhs(trig_eq)*cos((2*k-1)*t),t=0..2*Pi))=0,k=1..5)}; |
For display purposes only -- we get a system of 10 linear equations in 10 unknowns, which really
is decoupled into five systems of two simultaneous equations in two unknowns each.
Linearity at play again!!!! we could have looked at one sinusoid at a time, and then added all the
solutions together.
| > | array(map(q->[q],convert(algsys,list))); |
| > | myvars:={seq(a[2*k-1],k=1..5),seq(b[2*k-1],k=1..5)}; |
| > | algsol:=solve(algsys,myvars): op(algsol); |
This yields the particular solution
| > | yp:=subs(algsol,try3); |
check it:
| > | L(yp); |
| > | sol3:=y(t)=rhs(homsol)+yp: sol3; |
check it!
| > | L(rhs(sol3))-rhs(exa3); |
| > |
The fourth example: terms in the kernel of L
It becomes a little more involved when the right hand side of the inhongeneous differential
equaiton contains terms that coincide with solutions of the associated homgeneous differential
equation:
| > | g4:=3*exp(-3*t)-5*t^2*exp(-t): exa4:=L(y(t))=g4: exa4; |
Start w/ trial and error, trying different functions which L may map to terms similar
to those on the right hand side -- the first experiments:
| > | L(exp(-3*t)); |
| > | L(-t^2*exp(-t)); |
| > | L(t*exp(-t)); |
| > | L(exp(-t)); |
By taking linear combinations of terms of the above form it appears impossible to get match the
right hand side:
| > | simplify(L((A*t^2+B*t+C)*exp(-3*t)+D*exp(-t)))=g4; |
It should not come as a big surprise that a successful Ansatz also includes higher order
powers of t multiplying these functions. A complete theoretical explanation is found under
then name of "annihilators" (-- the idea is that these right hand sides are themselves solutions
of linear constant coefficent hmogeneous differentail equations) -- for our purposes it suffices
to take an open-minded trial-and-error approach:
| > | try4:=(A*t^3+B*t^2+C*t)*exp(-t)+(D*t)*exp(-3*t); |
which leads to the equation
| > | eq4:=L(try4)-g4=0: eq4; |
Again, many may prefer to manually extract the coefficients that are to be equated to zero -- here
a brute force effort to use MAPLE to extraxt these.
| > | eq0:=coeff(collect(lhs(eq4),exp(-t)),exp(-t))=0: eq0; eq1:=coeff(collect(lhs(eq4),exp(-3*t)),exp(-3*t))=0: eq1; |
| > | pre4:=collect(eq0,t): pre4; |
| > | eqs:=seq(coeff(lhs(pre4),t,k)=0,k=1..2),subs(t=0,pre4): eqs; |
For display purposes only -- we get a system of 4 linear equations in 4 unknowns
| > | array(map(q->[q],[eq1,eqs])); |
| > | algsol4:=solve({eq1,eqs},{A,B,C,D}): algsol4;; |
This yields the particular solution
| > | yp:=subs(algsol4,try4); |
check it:
| > | simplify(L(yp)); |
| > | sol4:=y(t)=rhs(homsol)+yp: sol4; |
check it!
| > | simplify(L(rhs(sol4))-rhs(exa4)); |
| > |
| > |
Exercise 1 Products of exponentials, sinusoids, and polynomials
| > | ex1:=L(y(t))=3*t^3*exp(-2*t)*sin(t)-5*t^2*exp(-t): ex1; |
Getting started:
| > | L(t^3*exp(-2*t)*sin(t)); |
What other terms do you think you should include in your Ansatz....?
| > |
Exercise 2: Higher order differential equations
A crazy effort to create a linear differential operator whose characteristic polynomial
as designated roots ... a more advanced way would use inverse Laplace transforms. But
in any case the following seems to wok -- cook-up your own polynomial, and auto-
matically get a matching differential operator
| > | cookup:=expand((r^2+2*r+2)^2*(r+1)^2); |
| > | solve(cookup=0,r); |
| > | exps:=map(q->diff(q,r)/q*r,convert(cookup,list)); cofs:=map(q->subs(r=1,q),convert(cookup,list)); |
| > | L:=u->convert(zip((a,b)->a*'diff'(u,seq(t,i=1..b)),cofs[1..-2],exps[1..-2]),`+`)+cofs[-1]*u: L(y(t)); |
| > | g2:=(3+5*t)*exp(-t)*sin(t)+t^2*exp(-t): ex2:=L(y(t))=g2: ex2; |
Can you get the right Ansatz for the method of undetermined coefficients to succeed?
| > | eval(L((A+B*t)*exp(-t)*sin(t)))=g2; |
What other terms do you think you should include in your Ansatz....?
| > |
| > |
| > |
If all fails, you know that dsolve will give the answer in one step:
| > | dsolve(ex2,y(t)); |
| > |
| > |
| > |