kill(all)$

maxima : casino  ( Why play or not: random walk),version 1.0,part 2
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 */

general :second order : "Difference equation"
===================================

1e)  Mathematical Model (second order).
---------------------------------------------------------

p1:a2*a[n+2]+a1*a[n+1]+a0*a[n] = 0;

2e) Solve 1e)
-------------------

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

p1b:lhs(p1a)=combine(rhs(p1a));

3e) find %k1, %k2
---------------------------

solution : will be used : Casino problem.

4e) find roots  : second order : "Difference equation"
------------------------------------------------------------------------
 => roots  Characteristic polynoom ,use 'p1'

p1d1:[a[n+2]=r^2,a[n+1]=r,a[n]=1];
p1d2:subst(p1d1,p1);

roots: ?  ' two roots'
----------

p1d3:solve(p1d2,r);

p1d3a:p1d3[1];
p1d3b:p1d3[2];

p1d4a:subst([r=r1],p1d3a);
p1d4a1:rhs(p1d4a) = lhs(p1d4a);
p1d4b:subst([r=r2],p1d3b);
p1d4b1:rhs(p1d4b) = lhs(p1d4b);

general : r1≠ r2
============
not use : r1 = r2

p1d5a:(p1d4a1)^n;
p1d5b:(p1d4b1)^n;

solution : a[n]: f(%k1,%k2,r1,r2)
=========================
use :p1a

p1e6:[p1d5a,p1d5b];
p1e6a:lratsubst(p1e6,p1a);

rem : use packages : load(lrats)

rem : %k1, %k2, through : Conditions 
================================
=>  IC : Intial Condition ( time dependent)
=>  BC: Boundary Condition
=>  General Condition
================================