Using the TI89 in Differential Equations

Bugs or improvements? lfriesen@butlercc.edu**Euler's Method:**

Bugs or improvements? lfriesen@butlercc.edu

**TI83 notes:**

-> is the STO-> button

The commands are all in 2nd CATALOG; = is at the end of the CATALOG:

Note : Key words like ClrHome, Input etc. must be entered from the catalog, not typed in!

Xmin,Xmax,Ymin,Ymax, Str0 are in VARS WINDOW

For letters and " use the ALPHA key.

Programs are entered using PRGM NEW

ClrHome

ClrAllLists

Input "DY/DX=",Str0

Input "X0=",X

Input "Y0=",Y

Input "STEP SIZE=",H

Input "FINAL X=",Z

(Z-X)/H -> N

For(I,1,N)

expr(Str0) -> F

Y+H*F -> Y

X+H -> X

Output(7,1," ") *Put several spaces between the quotes to erase old values. *

Output(8,1," ") *Put several spaces between the quotes to erase old values.*

Output(7,1,X)

Output(8,1,Y)

X -> L1(I):Y -> L2(I)

Pause

End

The answers are stored in lists 1 and 2. To see a plot of the solution:

2nd STATPLOT PlotsOn

Set the proper WINDOW

GRAPH.

**Euler slope field plotter:**

ClrHome

ClrDraw

Input "DY/DX=",Str0

Input "Xmin=",Xmin

Input "Xmax=",Xmax

Input "Ymin=",Ymin

Input "Ymax=",Ymax

(Xmax-Xmin)/10 -> W

(Ymax-Ymin)/10 -> V

DispGraph

For(M,Xmin,Xmax,W)

For(N,Ymin,Ymax,V)

M -> X

N -> Y

expr(Str0) -> Z

M-W -> P:N-W*Z -> Q:M+W -> R:N+W*Z -> S

2*((P-R)^2+(Q-S)^2))^ .5 -> K

Line(M-W/K,N-W*Z/K,M+W/K,N+W*Z/K)

End

End

Pause

ClrHome

If you get a divide by 0 error with a fraction, try changing your range values to odd decimals, e.g. -3.07

**Runge Kutta method:** variables Q,R,S,T are k1,k2,k3,k4

ClrHome

ClrAllLists

Input "DY/DX=",Str0

Input "X0=",A

Input "Y0=",B

Input "STEP SIZE=",H

Input "FINAL X=",Z

(Z-A)/H -> N

A -> X:B -> Y

For(I,1,N)

X -> V:Y -> W

expr(Str0) -> Q

V+H/2 -> X

W+H*Q/2 -> Y

expr(Str0) -> R

W+H*R/2 -> Y

expr(Str0) -> S

V+H -> X

W+H*S -> Y

expr(Str0) -> T

(Q+2*R+2*S+T)/6 -> K

W+H*K -> Y

Output(7,1," ") *Put several spaces between the quotes to erase old values. *

Output(8,1," ") *Put several spaces between the quotes to erase old values. *

Output(7,1,X)

Output(8,1,Y)

X -> L1(I):Y -> L2(I)

Pause

End

ClrHome

The answers are stored in lists 1 and 2. To see a plot of the solution:

2nd STATPLOT PlotsOn

Set the proper WINDOW

GRAPH.

**Runge Kutta method for 2nd order differential equations:**

ClrHome

ClrAllLists

Input "DX/DT=",Str0

Input "DY/DT=",Str1

Input "T0=",T Input "X0=",X

Input "Y0=",Y

Input "STEP SIZE=",H

Input "FINAL T=",Z

(Z-T)/H -> N

For(I,1,N+1)

X -> L1(I)

Y -> L2(I)

T -> L3(I)

X -> A

Y -> B

T -> C

expr(Str0) -> D

expr(Str1) -> E

C+H/2 -> T

A+H*D/2 -> X

B+H*E/2 -> Y

expr(Str0) -> L

expr(Str1) -> M

A+H*L/2 -> X

B+H*M/2 -> Y

expr(Str0) -> P

expr(Str1) -> Q

C+H -> T

A+H*P -> X

B+H*Q -> Y

expr(Str0) -> R

expr(Str1) -> S

(D+2*L+2*P+R)/6 -> F

(E+2*M+2*Q+S)/6 -> G

A+H*F -> X

B+H*G -> Y

End

The answers are stored in lists 1 and 2. To see the solutions, STAT | EDIT, L1 is X, L2 is Y, L3 is T.

To see a plot of the solution:

2nd STATPLOT PlotsOn

Set the proper WINDOW | GRAPH.

**Phase Plots:**

Use Program eulslope. This program will do autonomous (non-time dependent) plots only.

Since dy/dt over dx/dt = dy/dx enter y' as a numerator and x' as a denominator.

For example: If y' = 1-x^2 and x' = x-y enter dy/dx= (1-x^2)/(x-y)

If you get a divide by 0 error, try changing your range values to odd decimals, e.g. -3.07

**Graphing the unit step function:**

TI83 use the logical operations. Example: U(t-1) + 2U(t-3) - 3U(t-4) is: Y1 = (x>1) + 2(x>3) - 3(x>4)

**TI89** Many Differential Equation utilities are built in to the TI89.

**Slope Field Plot:**

Set MODE Graph DIFF EQUATIONS Y=

y1' = must be a function of y1 and t; For example if **dy/dx = x^2 + y^2 with y(0)=2**: enter** y1' = t^2 + y1^2** with** t=0** and** yi1=2**

then GRAPH

If no field comes the fields may be turned off. Hit the green diamond key and the Y= key; then the green diamond key and the **|** key; this will give you Graph Formats; go to Fields -> SLPFLD.

**Euler's Method:**

Set MODE Graph DIFF EQUATIONS

While in Y= do this: Green diamond key, then | key: Solution Method -> EULER; Fields -> FLDOFF

In **Y=** Define y1' = f( y1,t); in **WINDOW** enter your starting value and stepsize; in **TABLE** see the results in columns.

Example: **dy/dx = x + y **with** y(0)=1**: from x=0 to 2 by 0.1

**Y=**: y1' = t + y1; t0=0; yi1=1

**WINDOW:** t0=0; tmax=1; tstep=0.1

**TABLE**: gives values in columns

You should get y(.5)=1.721 and y(1)=3.1875

Note: TblSet allows you to start at any t value so you don't have to arrow a long way down the list. Use deltatbl to look at intermediate values so the list doesn't get too long. (This doesn't affect tstep.)

**GRAPH** to graph these points:

**Runge Kutta method:**

Set MODE Graph DIFF EQUATIONS

While in Y= do this: Green diamond key, then | key: Solution Method -> RK; Fields -> FLDOFF

In **Y=** Define y1' = f( y1,t); in **WINDOW** enter your starting value and stepsize; in **TABLE** see the results in columns.

Example: **dy/dx =-3x^2 y **with** y(0)=3**: from x=0 to 1by 0.25

**In the calculator:
Y=**: y1' = -3t^2 y1; t0=0; yi1=3

You should get y(.5)=2.6474 and y(1)=1.1039

Note: TblSet allows you to start at any t value so you don't have to arrow a long way down the list. Use deltatbl to look at intermediate values so the list doesn't get too long. (This doesn't affect tstep.)

**Runge Kutta method for 2nd and higher order differential equations:**

You must change the 2nd order DE to two first order equations and enter both of them.

Example: y" + 9y = sin(2x); y(0)=1; y'(0) = -1 from t = 0 to t = 3 stepsize h = 0.2

Using standard techniques convert the 2nd order DE to two 1st order DE in y1 and y2

y1' = y2 and y2' = -9y1 + sin(2x)

In the calculator:

**Y=**: y1' = y2; y2' = -9y1 + sin(2t); t0 = 0; yi1 = 1; yi2 = 0

**WINDOW**: t0 = 0; tmax = 3; tstep = 0.2

**TABLE**: gives values of t,y1,y2 in columns which are really x,y,y'

You should get y(0.2) = 0.8278 and y(1) = -0.8247

**GRAPH** to graph these points which are the solution curve y(x) and y'(x):

**Phase Plots:**

Set MODE | Graph | DIFF EQUATIONS

Y=; Green diamond key, then | key: Solution Method -> RK; Fields -> DIRFLD

Most books work in x,y, and t. The Calculator works in y1,y2 and t; Rewrite x as y1 and y as y2.

Example:** x' = 14x - 2x^2 - xy**; **y' = 16y - 2y^2 - xy**

Y= key;** y1' = 14y1 - 2y1^2 - y1*y2**; ** y2' = 16y2 - 2y2^2 - y1*y2**

Note: you must use the multiplication key between variables or the calculator thinks it is all one variable. For a typical curve set t0, yi1, and yi2 = to initial values. For example, if x(0) = 1 and y(0) = 3, then t0 = 0, yi1 = 1, and yi2 = 3.

**Graphing the unit step function** on TI89 is U(t-a) = 1/2(1+sign(x-a)) -> sign() is in the catalog.

TI83 use the logical operations. Example: U(t-1) + 2U(t-3) - 3U(t-4) is: Y1 = (x>1) + 2(x>3) - 3(x>4