The Rumor Example
> restart;
In this model we consider the spread of a rumor. Our idea is that the number of people who know
the rumor at the next time step is the sum of those who know it at the present time plus a small percentage
of the product of those who know it with those who don't. The idea of this product is that it will measure
the number of possible interactions betweeen those who know the rumor and those who don't.
> u := proc(n) if n<=0 then b else u(n-1) + a*u(n-1)*(Pop - u(n-1)) fi end;
Let's assume that the population,
, has been normalized to 1, and the proportionality constant,
,
is 0.05.
>
a := 0.05;
Pop := 1;
Now set the size of the group who initially knows the rumor to 1% of the total population.
>
b := 0.01;
pts := [seq([n,u(n)],n=0..10)];
plot(pts, style=point);
This calculation takes quite a bit of time, and the rumor has not even spread to 2% of the population.
The problem is that our recursive definition causes this function
u(n)
to be evaluated many many
times. We can fix this by telling Maple to
remember
the values that it has alreaady calculated.
Simply add the Maple statement
option remember;
to the function definition.
>
u := proc(n) option remember; if n<=0 then b
else u(n-1) + a*u(n-1)*(Pop - u(n-1)) fi end;
>
a := 0.05;
Pop := 1;
>
b := 0.01;
u(100);
pts := [seq([n,u(n)],n=0..200)]:
plot(pts, style=point);
When we evaluate
u(n)
with new values of its parameters we must first tell it to forget all the
values that it remebered from the calculations with the old parameters. The Maple command
is called
forget
.
>
readlib(forget);
forget(u);
b := 0.04;
u(100);
pts := [seq([n,u(n)],n=0..200)]:
plot(pts, style=point);
>
forget(u);
b := 0.07;
u(100);
pts := [seq([n,u(n)],n=0..200)]:
plot(pts, style=point);forget(u);
>
forget(u);
b := 0.1;
u(100);
pts := [seq([n,u(n)],n=0..200)]:
plot(pts, style=point);forget(u);
We can solve the recurrence formula for its rest points.
> solve(x = x + a*x*(Pop-x),x);
Can you explain what happens when
and
?