Fibonacci Triangle Matrices
12-22-2018, 06:33 PM
Post: #7
 compsystems Senior Member Posts: 1,162 Joined: Dec 2013
RE: Fibonacci Triangle Matrices
The FIBMAT() current code only works in numerical mode (HOME), but it must be taken into account that if the index variable that can only be changed in CAS mode, is in 'index': = 0, it affects the output of the function

test
Steps:
1: Press [CAS]
2: index:=0 [↵] returns "[] index start 0"
3: then Press [HOME]
4: FIBMAT(7) [↵]
[[1,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0],[1,1,2,0,0,0,0,0],[1,1,2,3,0,0,0,0],[1,1,2,3,5,0,0,0],[1,1,2,3,5,8,0,0],[1,1,2,3,5,8,13,0],[1,1,2,3,5,8,13,21]]

5: Press [CAS]
6: index:=1 [↵] returns "[] index start 1"
7: then Press [HOME]
8: FIBMAT(7) [↵]
[[1,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0],[2,1,2,0,0,0,0,0],[3,2,2,3,0,0,0,0],[5,3,4,3,5,0,0,0],[8,5,6,6,5,8,0,0],[13,8,10,9,10,8,13,0],[21,13,16,15,15,16,13,21]]

I try to change the value of the internal variable within the code but it fails.
CAS.index:=1;

PHP Code:
EXPORT FIBMAT(n)BEGIN// Fibonacci "triangle" in// matrix form// 2018-12-17 EWSLOCAL M1,k;CAS.index:=1;M1:=MAKEMAT(0,n+1,n+1);M1(1,1):=1;M1(2,1):=1;M1(2,2):=1;FOR k FROM 3 TO n+1 DOM1(k):=row(M1,k-1)+row(M1,k-2);M1(k,k):=M1(k-1,k-1)+M1(k-2,k-2);END;RETURN M1;END;
 « Next Oldest | Next Newest »

 Messages In This Thread Fibonacci Triangle Matrices - Eddie W. Shore - 12-20-2018, 02:29 PM RE: Fibonacci Triangle Matrices - John Keith - 12-21-2018, 04:01 PM RE: Fibonacci Triangle Matrices - Eddie W. Shore - 12-22-2018, 03:00 AM RE: Fibonacci Triangle Matrices - DA74254 - 12-22-2018, 07:07 AM RE: Fibonacci Triangle Matrices - Eric Rechlin - 12-22-2018, 03:01 PM RE: Fibonacci Triangle Matrices - Albert Chan - 12-22-2018, 05:31 PM RE: Fibonacci Triangle Matrices - compsystems - 12-22-2018 06:33 PM RE: Fibonacci Triangle Matrices - Eddie W. Shore - 12-23-2018, 09:33 PM RE: Fibonacci Triangle Matrices - pier4r - 12-23-2018, 09:59 PM

User(s) browsing this thread: 1 Guest(s)