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.1. INTRODUCTION TO DES 9<br />
Theorem 1.1.1. (Existence and uniqueness) Fix a point (t 0 ,x 0 ) in the plane. Let f(t,x)<br />
be a function of t and x for which both f(t,x) and f x (t,x) = ∂f(t,x)<br />
∂x<br />
are continuous on some<br />
rectangle<br />
a < t < b, c < x < d,<br />
in the plane. Here a,b,c,d are any numbers for which a < t 0 < b and c < x 0 < d. Then<br />
there is an h > 0 and a unique solution x = x(t) for which<br />
and x(t 0 ) = x 0 .<br />
x ′ = f(t,x), for all t ∈ (t 0 − h,t 0 + h),<br />
This is proven in §2.8 of Boyce and DiPrima [BD-intro], but we shall not prove this here<br />
(though we will return to it in more detail in §1.3 below). In most cases we shall run across,<br />
it is easier to construct the solution than to prove this general theorem.<br />
Example 1.1.6. Let us try to solve<br />
x ′ + x = 1, x(0) = 1.<br />
The solutions to the DE x ′ +x = 1 which we “guessed at” in the previous example, x(t) = 1,<br />
satisfies this IVP.<br />
Here a way of finding this solution with the aid of the computer algebra system <strong>Sage</strong>:<br />
<strong>Sage</strong><br />
sage: t = var(’t’)<br />
sage: x = function(’x’, t)<br />
sage: de = lambda y: diff(y,t) + y - 1<br />
sage: desolve(de(x),[x,t],[0,1])<br />
1<br />
(The command desolve is a DE solver in <strong>Sage</strong>.) Just as an illustration, let’s try another<br />
example. Let us try to solve<br />
x ′ + x = 1, x(0) = 2.<br />
The <strong>Sage</strong> commands are similar:<br />
<strong>Sage</strong><br />
sage: t = var(’t’)<br />
sage: x = function(’x’, t)<br />
sage: de = lambda y: diff(y,t) + y - 1<br />
sage: x0 = 2 # this is for the IC x(0) = 2<br />
sage: soln = desolve(de(x),[x,t],[0,x0])<br />
sage: solnx = lambda s: RR(soln.subs(t=s))