Introductory Differential Equations using Sage - William Stein
Introductory Differential Equations using Sage - William Stein
Introductory Differential Equations using Sage - William Stein
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
1.4. FIRST ORDER ODES - SEPARABLE AND LINEAR CASES 27<br />
Now note that ±e C 1<br />
can be any nonzero number, but in fact y = 0 is also a solution to the<br />
ODE so we can write the general solution as y = Ce kt for an arbitrary constant C. If k is<br />
positive, solutions will grow in magnitude exponentially, and if k is negative solutions will<br />
decay to 0 exponentially.<br />
Perhaps the most famous use of this type of ODE is in carbon dating.<br />
Example 1.4.2. Carbon-14 has a half-life of about 5730 years, meaning that after that<br />
time one-half of a given amount will radioactively decay (into stable nitrogen-14). Prior to<br />
the nuclear tests of the 1950s, which raised the level of C-14 in the atmosphere, the ratio<br />
of C-14 to C-12 in the air, plants, and animals was 10 −15 . If this ratio is measured in an<br />
archeological sample of bone and found to be 3.6 · 10 −17 , how old is the sample?<br />
Solution: Since a constant fraction of C-14 decays per unit time, the amount of C-14<br />
satisfies a differential equation y ′ = ky with solution y = Ce kt . Since<br />
y(5730) = Ce k5730 = y(0)/2 = C/2,<br />
we can compute k = − log(2)/5730 ≈ 1.21 · 10 −5 .<br />
We know that<br />
y(0)/y(t i ) = 10−17<br />
10 −15 = 10−2 = C<br />
Ce kt i = 1<br />
e kt i ,<br />
where t i is the time of death of whatever the sample is from. So t i =<br />
before the present.<br />
Here is a non-linear example.<br />
Example 1.4.3. Consider<br />
Here is one way to solve this <strong>using</strong> <strong>Sage</strong>:<br />
y ′ = (y − 1)(y + 1), y(0) = 1/2.<br />
<strong>Sage</strong><br />
log 102<br />
k<br />
≈ −38069 years<br />
sage: t = var(’t’)<br />
sage: x = function(’x’, t)<br />
sage: de = lambda y: diff(y,t) == yˆ2 - 1<br />
sage: soln = desolve(de(x),[x,t]); soln<br />
1/2*log(x(t) - 1) - 1/2*log(x(t) + 1) == c + t<br />
sage: # needs an abs. value ...<br />
sage: c,xt = var("c,xt")<br />
sage: solnxt = (1/2)*log(abs(xt - 1)) - (1/2)*log(abs(xt + 1))<br />
== c + t<br />
sage: solve(solnxt.subs(t=0, xt=1/2),c)<br />
[c == -1/2*log(3/2) - 1/2*log(2)]<br />
sage: c0 = solve(solnxt.subs(t=0, xt=1/2),c)[0].rhs(); c0<br />
-1/2*log(3/2) - 1/2*log(2)<br />
sage: soln0 = solnxt.subs(c=c0); soln0<br />
1/2*log(abs(xt - 1)) - 1/2*log(abs(xt + 1))