11.11.2014 Views

Introductory Differential Equations using Sage - William Stein

Introductory Differential Equations using Sage - William Stein

Introductory Differential Equations using Sage - William Stein

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1.2. INITIAL VALUE PROBLEMS 13<br />

<strong>Sage</strong><br />

sage: t = var(’t’)<br />

sage: c1 = var(’c1’)<br />

sage: c2 = var(’c2’)<br />

sage: de = lambda x: diff(x,t,t) + 4*diff(x,t) + 4*x<br />

sage: de(c1*exp(-2*t) + c2*t*exp(-2*t))<br />

0<br />

sage: desolve(de(x),[x,t])<br />

(k2*t + k1)*eˆ(-2*t)<br />

sage: P = plot(t*exp(-2*t),0,pi)<br />

sage: show(P)<br />

The plot is displayed in Figure 1.3.<br />

Now, to solve the IVP<br />

x ′′ + 4x ′ + 4x = 0, x(0) = 0, x ′ (0) = 1.<br />

we solve for c 1 and c 2 <strong>using</strong> the initial conditions. Plugging t = 0 into x(t) and x ′ (t), we<br />

obtain<br />

0 = x(0) = c 1 exp(0) + c 2 · 0 · exp(0) = c 1 ,<br />

1 = x ′ (0) = c 1 exp(0) + c 2 exp(0) − 2c 2 · 0 · exp(0) = c 1 + c 2 .<br />

Therefore, c 1 = 0, c 1 + c 2 = 1 and so x(t) = t exp(−2t) is the unique solution to the IVP.<br />

In Figure 1.3, you see the solution tends to 0, as t increases.<br />

Figure 1.3: Solution to IVP x ′′ + 4x ′ + 4x = 0, x(0) = 0, x ′ (0) = 1.<br />

Suppose, for the moment, that for some reason you mistakenly thought that the general<br />

solution to this DE was

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!