Post Reply 
Fibonacci Triangle Matrices
12-22-2018, 06:33 PM
Post: #7
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]]
[Image: FIBMAT%2Btriangle%2BHP%2BPrime.png]

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 EWS
LOCAL 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+DO
M1(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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Fibonacci Triangle Matrices - DA74254 - 12-22-2018, 07:07 AM
RE: Fibonacci Triangle Matrices - compsystems - 12-22-2018 06:33 PM
RE: Fibonacci Triangle Matrices - pier4r - 12-23-2018, 09:59 PM



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