Happiness Scenario

MATH 220 Linear Algebra

Here are the initial happiness values:

n=600  (* unhappy people *)
h=100  (* happy and they know it *)
r=300  (* happy without realizing*)

Let's write some equations to compute the distribution of happiness next week from the current numbers this week:

n1=0.25n+0.5h+0.1r;
h1=0.5n+0.4h+0.1r;
r1=0.25n+0.1h+0.8r;
{n1,h1,r1}

We could then simulate another week:

n2=0.25n1+0.5h1+0.1r1;
h2=0.5n1+0.4h1+0.1r1;
r2=0.25n1+0.1h1+0.8r1;
{n2,h2,r2}

There are faster and better ways to iterate this process! In this course, we will learn both Mathematica techniques and the theoretical linear algebra that will help us understand what is happening!

Using a loop to simulate many weeks

(* set the initial values *)
n=600;
h=100;
r=300;
Print[{n,h,r}]

(* a "Do" loop performs a repetitive process many times *)
Do[
(* compute the values for the next week *)
n1=0.25n+0.5h+0.1r;
h1=0.5n+0.4h+0.1r;
r1=0.25n+0.1h+0.8r;

(* shift the computed value to the variables n, h, and r *) 
n=n1;
h=h1;
r=r1;

(* print the results *) 
Print[{n,h,r}]

(* the next number deterimines how many times the loop will run *)
,52
]