kill(all)$

matrix : power of a matrix ( = Fibonacci sequence).,part 2
peter.vlasschaert@gmail.com, 03/02/2020

load packages :
===========

load(lrats)$
load(solve_rec)$
load(diag)$

see : CASINO ,website.

Fibonacci sequence (= Difference equation)
=================================

Mathematical Model : Fibonacci,n =integer
F(0) =0                                             (1)   BC
F(1) =1                                             (2)   BC
F(n) = F(n-1)+F(n-2),  n=2,3,.....       ( 3)   Difference equation

How to solve (3)
--------------------

p1a:F(0) = 0;
p1b:F(1) = 1;
p1:F(n) =F(n-1) +F(n-2);

how to construct  : matrix from (1),(2),(3)
==============================

p2a:p1;
p2b:F(n-1) = F(n-1);

coef(matrix)
----------------

p3a:rhs(p2a);
p3b:rhs(p2b);
p3c:[part(rhs(p2a),1),part(rhs(p2a),2)];
p3d:coefmatrix([p3a,p3b],p3c);

rem : coef(matrix),p3d

rhs : matrix
========

p3e:p3d.'transpose(p3c);

lhs : matrix
========

p3f:transpose([lhs(p2a),lhs(p2b)]);

  => lhs = rhs
============

p3g:p3f=p3e;

p3g1 :part(rhs(p3g),2);

p3g2:subst([n=2],p3g1);

equation : p3g
===========
n=2,3,4,....

p4:subst([n=2],p3g);

p4a:subst([n=3],p3g);

p4b:subst([n=4],p3g);

transpose 'p4,p4a,p4b'

p5:transpose(lhs(p4)) = transpose(rhs(p4));

p5a:transpose(lhs(p4a)) = transpose(rhs(p4a));

p5b:transpose(lhs(p4b)) = transpose(rhs(p4b));

F(4)  three times 'p3d'
================
{p4,p4a,p4b}

p6:p3f=p3d^^(n-1).p3g2;

p6a:subst([n=4,p1a,p1b],p6);

p6b:ev(p6a,nouns);

construct :list
==========

p7a:makelist(subst([n=i],lhs(p1)),i,2,4);

p7b:makelist(subst([n=i],rhs(p1)),i,2,4);

p7c:map("=",p7a,p7b);

p7d:subst([p1a,p1b],p7c);

p7d1:subst([p7d[1]],p7d);

p7d2:subst([p7d1[2]],p7d1);

rem : symbolic

f(x):=x^(n-1);
p8:mat_function(f,p3d);

for n=4

p8a:subst([n=4],p8),float;

p8b:round(p8a);

check : p8b ? p6a
=============

p9:is(p8b=part(rhs(p6a),1));