Monday, October 3, 2022

Matrices in Python without Numpy: Part 1

Matrices in Python without Numpy:  Part 1


Introduction


Python is a wonderful programming language and is a welcome addition to graphing calculators such as:


*  TI nSpire CX II  and TI nSpire CX II CAS

*  TI-84 Plus CE Python (it's become hard to find and hopefully it won't be the case in 2023)

*  HP Prime

*  Casio fx-CG 50

*  Casio fx-9750GIII and fx-9860GIII

*  Numworks

*  From France:  TI-83 Premium Python, TI-82 Advanced Edition Python, Casio Graph fx-35+ E II


As I understand at time, there is no numpy module for any of the calculators*.   


But we want to work with matrices.  So we will need to program code to allow work with matrices.  Welcome to the Matrices in Python without Numpy series!


* There is a linalg module for the HP Prime.  


This series will cover:


*  creating matrices and other basics

*  adding and multiplying matrices

*  determinant and inverse of 2 x 2 and 3 x 3 matrices

*  upper triangular matrices and general determinant



In this series, a single Python file is created, matrix.py.   Each of the commands are going to be a separate function within a define structure.   This allows matrix.py to imported into other Python scripts by from matrix import *.  



Entering Matrices


Use square brackets to enter matrices:  


[ [ M11, M12, M13, ... ] , [ M21, M22, M23, ... ] , [ M31, M32, M33, ... ] ] 


Each row enclosing elements per column, and each row is separated by a comma.  All the rows are enclosed in square brackets.  


In this sense, matrices in this sense are nested lists.  Call elements by:


Call a row:   matrix[row]

Call the last row:  matrix[-1]

Call an element:  matrix[row][column]


Number of rows:  len(matrix)

Number of columns:  len(matrix[0])


Remember, in Python, indices start with 0 and go to row-1, column-1.  We will stick with the index convention to stay consistent.  


Screenshots are made using an emulator on my.numworks.com


Creating and Printing Matrices


newmatrix(number of rows, number of columns).  


The matrix will be filled with zeros.


Code:

def newmatrix(r,c):

  M = []

  while len(M)<r:

    M.append([])

    while len(M[-1])<c:

      M[-1].append(0.0)

  return M





identity(size)


Creates an identity matrix, a square matrix with ones in the diagonal, zeroes everywhere else.  The identity matrix a fundamental matrix.


Code:


def identity(n):

  M = newmatrix(n,n)

  for i in range(n):

    M[i][i]=1.0

  return M





So far, we see resulting matrices in a row or scroll off the screen.  Let's make it so we can see matrices as they are written.  


mprint(matrix)


Prints a matrix in text form.


def mprint(M):

  for r in M:

    print([x+0 for x in r])


List comprehension is a very powerful tool in Python.


In the following examples, we will store a 3 x 3 matrix:


mat1 = [ [ 1, 2, 3 ] , [ 4, 5, 6 ] , [ 7, 8, 9 ] ] 


transpose(matrix)


The transpose function flips a matrix on it's diagonal.  For each element:


M^T:   M(row, col) → M^T(col, row)


def transpose(M):

  # get numbers of rows

  r=len(M)

  # get number of columns

  c=len(M[0])

  # create transpose matrix

  MT=newmatrix(c,r)

  for i in range(r):

    for j in range(c):

      MT[j][i]=M[i][j]

  return MT






scalar(matrix, factor)


Next, we have scalar multiplication, multiply each element of the matrix by the factor.


def scalar(M,s):

  r=len(M)

  c=len(M[0])

  MT=newmatrix(r,c)

  for i in range(r):

    for j in range(c):

      MT[i][j]=s*M[i][j]

  return MT





mtrace(matrix)


Finally, we have the a trace of a matrix.  The trace is the sum of all the diagonals of a square matrix.  If the matrix is not square, an error occurs.


def mtrace(M):

  r=len(M)

  c=len(M[0])

  MT=newmatrix(r,c)

  if r !=c:

    return "Not a square matrix"

  else:

    t=0

    for i in range(r):

      t+=M[i][i]

    return t


In Python != means not equal.  





Coming in Part 2, let's add and multiply matrices.  


Happy computing,


Eddie 



Source:


Ives, Thom.  "BASIC Linear Algebra Tools in Pure Python without Numpy or Scipy"  Integrated Machine Learning & AI  December 11, 2018.  https://integratedmlai.com/basic-linear-algebra-tools-in-pure-python-without-numpy-or-scipy/


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. 


Sunday, October 2, 2022

Swiss Micros DM41X: Setting Up Keys Through a Program

Swiss Micros DM41X:  Setting Up Keys Through a Program


Assigning User Keys Through a Program


On the HP 41/DM 41 family, it is possible to store programs or commands in a program (see Caution below).


ASN vs PASN


Both ASN and PASN assigns a user key.  ASN is not a programmable command, but PASN is.  


ASN will prompt for a key with the program or command in the alpha register. 


PASN is a programmable command with the following syntax:


^T  (program or command name)

(key code)

PASN


The key codes start in the upper left hand corner of the classic HP 41C calculators.  If you are using a Swiss Micros version, please keep in mind that the keyboard is different from the classic HP 41C but the key codes are retained.


Some common user keyboard key codes are:

[ Σ+ ] 11

[ 1/x ] 12

[ √x ] 13

[ LOG ] 14

[ LN ] 15


[x<>y] 21

[ R↓ ] 22

[SIN] 23

[COS] 24

[TAN] 25


[ENTER↑] 41

[ - ] 51

[ + ] 61

[ × ] 71

[ ÷ ] 81


Shifted user keys have a negative value, for example:

[ (shift) ] [ Σ+ ] ( Σ- )  -12

[ (shift) ] [ 1/x ] (y^x)  -13

 and so on.


Clearing Assigned Keys


To clear a single user key, assign a blank alpha string to it.  This works for both ASN and PSAN.  


You can clear all the keys by the CLKEYS command. (see Caution below).


Caution:  Unless modifications or additional ROMs are added, the commands PASN and CLKEYS are not available on the HP 41C and the HP 41CV.  The commands are available on the HP 41CX, DM41X,  DM 41, and DM 41L.  



Template



Give the user a choice to clear or load the user keys: 


LBL ^T  (main name of the program)

^T 0 CLR 1 LOAD

PROMPT

STO 00

GTO IND 00


Fortunately we can use indirect addressing with the GTO command. 


This section clears all the keys.  I put a DONE message to tell the user that the process is done.  


LBL 00

CLRKEYS

^T DONE

AVIEW

RTN          


This section loads the commands and programs to user keys.  Detailed programs will follow. 


LBL 01 

^T  (program or command name)

(key code)

PASN

...

RTN


Now for the programs and calculations created:


LBL ^T (program or command name)

(contents)

RTN

...


END 


Add an END command after the last RTN.  


The Program UFX


The program UFX presents the user with two options:  enter 0 to clear all the user keys.  Entering 1 loads the following functions:


SSPH:  Surface area of a sphere.  Assigned to the user key [ Σ+ ], key code 11.

Surface area of a sphere = 4 * π * x^2


VSPH:  Volume of a sphere.  Assigned to the user key [ x<>y ], key code 21.

Volume of a sphere = 4/3 * π * x^3


STOR:  Surface area of a torus.  Assigned to the user key [ 1/x ], key code 12. 

Surface area of a torus = 4 * π * y * x 

y = larger radius, x = smaller radius


VTOR:  Volume of a torus.  Assigned to the user key [ R↓ ], key code 22.

Volume of a torus = 2 * π^2 * y * x^2

y = larger radius, x = smaller radius


Swiss Micros DM41X Program UFX


(^T:  alpha string indicator)


01 LBL ^T UFX

02 ^T 0 CLR 1 LOAD

03 PROMPT

04 STO 00

05 GTO IND 00

06 LBL 00

07 CLRKEYS

08 ^T DONE

09 AVIEW

10 RTN          \\ RTN outside a subroutine stops the program

11 LBL 01      \\  assign the keys first, add the programs later

12 ^T SSPH

13 11

14 PASN

15 ^T VSPH

16 21

17 PASN

18 ^T STOR

19 12

20 PASN

21 ^T VTOR

22 22

23 PASN

24 ^T DONE    

25 AVIEW

26 RTN              \\ this ends the loading processing, the detialed subroutines follow 

27 LBL ^T SSPH

28 X↑2

29 PI

30 *

31 4

32 *

33 RTN

34 LBL ^T VSPH

35 3

36 Y↑X

37 4

38  *

39  3

40  /

41 PI

42  *

43 RTN

44 LBL ^T STOR

45 *

46 PI

47 X↑2

48  *

49  4

50  * 

51  RTN

52 LBL ^T VTOR

53 X↑2

54  *

55  PI

56 X↑2

57  *

58  2

59  *

60  RTN

61  END     \\ we want to end the program with END


Source (for the Torus formulas):


Mathematics Program Library:  Sinclair Enterprise Programmable  Sinclair Radionics Inc.  New York; Cambridgeshire, London.  1975


That is all this time, see you next time!


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, October 1, 2022

Casio fx-CG 50: Random Walk Histogram

Casio fx-CG 50:  Random Walk Histogram


Mosquitos an Inspiration, What? 


Inspiration:  

Ellenberg, Jordan.   Shape:  The Hidden Geometry of Information, Biology, Strategy, Democracy, and Everything Else  Penguin Books:  New York, NY. 2021


The beginning of Chapter 4, Sir Ronald Ross proposes the problem:  In a simple case, a mosquito can only travel in one of two directions, which is northeast or southwest.   The goal was to find the average distance a mosquito is from its home after a given life span.


The program TWALK would address a similar problem.  


N = number of trials


S = number of steps the mosquito (or whatever you want to imagine) walks in a single direction


Each trial calculates the final position.  The program draws a histogram of all the trails.   


TWALK gives two choices:


(-1, 1):  Each turn, the mosquito must move forward 1 step or backward 1 step


(-1, 0, 1):  Each turn, the mosquito must either move forward 1 step, move backward 1 step, or stay still for one turn. 



Drawing an Histogram Program in Casio Programming


Syntax:


S-Grph#  DrawOn, Hist, List x, 1, [ColorLinkOff], [Color] ColorLighter


# = Graph 1, 2, 3

List x = List 1 to List 26

Color Commands:  ColorLinkOff, 

Colors: One of 8 eight colors

ColorLighter: the fill of the color is lighter than the bar


The color commands are optional.  If you are using a Casio fx-9750GIII, leave of the color commands.



Casio fx-CG50 Program TWALK


Text:

'ProgramMode:RUN

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?->N

N->Dim List 26

"NO. STEPS"?->S

Menu "STEPS","_(-)_1,1",2,"-1,0,1",3

Lbl 2:2->F:Goto 1

Lbl 3:3->F:Goto 1

Lbl 1

For 1->I To N

F=2=>Sum (2*RanInt#(0,1,S)-1)->List 26[I]

F=3=>Sum (RanInt#((-)1,1,S))->List 26[I]

Next

"POSITIONS LIST:"Disps

List 26Disps

(-)S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat



On the Screen:

"EWS 2022-08-04"

"RANDOM WALK 2.0"

"NO. TRIALS"?→N

N→Dim List 26

"NO. STEPS"?→S

Menu "STEPS","-1,1",2,"-1,0,1",3

Lbl 2:2→F:Goto 1

Lbl 3:3→F:Goto 1

Lbl 1

For 1->I To N

F=2⇒Sum (2×RanInt#(0,1,S)-1)→List 26[I]

F=3⇒Sum (RanInt#(-1,1,S))→List 26[I]

Next

"POSITIONS LIST:"◢

List 26◢

-S->H Start

1->H pitch

S-Gph1 DrawOn,Hist,List 26,1,ColorLinkOff,Blue ColorLighter 

DrawStat


Examples


N = 50, S = 5


(-1, 1):  Mosquito cannot rest





(-1, 0, 1): Mosquito can rest






Wishing you an excellent day,


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. 


Sunday, September 25, 2022

Proving Chebyshev Polynomial Closed Formulas for n = 0, n = 1, and n = 2

Proving Chebyshev Polynomial Closed Formulas for n = 0, n = 1, and n = 2



Chebyshev Polynomials of the First Kind


Recurrence Definition:


T_0(x) = 1

T_1(x) = x

T_n+1(x) = 2 * x * T_n(x) - T_n-1(x)


Closed Definition:


T_n(x) = 1/2 * [ (x - √(x^2 - 1))^n + (x + √(x^2 - 1))^n ]


Let: w = √(x^2 - 1)


T_n(x) = 1/2 * [ (x - w)^n + (x + w)^n ]


n = 0

T_0(x) 

= 1/2 * [ (x - w)^0 + (x + w)^0 ]

= 1/2 * [ 1 + 1 ] 

= 1


n = 1

T_1(x)

= 1/2 * [ (x - w)^1 + (x + w)^1 ]

= 1/2 * [ x - w + x + w ]

= 1/2 * [ 2 * x]

= x


n = 2

T_2(x)

= 1/2 * [ (x - w)^2 + (x + w)^2 ]

= 1/2 * [ x^2 - 2*w + w^2 + x^2 + 2*w^2 + w^2 ]

= 1/2 * [ 2 * x^2 + 2 * w^2 ]

= x^2 + x^2 - 1

= 2 * x^2 - 1



Chebyshev Polynomials of the Second Kind


Recurrence Definition:


U_0(x) = 1

U_1(x) = 2 * x

U_n+1(x) = 2 * x * U_n(x) - U_n-1(x)


Closed Definition:


U_n(x) = [ (x + √(x^2 - 1))^(n + 1) - (x - √(x^2 - 1))^(n + 1) ] ÷ [ 2 * √(x^2 - 1) ]


Let: w = √(x^2 - 1)


U_n(x) = [ (x + w)^(n + 1) - (x - w)^(n + 1) ] ÷ [ 2 * w ]


n = 0

U_0(x)

= [ (x + w)^(1) - (x - w)^(1) ] ÷ [ 2 * w ]

= [ x + w - x + w ] ÷ (2 * w)

= (2 * w) ÷ (2 * w)

= 1


n = 1

U_1(x)

= [ (x + w)^(2) - (x - w)^(2) ] ÷ [ 2 * w ]

= [ (x^2 + 2 * x * w + w^2) - (x^2 - 2 * x * w + w^2) ] ÷ (2 * w)

= [ 4 * x * w ] ÷ (2 * w)

= 2 * x


n = 2

U_2(x)

= [ (x + w)^(3) - (x - w)^(3) ] ÷ [ 2 * w ]

= [ x^3 + 3*x^2*w + 3*x*w^2 + w^3 - (x^3 - 3*x^2*w + 3*x*w^2 - w^3)] ÷ [ 2*w ]

= [ x^3 + 3*x^2*w + 3*x*w^2 + w^3 - x^3 + 3*x^2*w - 3*x*w^2 + w^3] ÷ [ 2*w ]

= [ 6*x^2*w + 2*w^3 ] ÷ [ 2*w ]

= [ 6*x*√(x^2 - 1) + 2*(x^2 - 1)^(3/2) ] ÷ [ 2*√(x^2 - 1)  ]

= [ 6*x*√(x^2 - 1) + 2*(x^2 - 1)*√(x^2- 1) ] ÷ [ 2*√(x^2 - 1)  ]

= [ 6*x*√(x^2 - 1) + 2*(x^2 - 1)*√(x^2- 1) ] ÷ [ 2*√(x^2 - 1)  ]

= [ 6*x*√(x^2 - 1) + (2*x^2 - 2)*√(x^2- 1) ] ÷ [ 2*√(x^2 - 1)  ]

= [ (8*x - 2)*√(x^2 - 1) ] ÷ [ 2*√(x^2 - 1)  ]

= 4*x^2 - 1


Good that the closed formulas hold up, at least for n = 0, 1, 2.   The closed formulas would be good if you don't want to use recurrence relations.  


Sources:


"Chebyshev polynomials"  Wikipedia.   https://en.wikipedia.org/wiki/Chebyshev_polynomials  Last Updated July 20, 2022.  Last Accessed June 21, 2022


Oldman, Keith, Jan Myland, & Jerome Spainer  An Atlas of Functions: with Equator, the Atlas Function Calculator  2nd Edition   Springer:  New York, NY.  2009  ISBN 978-0-387-48806-6


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, September 24, 2022

LSQ2: An update to LSQ (Casio fx-9750GIII, TI-84 Plus CE)

LSQ2:  An update to LSQ (Casio fx-9750GIII, TI-84 Plus CE)


Least Square Matrix and Correlation


The program LSQ2 fits the allows to fit data to a function with minimal error possible. 


Multiple Linear Regression:

f(x1, x2, x3, ...) = b0 + b1 * x1 + b2 * x2 + b3 * x3 + ....


Polynomial Regression:

f(x) = b0 + b1 * x + b2 * x^2 + b3 * x^3 + ...


General:

f(x) = b0 + b1 * g1(x) + b2 * g2(x) + b3 * g3(x) + ...


f(x1, x2, x3, ...) = b0 * g0(x1, x2, x3, ...) + b1 * g1(x1, x2, x3, ...) + ...


The Matrices X, Y, and B



X is your data matrix and is set up as columns:


[  g0(x),  g1(x),  g2(x), ... ]


Where the function g(x) represents functions applied to every data point x_i.  


Example 1:   f(x) = b0 + b1 * x 


The columns of the data matrix are set up as:

[ 1,  x ]


A column of ones set up solving for a constant.


Example 2:  f(x) = b0 + b1 * x + b2 * x^2


The columns of the data matrix are set up as:

[ 1, x, x^2 ]


Example 3:  f(x0, x1) = b0 + b1 * x1 + b2 * x2


The columns of the data matrix are set up as:

[ 1, x1, x2 ]  (note, not x squared in this case)



Y is the answer matrix, of size n rows and 1 column.  There are n data points. We are fitting the function to y_i.


B is the coefficient matrix, consisting of values b0, b1, b2, ....



Simply put, to find B using the least squares method given the data points:


B = (X^T X)^-1 X^T Y


X^T is the transpose matrix of X



How well does the function fit?  


We can predict y values by multiplying X by B.  


P' = X B 



Determining Coefficient of Correlation:


r^2 = SSreg ÷ SStot = [ B^T X^T Y - (O Y)^2 ÷ n ] ÷ [ Y^T Y - (O Y)^2 ÷ n ]

where O is a ones matrix [[ 1, 1, 1, 1, ... ]] of size 1 x n.  



Casio fx-9750GIII Program:  LSQ2


From the text file:  


'ProgramMode:RUN

ClrText

"2022_-_07_-_19 EWS"

"LEAST SQUARES"

"_Mat _X"?->Mat X

"_Mat _Y"?->Mat Y

Dim Mat Y->List 26

List 26[1]->N

(Trn Mat X*Mat X)^-1*Trn Mat X*Mat Y->Mat B

"_Mat _B:"Disps

Mat BDisps

{1,N}->Dim Mat O

Fill(1,Mat O)

Mat O*Mat Y->Mat S

Mat S*Mat S/N->Mat S

(Trn Mat B*Trn Mat X*Mat Y)-Mat S->Mat R

Mat R*(Trn Mat Y*Mat Y-Mat S)^-1->Mat R

"R_^<2>_:"Disps

Mat R



Listing:


ClrText

"2022-07-19 EWS"

"LEAST SQUARES"

"Mat X"? → Mat X

"Mat Y"? → Mat Y

Dim Mat Y → List 26

List 26[1] → N

(Trn Mat X × Mat X)^-1 × Trn Mat X × Mat Y → Mat B

"Mat B:" ⊿

Mat B ⊿

{1, N} → Dim Mat O

Fill(1, Mat O)

Mat O × Mat Y → Mat S

Mat S × Mat S ÷ N → Mat S

(Trn Mat B × Trn Mat X × Mat Y) - Mat S → Mat R

Mat R × (Trn Mat Y × Mat Y - Mat S)^-1 → Mat R

"R^2:" ⊿

Mat R


Matrices:

Mat X:  data matrix, X

Mat Y:  answer matrix, Y

Mat B: coefficient matrix, B

Mat O: ones matrix

Mat S:  used for calculation

Mat R:  correlation




TI-84 Plus CE Program:  LSQ2  (TI-Basic)



Listing:

"2022-07-19 EWS"
ClrHome
Disp "LEAST SQUARES"
Input "[X]? ", [J]
Input "[Y]? ", [I]
dim([I]) → L6
L6(1) → N
([J]^T [J])^-1 [J]^T [I] → [B]
Disp "[B]: "
Pause [B]
{1,N} → dim([H])
Fill(1,[H])
[H] [I] → [G]
[G] [G] * N^-1 → [G]
[B]^T [J]^T [I] - [G] → [A]
[A] * ([I]^T [I] - [G])^-1 → [A]
Disp "R^2: "
Disp [A]

List:
L6:  [ 2nd ] [ 6 ]

Matrices:
[J]:  data matrix, X
[I]:  answer matrix, Y
[B]: coefficient matrix, B
[H]: ones matrix
[G]:  used for calculation
[A]:  correlation


Examples

Example 1:

Equation: y = b0 + b1 * x1 + b2 * x2

X = [ [ 1, 1, 3 ] [ 1, 2, 4 ] [ 1, 5, 6 ] [ 1, 7, 3 ] [ 1, 7, 2 ] ]
Y = [ [ 0.86 ] [ 0.89 ] [ 0.95 ] [ 0.98 ] [ 0.96 ] ]

Coefficients:  [ [ b0 ] [ b1 ] [ b2 ] ]
B = [ [ 0.8257514451 ] [ 0.01836705202 ] [ 5.953757225E-3 ] ]

Correlation: [ [ 0.9875030926 ] ]

Example 2:

Equation: y = b0 + b1 * x + b2 * x^2

X = [ [ 1, 1, 1^2 ] [ 1, 2, 2^2 ] [ 1, 3, 3^2 ] [ 1, 4, 4^2 ] [ 1, 5, 5^2 ] [ 1, 6, 6^2 ] ]
Y = [ [ 1000 ] [ 1294 ] [ 1511 ] [ 1233 ] [ 1006 ] [ 879 ] ]

Coefficients:
B = [ [ 681.7 ] [ 435.2107143 ] [ -69.30357143 ] ]

Correlation: [ [ 0.8119609681 ] ]


Summary

Function to fit:   
f(x1, x2, x3 ... ) = b0 + b1 * g1(x1, x2, x3, ...) + b2 * g2(x1, x2, x3, ...) + ...

X = data matrix
Y = answer matrix, size n x 1
B = coefficient matrix

Determining the Coefficients:   B = (X^T X)^-1 X^T Y

Predicting Values:  P = X B

Determining Coefficient of Correlation:

r^2 = SSreg ÷ SStot = [ B^T X^T Y - (O Y)^2 ÷ n ] ÷ [ Y^T Y - (O Y)^2 ÷ n ]
where O is a ones matrix [[ 1, 1, 1, 1, ... ]] of size 1 x n.  

Source

Abdi, Hervè.  "Multiple Correlation Coefficient"  Program in Cognition and Neurosciences   https://personal.utdallas.edu/~herve/Abdi-MCC2007-pretty.pdf   Retrieved July 17, 2022.  


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. 

Monday, September 19, 2022

HHC 2022 Conference Videos

HHC 2022 Conference Videos


Coming to you from Nashville, Tennessee!


"We're Not Dead Yet"


And if it is any indication, HHC is doing alive and well.


I had the pleasure of attending HHC 2022 in Nashville a week ago.   Most of the talks from HHC 2022 have now been loaded on to hpcalc.org's YouTube channel:


https://www.youtube.com/c/hpcalc/videos



Highlights


*  The ill-fated Texas Instruments TI-88 that was never released in to the public.  How did it fail and what caused Texas Instruments to call off the project after five years?  


*  Updates on the new software for Telsa's automobiles for the Elon Musk fan base. 


*  The HP 10 referred to in Jim Johnson's talk is not the HP 10B or HP 10C, it is the 1978 HP 10 mini-adding machine.   I believe that this is Hewlett Packard's only adding machine type of calculator.


* APF Electronics, Inc manufactured calculators in the 1970s, focusing on four-function and scientific calculators.


*  Bob Prosperi's "When Ordan was New" is about the upcoming Swiss Micros DM32, which is an improved reimplementation of the popular HP 32SII.  


*  The "Everything But The Kitchen Sink" is not about a sink, or a kitchen, but something for the HP 85 and HP 87 computers. 


*  I made a presentation of the advanced functions of the solve feature of the Plus42 app on Day Two.  The Plus42 is by Thomas Okken.  


*  Day One lasted from 8:00 AM to 10:00 PM, and believe it or not, the day goes by fast!   On Day Two we started about 9:30 AM.   Per tradition, Day Two invites attendees to attend an optional Catholic Sunday mass. 


* Door prizes included over 60 calculators and lots of books.  I have a second HP 20S and won a few vintage calculator manuals.  


* Day Two started with an online talk with Klass Kuperus, HP Product Manager of Moravia Consulting.  In the last few years, Hewlett Packard transferred their calculator operation to Moravia Consulting, with the United States market in charge by Royal Consumer.  HP office supply's page:  https://hpofficesupply.com/product-category/calculators/.  Any further updates to the HP Prime's firmware will I get to you as soon I learn of it.  


* The "Actuarial Math" presentation gives a great introduction of calculating the cost of life insurance. 


Videos (as of 9/18/2022) are:


Day One - September 10, 2022


Calculator Patents and How to Find Them - Felix Gross

https://www.youtube.com/watch?v=7ylp17D2tDY


TI-88 Part 1: History of Go/No Go Decision - Gene Wright

https://www.youtube.com/watch?v=wl16wzmn3wA


TI-88 Hardware Tour - Richard Nelson

https://www.youtube.com/watch?v=AuujYrzSyJk


Autonomous Vehicle Status - Telsa's Full Self Driving in 2022 - David Ramsey

https://www.youtube.com/watch?v=4d-ERZgOO5s


What's New on the HCC 2022 USB Drive - Eric Rechlin

https://www.youtube.com/watch?v=FuR3VlWT0-0


If you want a USB Drive, please check on the hpcalc.org's commerce page.  It will be available soon (I don't know the exact date), the drive is sold at cost.  https://commerce.hpcalc.org/


What's New in the PPC Achieve - Jake Schwartz

https://www.youtube.com/watch?v=cWM6ZTan0_o


As of this post, the current version is 2.41, April 1, 2022.  The next update is scheduled later in 2022.   http://www.pahhc.org/ppccdrom.htm


When Ordan was New - Bob Prosperi

https://www.youtube.com/watch?v=kC4qqOmnVUs


TI-88 Part 2:  Features, Comparisons, and Verdict - Gene Wright

https://www.youtube.com/watch?v=xIHaSpvDu0o


Everything But The Kitchen Sink - David Ramsey

https://www.youtube.com/watch?v=tw0oMjgftkY


HP-10 Calculus with Focus on the HP-10 Printer - Jim Johnson

https://www.youtube.com/watch?v=44jsRmrs4_w


Calculator Humor - Gene Wright

https://www.youtube.com/watch?v=FPwUL7kWbHs


APF Calculators - Gene Wright

https://www.youtube.com/watch?v=5IyICERuQWQ



Day Two:  September 11, 2022


Literature Achieve Update - Eric Rechlin

https://www.youtube.com/watch?v=MA9_0q7g96g


Plus42:  Advanced Equation Editor Functions - Edward Shore

https://www.youtube.com/watch?v=8Hk74yB1DhA


Best New Simple PRNGS (pseudo-random number generators) for Calculators: a Pandora's Box - Namir Shammas

https://www.youtube.com/watch?v=NvdBFTZF4SE


Actuarial Math - Adding Morality To The Time Value of Money - Gene Wright

https://www.youtube.com/watch?v=MAmC4An9LrU


Texas Instruments SR-60A Programmable Calculator - David Ramsey

https://www.youtube.com/watch?v=0Mf5rZbrx7k


Namir Shammas - The Best Empirical Multiple Regression Model. 

https://www.youtube.com/watch?v=w_rwLmjFC7E


Disclaimer:  I do not make money from the sales of the HHC USB drives or nor I was paid to advertise.  


Happy calculating,


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. 


Sunday, September 18, 2022

Quick Tip: Determining the Characteristics of a Quadratic Equation

Quick Tip:   Determining the Characteristics of a Quadratic Equation


Introduction


For our algebra and college pre-calculus students, here is a quick way to tell whether the quadratic equations 


A * x^2 + B * x + C = 0


has real roots or complex roots (in the form of a + bi or r*e^(Θi)).  The simple way is to calculate the discriminant.


The discriminant of the quadratic equation is B^2 - 4 * A * C.   


If B^2 > 4 * A * C, or B^2 - 4 * A * C > 0, the roots are real and distinct


If B^2 = 4 * A * C, or B^2 - 4 * A * C = 0, there is a repeated root


If B^2 < 4 * A * C, or B^2 - 4 * A * C < 0, the roots are complex


(A, B, C are real numbers)



Examples


3 * x^2 - 6 * x + 81 = 0

B^2 = 36

4 * A * C = 972

36 < 972

The roots are complex  (1 ± i√26)


4 * x^2 + 44 * x - 318 = 0

B^2 = 1936

4 * A * C = -5088

1936 > -5088

The roots are real and distinct ( (-11 ±√439)/2 )


-3 * x^2 - 6 * x - 5

B^2 = 6

4 * A * C = 60

6 < 60

The roots are complex ( (-3 ± i√6)/ 3)



A Study 


If we let A = 1 and B and C range of integers through -5 to 5, if we pick a quadratic equation from random we find that:


25.62% of the equations have complex roots

4.13% has a repeated root

70.25% has two distinct real roots


Here is the Google Sheet that has the study:  

https://docs.google.com/spreadsheets/d/1ZKAR1dtnHAss1CzxqygHCIB3Mq2u2fn3TLR3espUUXM/edit?usp=sharing



Hope this helps,


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. 


Matrices in Python without Numpy: Part 1

Matrices in Python without Numpy:  Part 1 Introduction Python is a wonderful programming language and is a welcome addition to graphing calc...