kill(all)$

maxima : casino  ( Why play or not: random walk),version 1.0,part 1
peter.vlasschaert@gmail.com, 02/02/2020

see :youtube :https://www.youtube.com/watch?v=9FVlkg2bLlI
                         =>   " Lecture 25 Random Walks "

load packages 
============

load(lrats)$
load(solve_rec)$ /*use solving Difference equations */

simple example : ' Difference Equation'
==============================
=> discrete formulation 

1e)  Mathematical model.
-----------------------------------

p1:a[n+1] = k*a[n];

2e)  solve : Mathematical model
---------------------------------------------

p1a:solve_rec(p1,a[n]);

3e) unknown , ' %k1 ' ?
--------------------------------
?  How to find : called  : ' Condition '
time depent problem : '(I)nitial (C)ondition' = IC

p1b1 :a[0] = 1;

use : 'p1a'

p1b2:subst([n=0],p1a);

p1b3:rhs(p1b2) = lhs(p1b2);

4e) solution for the model  '1e'
-----------------------------------------
use : 3e

p1c:lhs(p1a) = subst([p1b3], rhs(p1a));

see : also: ' advanced programming'
https://petervlaschemeng.weebly.com/modelling--advanced-69.html
 =>  71e) Relation between two connected Lakes ( pollution problem) 

rem : 1e order Difference, only one condition to solve (%k1).

from : elementary mathematics
y = a1*x+a2 , probem above
(y=0) : "a1*x+a2 = 0"

see :  'p1'

Nomenclatuur :  x  => a[n+1]
                            a1 =>1
                            a2 => -k*a[n]

use: 'p1'
=======

p1d:lhs(p1) - rhs(p1) = 0;

characteristics :polynoom: Difference equation 
====================================
reason :k^n, root of p1e1

p1e:[a[n+1] = r ,a[n] = 1];

use : 'p1d'

p1e1 :subst(p1e,p1d);
p1e2:solve (p1e1,r)[1];

root :characteristics polynoom ( = first oder)
=================================

p1e3:rhs(p1e2);

rem : a[n+1] = r ,a[n] = 1.

rem :
====
characteristics polynoom ( = first       oder),one root.
a[n+1]+a0*a[n] = 0
-----------------------------------------------------------------------
=>      r +a0  = 0 ,example ( a0 = -k)  => r = k
characteristics polynoom ( = second oder),two roots.
a[n+2]+a1*a[n+1] +a0*a[n+0] =0
a[n+2]+a1*a[n+1] +a0*a[n]      =0
-----------------------------------------------------------------------
=>     r^2+a1*r+a0 = 0 ' quadratic equation variable "r" '

rem :a2*x^2+a1*x+a0 = 0,elementary mathematics.