Novocaine Example

> restart;

Initial Condition: [Maple Math] .
Recursion Formula:
[Maple Math] .
Define the function
[Maple Math] directly from the difference equation.
This is called a
recursive definition.

> u := proc(n) if n<=0 then 500 else u(n-1) - 0.2*u(n-1) fi end;

[Maple Math]


We can now evaluate
[Maple Math] for various values on [Maple Math] simply by entering [Maple Math] .

> u(0); u(1); u(2); u(3);

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]


We can generate a list of points for
[Maple Math] taking on the values from 0 to 25 by entering .

> [seq([n,u(n)], n=0..25)];

[Maple Math]
[Maple Math]
[Maple Math]


We can avoid printing out the entire list, but save it for future use by assigning the list to a variable and by terminating the command with a colon.

> pts := [seq([n,u(n)], n=0..25)]:


We can plot the list of points using the plot command.

> plot(pts,style=point);

[Maple Plot]


Upon reflection, we see that we can write
[Maple Math] in a closed form as [Maple Math] .
What happens if we simply replace
[Maple Math] by [Maple Math] and let [Maple Math] take on arbitrary values?

> u := proc(t) 500*(0.8)^t end;
plot(u(t),t=0..25);

[Maple Math]

[Maple Plot]


We can display both plots by giving each one a name, supressing any output,
and displaying them with the plots[display] command.

> P1 := plot(pts,style=point):
P2 := plot(u(t),t=0..25):
plots[display]({P1,P2});

[Maple Plot]