kill(all)$

peter.vlasschaert@gmail.com,18/02/2016

part : how to get the model

discrete : first-order nonhomogeous dynamical system
----------------------------------------------------
amount pollution => simplification to understand principles.

Lake Ontari:a(n)
Lake Eri   :b(n)
Lake Ontario connected with Lake Eri

system of equations :difference equations

           a(n+1)=0.87*a(n)+0.38*b(n)    '1'
           b(n+1)=0.62*b(n)              '2'

eqn1:a(n+1)=a1*a(n)+b1*b(n)$
eqn2:b(n+1)=a2*a(n)+b2*b(n)$

b(n):each year: Lake Eri 38%(0.38) 'replaced' by rain          
      

a2:0;
b2:1-0.38;

eqn1:a(n+1)=a1*a(n)+b1*b(n);
eqn2:b(n+1)=a2*a(n)+b2*b(n);

a(n);each year :Lake Ontario
38%(0.38) Lake Eri flows into Lake Ontario
13%(.13 ) Lake Ontarion 'replaced' from water from Lake Eri

rem:replaced : 1-..

a1:1-0.13;
b1:0.38;

eqn1:a(n+1)=a1*a(n)+b1*b(n);
eqn2:b(n+1)=a2*a(n)+b2*b(n);

solve: problem from the connected lakes(Eri,Ontario)

first: not connected  :eqn2 : n=0,1,2,3,...
b(0)=1 unit of pollution

v0:b(0)=1;
v1:b(1)=0.62*b(0);
v2:b(2)=0.62*b(1);

w1:ev(v2,v1);

d1:part(coeff(w1,b(0)),2);

d2:d1-(b2)^kk=0;
find_root(d2,kk,0,100);

b(k)=(0.62)^k*b(0)=(0.62)^k*1 

eqn11:ev(eqn1,b(n)=(0.62)^n*b(0));
eqn111:ev(eqn11,b(0)=1);

theory: Nonhomogeneneous dynamical systems
        a(n+1)=r*a(n)+b*s^n
suppose  : r<>s
solution : a(k)=c1*(r)^k+c2*(s)^k
           a(k)=c*(r)^k+a*s^k
           a(k)= general solution + particular solution
           ? find a
rem: r=s
     a(k)=c1*(r)^k+particular solution
     a(k)=c1*(r)^k+c2*k*(r)^k,c2=b/r
     a(k)=c1*r^k+(b/r*k)*r^k

eqt : a(n+1)=r*a(n)+b*s^n;
eqak: a(k)=c*(r)^k+a*s^k;
eqan: ev(eqak,k=n);

eqanplus1:ev(eqan,n=n+1);

eqinput:ev(eqt,eqan,eqanplus1);

eqval1:ratsimp(a*s^(n+1)+c*r^(n+1)=r*(a*s^n+c*r^n)+b*s^n);

radcan(a*s^(n+1)+c*r^(n+1)=(a*r+b)*s^n+c*r^(n+1));

d_part1:coeff(part(eqval1,1),s^(n+1))*s;
d_part2:coeff(part(eqval1,2),s^(n));
eq_particular: d_part1=d_part2;
aa:part(solve(eq_particular,a),1);

gen_eq1:ev(part(eqak,2),aa);

gen_eq:a(k)=gen_eq1;

example: from Lake Ontario and Lake Eri
         r=0.87
         s=0.62
         b=0.38
size: Lake Ontario three times the size of Lake Eri
result :three times pollution but the same initial concentration
        a(0)=a0 ,a0=3*b0=3.b(0)

gen_eq_example:ev(gen_eq,r=0.87,s=0.62,b=0.38);

because c undetermined variable,anything we like.
check initial conditions.

gen_eq_ex1:ev(gen_eq_example,c=c-part(aa,2));
gen_eq_ex2:ev(gen_eq_ex1,r=0.87,s=0.62,b=0.38);

gen_eq_init:ev(gen_eq_ex2,k=0);

gen_eq_initc:ev(gen_eq_init,a(0)=3);

c_init:part(solve(gen_eq_initc,c),1);

gen_eq_ex3:ev(gen_eq_ex2,c_init);

How long will take :Lake Eri , 10%(0.1) from present value b(0)=1
Because Lake Ontario '3' times size of Lake Eri
                               30%(0.3)        
(Lake Eri :ref)

first :unpolluted,Lake Eri ? How many years

b_unpol1:ev(b(k)=(0.62)^k*b(0),b(0)=1);

b_unpol2:ev(b_unpol1,b(k)=0.1);

find ,between 0 years and 100 years

k_year_unpol_Eri:find_root(b_unpol2,k,0,100);

second:unpolluted,Lake Ontario ? How many years
b(k) = 0.1 -> 3 times -> a(k) = .3

a_unpol1:ev(gen_eq_ex3,a(k)=.3);

find,between 0 years and 100 years

k_year_unpol_Ontario:find_root(a_unpol1,k,0,100);