Showing posts with label matrix. Show all posts
Showing posts with label matrix. Show all posts

Saturday, December 13, 2025

RPN: HP 42S, DM42, Free 42 Tones, Column Vectors, and Songs

RPN: HP 42S, DM42, Free 42 Tones, Column Vectors, and Songs



Making Music of 10 Tones


The HP 42S, and subsequently, the Free42 app, the Plus42 app, and the Swiss Micros DM42, along with the HP 41C and DM41X. Let’s focus on the HP 42S version.


Tone is followed by:


* a single-digit integer (0-9)

* a tone number called indirectly through a stack level (X, Y, Z, T) or a memory register


I asked on the MoHPC (Museum of HP Calculators) forum what scale that the 42S used for the tones. According to Thomas Okken, who programmed the Free42 app, the tones come from the A major scale, with the note A3 called from TONE 1. TONE 0 played the E3 note. Thank you, Thomas!


https://www.hpmuseum.org/forum/thread-23678-post-205315.html#pid205315


The program CTONE plays a collection of tones that is stored in a single-column matrix named MCOL. An example of a collection of tones


[ [ 1 ]

[ 3 ]

[ 5 ]

[ 1 ]

[ 3 ]

[ 5 ]

[ 7 ]

[ 7 ]

[ 7 ]

[ 7 ]

[ 1 ]

[ 3 ]

[ 5 ]

[ 1 ]

[ 3 ]

[ 5 ]

[ 7 ]

[ 8 ]

[ 9 ]

[ 7 ] ]


CTONE: plays tones of the column vector MCOL


00 { 44-Byte Prgm }

01▸LBL "CTONE"

02 INDEX "MCOL"

03 WRAP

04 RCL "MCOL"

05 DIM?

06 X<>Y

07 3

08 10↑X

09 ÷

10 +

11 STO 00

12▸LBL 00

13 RCLEL

14 TONE IND ST X

15 I+

16 ISG 00

17 GTO 00

18 RTN

19 .END.


The following program, CRVCT, creates a matrix with one column named MCOL.


CRVCT: create a vector MCOL


00 { 79-Byte Prgm }

01▸LBL "CRVCT"

02 "SIZE?"

03 PROMPT

04 STO 01

05 1

06 DIM "MCOL"

07 X<>Y

08 3

09 10↑X

10 ÷

11 +

12 STO 00

13 INDEX "MCOL"

14 WRAP

15 ALL

16▸LBL 00

17 "ROW "

18 RCL 00

19 IP

20 ARCL ST X

21 ├"?"

22 PROMPT

23 STOEL

24 ISG 00

25 GTO 01

26 GTO 02

27▸LBL 01

28 I+

29 GTO 00

30▸LBL 02

31 RCL "MCOL"

32 FIX 04

33 RTN

34 .END.


Source


“HP 42S TONE” Museum of HP Calculators. https://www.hpmuseum.org/forum/thread-23678-post-205315.html#pid205315 Retried June 9, 2025.


Have fun,


Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

The author does not use AI engines and never will.

Saturday, June 28, 2025

fx-991 CW: Finding the Eigenvalues of a 2 x 2 Matrix

fx-991 CW: Finding the Eigenvalues of a 2 x 2 Matrix



Finding the Eigenvalues of a 2 x 2 Matrix


To find the eigenvalues of a matrix M, the characteristic polynomial must be solved in terms of λ:


det( M – λ * I) = 0


where:

M = a square matrix of dimension n x n

I = an identity matrix of size n x n.


The identity matrix is a square matrix in which all elements have a value 0 except the diagonal elements, which have the value 1.


A 2 x 2 identity matrix: [ [ 1, 0 ] [ 0, 1 ] ]

A 3 x 3 identity matrix: [ [ 1, 0, 0 ] [ 0, 1, 0 ] [ 0, 0, 1 ] ]


For a 2 x 2 matrix:


M = [ [ a, b ] [ c , d ] ]


The characteristic polynomial used to find the eigenvalues are:


det( M – λ * I) = 0

det( [ [ a, b ] [ c , d ] ] - λ * [ [ 1, 0 ] [ 0, 1 ] ] ) = 0

det( [ [ a, b ] [ c , d ] ] - [ [ λ, 0 ] [ 0, λ ] ] ) = 0

det( [ [ a - λ, b ] [ c , d - λ ] ] ) = 0

(a – λ) * (d – λ) – b * c = 0

λ^2 – (a + d) * λ + (a * d – b * c) = 0


Note:

trace(M) = a + d

det(M) = a * d – b * c


The characteristic equation to be solved is:


λ^2 – (a + d) * λ + (a * d – b * c) = 0

λ^2 – trace(M) * λ + det(M) = 0



Casio fx-991CW Algorithm


The algorithm will involve two apps: Matrix and Equation. Here is a way of finding the eigenvalues of a 2 x 2 matrices using only the fx-991 CW calculator without the need for writing anything down.


Note: The variables I use in the procedure is just for illustrative purposes. You can use any variables you want to designate the corner elements, the trace, and the determinant. The point is to be organized.


Variables used in this procedure:

A = upper-left element

B = lower-right element

C = trace = A + B

D = determinant


Settings: It is assumed that the MathI/MathO Input/Output mode and a+bi is selected for Complex result.


The screen shots are generated using the ClassPad Math (classpad.net) emulator for the fx-991CW and illustrates finding the eigenvalues of the matrix:


MatA = [ [ 4, 2 ] [ 5, 4 ] ]


Matrix App


Step 1: Press the [ HOME ] key, select the Matrix app.


Step 2: Use the TOOLS key to define a Matrix of dimension 2 x 2.


Step 3: Enter the matrix’s elements. Register each element is registered by using [ OK ] or [ EXE ]. Be careful not to press [ EXE ] or [ OK ] without entering a value first, as we need to keep the matrix editing screen up.


Step 4: Go to element (1,1) (upper-left hand corner), press the [ VARIABLE] key, go to variable A, press [ OK ], and select Store. Then go to element (2,2) (lower-right hand corner), press the [ VARIABLE] key, go to variable B, press [ OK ], and select Store.**


Step 5: Without entering or editing an element, press either [ EXE ] or [ OK ] to leave the matrix editor. When the message “Press [TOOLS] to define Matrix.” appears, we are in the calculation mode of the Matrix app.


Note: If you leave the matrix edit mode before storing the corner elements, you can go back into matrix edit mode by pressing [ TOOLS ], selecting your matrix, and then selecting Edit. You can check to see if corner values are stored by pressing [ VARIABLE ].





Step 6: Press [ SHIFT ] [ 4 ] (A) + [ SHIFT ] [ 7 ] ( B ) [ EXE ]. This calculates the matrix’s trace. Then press [ VARIABLE ], choose C, press [ OK ], choose Store.


Step 7: Press [ CATALOG ], select the Matrix sub-menu, then the Matrix Calc sub-menu, and select Determinant. Then use the catalog to grab the matrix and press [ EXE ] to calculate the matrix. Use the variable list to store the value in D (similar procedure in Step 6).





When transferring between apps, the values stored in the memory registers A-F, x, y, and z are retained, even when the fx-991CW is turned off.


Equations App


Step 8: Press [ HOME ] and select the Equation app and press [ OK ]. Select Polynomial, ax²+bx+c (2nd order polynomial, quadratic equation).


Step 9: Enter the following coefficients: 1 x² – C x + D (note the minus sign on C).


Step 10: Press [ OK ]. The first eigenvalue is displayed. Press the down arrow ([↓]) to get the other eigenvalue. 

 An optional step is to use the [ VARIABLE ] key to store the results (like in E or F, for example). 

 Another optional step is to press [ FORMAT ], select Decimal to see the decimal approximation.





The results are:


C = trace = 8

D = determinant = 6

Eigenvalues:

λ1 = 4 + √10

λ2 = 4 - √10



Other Examples



Find the eigenvalues of Mat B = [ [ -8, 1 ] [ 16, 7 ] ]


Results:

C = trace = -1

D = determinant = -72

Eigenvalues:

λ1 = 8

λ2 = -9





Find the eigenvalues of Mat C = [ [ -5, -7 ] [ 3, - 2] ]


Results:

C = trace = -7

D = determinant = 31

Eigenvalues:

λ1 = (-7 + 5 * √3 * i) / 2

λ2 = (-7 - 5 * √3 * i) / 2




I hope you find this useful and beneficial. Until next time,


Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Monday, March 21, 2022

Swiss Micros DM42/HP42S: Polynomial Solver

 Swiss Micros DM42/HP42S:  Polynomial Solver


Introduction


The solver PSOL (pmatsolver.raw) uses a two column matrix PMAT to evaluate and solve for polynomials in the form:


p(x) = a1 * x^b1 + a2 * x^b2 + a3 * x^b3 + ...


And PMAT has the matrix in the form of:


[ [ a1,  b1 ],  

[ a2, b2 ], 

[ a3, b3 ] ... ]


The PMAT Matrix


The solver uses the matrix PMAT.  It must first be created in order for the solver to work.


Creating PMAT:    

1.  Enter the number of terms, press [ENTER], type 2, press [(shift)] [ 9 ] (MATRIX), select (NEW).

2.  Select (EDIT) from the MATRIX menu.

3.  Enter the coefficients and powers.   For terms in form of a1, the power is 0.  For terms in form of x^b1, the coefficient is 1.

4.  Press [EXIT], then [STO], [(shift)] [ENTER] (ALPHA), type PMAT.


Editing PMAT:

1.  Enter the number of terms, press [ENTER], type 2, press [(shift)] [ 9 ] (MATRIX), select (DIM), select PMAT.

2.  From the MATRIX menu, select (EDITN), select PMAT.  Be sure to select EDITN (edit named matrix).


Running the Solver


To run the polynomial solver:

1.  Press [(shift)] [ 7 ] (SOLVER), select PSOL.

2.  To evaluate p(x), enter a value for X and solve for P.   

3.  To solve for x, enter a value for P, enter a guess for X, and then press X again to solve.


Note:  The solver cannot evaluate 0^0.  Hopefully you can see why in the program listing.


The best part of PSOL is that you don't have to use just integer powers, put powers in order, or fill in zero terms (0 * x^n).


Examples


Example 1:  p(x) = 2 + 3x^1.5 - x^3


Set PMAT to be this:

[ [ 2, 0 ], 

[ 3, 1.5 ]

[ -1, 3 ] ]


If X = 2.2, solving for P yields 1.141382003

If P = -1, solving for X with guess 0 yields 2.431407988


Example 2:  p(x) = -5 + 3*x + 4*x^2


Set PMAT to be this:

[ [ -5, 0 ],

[ 3, 1 ], 

[ 4, 2 ]]


If X =1.8, solving for P yields 13.36

If P = 10, solving for X with guess 0 yields 1.59746673 



DM42/HP42S (Free42) Solver Program PSOL


00 { 65-Byte Prgm }

01 LBL "PSOL"

02 MVAR "P"

03 MVAR "X"

04 0

05 STO 01

06 INDEX "PMAT"

07 RCL "PMAT"

08 DIM?

09 R↓

10 STO 02

11 LBL 00

12 RCLEL

13 RCL "X"

14 J+

15 RCLEL

16 Y↑X

17 ×

18 STO+ 01

19 RCLIJ

20 R↓

21 RCL 02

22 X=Y?

23 GTO 01

24 J-

25 I+

26 GTO 00

27 LBL 01

28 RCL 01

29 RCL- "P"

30 .END.


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, June 5, 2021

7000G Retro Month - June 5 Edition

7000G Retro Month - June 5 Edition





Introduction


Welcome to the 7000G Retro Month, which features programming for the classic Casio calculators from the mid/late 1980s:  primarily fx-7000G and fx-7500G.  Since the programming language stays similar throughout the years, programs can be translated to the fx-6300G and later graphing calculators with little to no adjustments.  Non graphic programs should be ported to the fx-4000P, fx-4500P (A), fx-3650p (II), fx-50F Plus (II), and fx-5800P with little to no adjustments.  


7000G Retro Month takes place every Saturday during June 2021.


To make text easier to type, I can going to use the following text friendly symbols for the following:


->  for →


/I for ⊿


=> for ⇒


What do you think?   Unicode or simple text equivalents?  


- - - - - - -- - -- - -


Today's subject revolves around General Mathematics.  Enjoy!


- - - -- - - -- - -- -- -



Day Number of the Year


Returns the day number of a year, with January 1 being Day 1 and December 31 being day 365 (or 366 on leap years).  For LEAP? enter 0 for non leap years or 1 for leap years.   


"MONTH"? -> M

"DAY"? -> D

"LEAP"? -> L

M≤2 => D+Int(30.6M+368.8)-399 -> N

M>2 => D+Int(30.6M+1.6)-34+L -> N


Arithmetic-Geometric Mean


The arithmetic-geometric mean of two positive numbers x and y is a convergence of repeated means:


Arithmetic:  a = (x + y)/2

Geometric:  g = √(x y) 


Tolerance:  decimal to determine desired accuracy.  For example, to eight decimal places, set tolerance to 1E-8.  


"AGM"

"A0"? -> X

"G0"? -> Y

"TOL"? -> T

Lbl 1

(X+Y)÷2 -> A

√(XY) -> G

A -> X : G -> Y

Abs (A-G) ≥ T => Goto 1

A /I

G


The final A and G are displayed to show the convergence.  


Now for two classics.


Determinant of a 3 x 3 Matrix


Here the program makes use of the square brackets and indirect storage.  Yes, indirect storage and recall are possible with the fx-7000G and fx-7500G.  Of course, this program is not necessary in later graphing calculators.


A[0] = A

A[1] = B

A[2] = C

A[3] = D

A[4] = E

A[5] = F

A[6] = G

A[7] = H

A[8] = I


Elements are entered left to right, completing row by row.


The determinant is stored in the variable T.


The Isz command is used to increment K by 1.  Since K starts at 0 and K increases by 1 before comparing it, the next command is never going to be skipped.


"3 X 3 DET"

0 -> K

Lbl 1

? -> A[K]

Isz K

K < 9 => Goto 1

A(EI-FH)-B(DI-FG)+C(DH-EG) -> T


Quadratic Formula


I would consider this the "Hello World" of mathematics programs.   


Ax^2 + Bx + C = 0


Let D be the discriminant:  D = B^2 - 4AC.   D is displayed where you can determine the characteristics of the roots:


D ≥ 0:  roots are real, stored in X and Y

D < 0:  roots are complex, that take the form of X + Yi, X - Yi


"A"? -> A

"B"? -> B

"C"? -> C

B^2-4AC -> D /I

D<0 => Goto 1

(-B+√D)÷(2A) -> X

(-B-√D)÷(2A) -> Y

Goto 2

Lbl 1

-B÷(2A) -> X

√ Abs D ÷(2A) -> Y

Lbl 2

X /I Y


Eddie


All original content copyright, © 2011-2021.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Sunday, September 13, 2020

Numworks: Generating a Colorful Matrix

Numworks:  Generating a Colorful Matrix 

(updated 10/18/2021)


Introduction

Today's script generates a 3 x 3 matrix of random integers from 1 - 9 which each of the numbers are assigned a color.  The numbers are displayed in a 3 x 3 grid using the 320 x 240 pixel screen.  

The colors which are assigned to each number are:

1:  Shamrock Green  (0, 158, 96)

2:  Denim Blue (21, 96, 189)

3:  Navy Blue (0, 0, 128)

4:  Indigo (75, 0, 130)

5:  Red (255, 0, 0)

6:  Rose (255, 0, 127)

7:  Brown (101, 67, 33)

8:  Orange (255, 127, 39)

9:  Gold (255, 223, 0)


Numworks Python Script:  colormtx.py


from math import *

from random import *

from kandinsky import *


# 2020-08-25 EWS


# color arrays

# red

mr = [ 0, 21, 0, 75, 255, 255, 101, 255, 255 ]

# green

mg = [ 158, 96, 0, 0, 0, 0, 67, 127, 223 ]

# blue 

mb = [ 96, 189, 128, 130, 0, 127, 33, 39, 0 ]


# set up matrix

mat = [ [ 0, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ]


# generate random numbers, assign colors 

for r in range(3): 

 for c in range(3):

  mat[ r ][ c ] = randint(1,9)

  x = 80 + 80 * c

  y = 60 + 60 * r

  s = mat[ r ][ c ]

  draw_string(str(s), x, y, color(mr[s-1], mg[s-1], mb[s-1]))


Download the code here:  https://my.numworks.com/python/ews31415/colormtx


Gratitude to Brian who let me know about my typo on the last line, it was missing the final right parenthesis.  


Remember that the index of arrays and matrices go from 0 to n-1.  

Examples






Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Friday, July 3, 2020

Casio fx-9750GIII: Sequence of Rotated Points

Casio fx-9750GIII: Sequence of Rotated Points

Introduction

The program ROTSEQ generates a 2 row matrix from the sequence:

[ [ x_n+1 ] [ y_n+1 ] ] = A * [ [ cos θ, -sin θ ] [ sin θ, cos θ ] ] * [ [ x_n ] [ y_n ] ]

The required inputs are:
You will set the angle mode to Degree, Radian, or Gradian
A = multiplier
θ = angle
x1 = initial x point
y1 = initial y point
N = number of steps

Casio fx-9750GIII Program ROTSEQ

This can be used on most if not every modern Casio Graphing calculator.

"EWS 2020-06-07"
Menu "ANGLE","DEGREE",1,"RADIAN",2,"GRADIAN",3
Lbl 1:Deg:Goto 4
Lbl 2:Rad:Goto 4
Lbl 3:Gra:Goto 4
Lbl 4
"F=A*MAT*[[X][Y]]"
"A"?->A
"θ"?->θ
"X1"?->X
"Y1"?->Y
"STEPS"?->N
[[X][Y]]->Mat A
Mat A->Mat B
For 1->I To N
[[cos θ,-sin θ][sin θ,cos θ]]*Mat A->Mat A
Augment(Mat B,Mat A)->Mat B
Next
"FINAL RESULTS:"◢
Mat B

Example

A = 0.5
θ = 10 grads  (Gradian mode)
x1 = 1
y1 = -1
N = 5  (5 steps)

I don't think I ever used gradian angle units on this blog before, so why not?

Results are shown and rounded to 2 decimal places

Mat B:

[ 1.00   1.14   1.26   1.34   1.40   1.41 ]
[ -1.00  -0.83  -0.64 -0.44  -0.22  0.00 ]

The next blog post will be on July 5 since tomorrow will be the 4th of July (Happy Birthday, United States). 

Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Sunday, June 14, 2020

TI-84 Plus CE: Complex Recurring Sequences

TI-84 Plus CE:  Complex Recurring Sequences

The program CMPXSEQ generates a matrix table for the complex recurring series:

C = (P + B * Q) / (1 + A)

where:
P and Q are complex constants
A = z_0
B = z_1
C = z_2

Restated, this recursion series becomes:

z_2 = (P + z_1* Q) / (1 + z_0)

In its current operating system (5.4.0), the TI-84 Plus CE's recurring sequence graphing mode cannot accept complex numbers.   Therefore a program is required.  Furthermore, matrices on the TI-84 Plus CE do not handle complex numbers.   It is required to break the complex numbers into parts.   For completeness I added both the rectangular and the polar parts of complex numbers:  real part, imaginary part, radius, and angle (dependent on angle mode).

TI-84 Plus CE Program CMPXSEQ  (text)

"EWS 2020-04-28"
ClrHome
a+bi
Disp "C=(P+B*Q)/(1+A)","COMPLEX","C=Z(N), B=Z(N-1), A=Z(N-2)"
Prompt P,Q
Input "Z0?",A
Input "Z1?",B
Input "NO OF STEPS?",N
{5,N+1}→dim([E])
For(I,0,N)
(P+Q*B)/(1+A)→C
I→[E](1,I+1)
real(C)→[E](2,I+1)
imag(C)→[E](3,I+1)
abs(C)→[E](4,I+1)
angle(C)→[E](5,I+1)
B→A
C→B
End
[E]^T→[E]
Disp "RESULT = [E]","[REAL,IMAG,ABS,ANGLE]"


Results are stored in matrix E.  ^T is the transpose function. 

Examples

Tables generated using the LibreOffice Numbers desktop app and results verified with the TI-84 Plus CE. 

Example 1:
P = 1
Q = i
z_0 = A = 2i
z_1 = B = -2



Example 2:
P = -i
Q = 1
z_0 = A = 2i
z_1 = B = -2



Example 3:
P = 1-i
Q = 1+i
z_0 = A = 2i
z_1 = B = -2



Have a great Sunday and week,

Eddie

All original content copyright, © 2011-2020.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Tuesday, April 2, 2019

HP Prime and TI-84 Plus CE: Percent Change on Paired Data

HP Prime and TI-84 Plus CE:  Percent Change on Paired Data

Introduction

Given a two column matrix, the programs here calculate the percent difference on each row.  The first column is the old value while the second column is the new value.

HP Prime Program %CHGPAIRED

EXPORT %CHGPAIRED(m0)
BEGIN
// Δ% on a 2 column matrix
// 2019-03-31 EWS
LOCAL k,s:=SIZE(m0);
LOCAL n:=s(1);
LOCAL m1:=MAKEMAT(0,n,1);
FOR k FROM 1 TO n DO
m1(k,1):=%CHANGE(m0(k,1),m0(k,2));
END;
RETURN m1;
END;

TI-84 Plus Program CHGPAIR

"2019-03-31 EWS"
Disp "PCHG PAIRED DATA"
Input [J]
dim([J])→L₆
L₆(1)→N
{N,1}→dim([I])
For(K,1,N)
([J](K,2)-[J](K,1))/[J](K,1)*100→[I](K,1)
End
Pause [I]

Example

M =
[[ 1, 6 ], [ 4, 2 ], [ 3, 7 ], [ 6, 5 ], [ 4, 11 ]]

Result:
[[ 500 ], [ -50 ], [ 133.3333333 ], [ -16.6666667 ]]

[picture]

Source:  "Probability and Statistics:  Step by Step Solutions for Your HP-28S or HP-28S Calculator"  Hewlett Packard.  November 1987.

Eddie


All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Thursday, December 20, 2018

HP Prime and TI-84 Plus: Fibonacci Triangles (updated)

HP Prime and TI-84 Plus:  Fibonacci Triangles

This program is the request of John Cvetan.  I thank you for your suggestion.

Introduction

The program FIBMAT generates the Fibonacci Triangle in matrix form.  The Fibonacci triangle is a triangle generated where the outer entries of each row contain the Fibonacci sequence.  The Fibonacci sequence is generated by:

f_0 = 1
f_ 1 = 2
f_n = f_n-1 + f_n-2

You can quickly calculate the nth Fibonacci number by the formula:

f_n = ( (1 + √5)^n - (1 - √5)^n ) / (2^n * √5)

To generate the Fibonacci triangle,

1.  Let r the row and c be the column with

f_0,0 =  1
f_1,0 = 1
f_1,1 = 1
f_2,1 = 1

2.  Each row will be determined by adding the last two terms going diagonally.  You can use one of two formulas:

f_r,c = f_r-1,c + f_r-2,c

f_r,c = f_r-1,c-1 + f_r-1,c-2

The Program FIBMAT

FIBMAT generates a Fibonacci triangle in matrix form.  It's the result is a triangle that is "tilted".  n will need to be 3 or greater.



HP Prime Program FIBMAT

EXPORT FIBMAT(n)
BEGIN
// Fibonacci "triangle" in
// matrix form
// 2018-12-17 EWS
LOCAL M1,k;
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 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;

Here's an alternate code for Fibonacci Triangle Matrices.  The row command has been eliminated and I used a second For loop in its place.  (added 12/23/2018)

EXPORT FIBMATALT(n)
BEGIN
// 2018-12-23 EWS
// Fibonacci Matrix Alternate
// matrix form
// This version does not have the
// row function.
LOCAL M1,k,j;
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 DO
FOR j FROM 1 TO n DO
M1(k,j):=M1(k-2,j)+M1(k-1,j);
END;
M1(k,k):=M1(k-1,k-1)+M1(k-2,k-2);
END;
RETURN M1;
END;


TI-84 Plus Program FIBMAT

"2018-12-18 EWS"
"FIBONACCI MATRIX"
Input "ORDER: ",N
{N+1,N+1}→dim([A])
1→[A](1,1)
1→[A](2,1)
1→[A](2,2)
For(K,3,N+1)
For(J,1,N)
[A](K-2,J)+[A](K-1,J)→[A](K,J)
End
[A](K-1,K-1)+[A](K-2,K-2)→[A](K,K)
End
Pause [A]

The Program FIBTRI

This is a visual program for Fibonacci Triangle.



FIBTRI(n) generates a visual Fibonacci Triangle - although I don't recommend going beyond 12 rows due to the constraints of the screen.  I used the small font for the rows.

HP Prime Program FIBTRI

EXPORT FIBTRI(n)
BEGIN
// Fibonacci triangle
// 2018-12-17 EWS
LOCAL M1,k;
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 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;

RECT();
LOCAL s;
FOR k FROM 1 TO n+1 DO
s:=STRING(SUB(row(M1,k),1,k));

IF k≤6 THEN
TEXTOUT_P(s,
140-5.5*(k-1),(k-1)*15,2);
END;

IF k>6 AND k≤11 THEN
TEXTOUT_P(s,
140-8*(k-1),(k-1)*15,2);
END;

IF k>11 THEN
TEXTOUT_P(s,
140-11.5*(k-1),(k-1)*15,2);
END;

END;
WAIT(0);
END;

Source:

Hosoya, Haruo.  "Fibonacci Triangle"  Ochanomizu University, Tokyo, Japan.  1976.  https://www.fq.math.ca/Scanned/14-2/hosoya.pdf

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues The programs are listed for the Swiss Micros DM42 an...