Sunday, November 29, 2020

HP Prime: Linear Exponential Combination Fit

 HP Prime:  Linear Exponential Combination Fit


The program LINEXPREG attempts to fit bivariate data to the curve:


y = a + b * x + c * e^x


The LSQ (least square) function is used.  The output is a list of three matrices:



*  A matrix of coefficients:  [ [ a ] [ b ] [ c ] ] 


*  A matrix of y values entered


*  A matrix of predicted y values



HP Prime Program LINEXPREG


EXPORT LINEXPREG(lx,ly)

BEGIN

// 2020-11-17 EWS

// x list, y list

LOCAL n,lx2,lx3,mx,my,k,mr,mq;

n:=SIZE(lx);

lx2:=e^(lx);

lx3:={};

FOR k FROM 1 TO n DO

lx3:=CONCAT(lx3,{1,lx(k),lx2(k)});

END;

mx:=list2mat(lx3,3);

my:=list2mat(ly,1);

mq:=LSQ(mx,my);

mr:=mq(1,1)+mq(2,1)*lx+

mq(3,1)*e^(lx);

mr:=list2mat(mr,1);

RETURN {mq,my,mr};

END;


Example





x list:  {0, 1, 2, 3, 4, 5}

y list:  {2, 7, 13, 18, 26, 34}


LINEXPREG({0, 1, 2, 3, 4, 5},{2, 7, 13, 18, 26, 34})


Results:  {coefficients, y values, predicted y values}


coefficients:

[ [ 1.74935499143 ]

[ 5.39455446221 ]

[ 3.66584105034E-2 ] ] 


y values:

[ [ 2 ]

[ 7 ]

[ 13 ]

[ 18 ]

[ 26 ]

[ 34 ] ]


predicted y values:

[ [  1.78601340193 ]

[ 7.24355734477 ]

[ 12.8093349675 ]

[ 18.6693222357 ]

[ 25.3290542368 ]

[ 34.1627178129 ] ] 


Equation:

y = 1.74935499143 + 5.39455446221 * x + 3.66584105034E-2 * e^x


On to the last month of 2020...


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. 


Saturday, November 28, 2020

Review: Ativa 2-Line Calculator DD-2361

 Review:  Ativa 2-Line Calculator DD-2361


Just the Facts:


Model:  DD-2361 (I was stated in the manual)

Company: Ativa (Office Depot)

Type: Four Function

Battery:  Solar with backup battery LR1130

Logic: Algebraic

Memory Registers: None

Price:  $8.99





A Two Line Screen

The Ativa DD-2361 calculator has a two lines: the top line shows the entered expression.  Each calculation can have up to 79 characters.   The bottom line shows answers, which can have up to 12 characters.  

Functions include the percent function which, works like four function calculators.  

Example:  

Top:  7 x 8 - 2 x 9

Bottom:  38


The order of operations are used.  


The keys on the keyboard are huge and responsive.  Expressions can be edited using left and right arrow keys.  Characters are replaced in editing.  


Verdict


I like the big keys.  The DD-2361 does lack a few key features: square root, an independent memory register, and due to the calculator following the order of operations, parenthesis.  This is one of few two-line four-function calculators where you can buy it a store, and not just online.  


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, November 22, 2020

Heron's Formula vs Area by Vertices

Heron's Formula vs Area by Vertices

There are several ways to determine the area of a triangle.

Heron's Formula:

With side lengths A, B, and C, the area is:

Area = √( S * (S - A) * (S - B) * (S - C) ) 

where S = (A + B + C) / 2

Area of Vertices:

With vertices (x1, y1), (x2, y2), and (x3, y3), the area is:

Area = 1/2 * abs( (x1 - x2) * (y1 + y2) + (x2 - x3) * (y2 + y3) + (x3 - x1) * (y3 + y1) )

Testing The Data






I ran a test of 50 randomly selected sets of three points that form the triangle.  The three points are:
*  The origin: (0,0)
*  The second point has 0 ≤ x ≤ 20 and -20 ≤ y ≤ 20, x and y are integers
*  The third point has 0 ≤ x ≤ 20 and 0 ≤ y ≤ 20, x and y are integers

I used the Casio fx-9750gIII Spreadsheet application.    

Casio Spreadsheet Set Up

Column Titles - Row 1:

Column A:  "X1"   x coordinate of point 1
Column B:  "Y1"   y coordinate of point 1
Column C:  "X2"   x coordinate of point 2. 
Column D:  "Y2"  y coordinate of point 2
Column E:  "X3"  x coordinate of point 3
Column F:  "Y3"  y coordinate of point 3
Column G:  "XY1"  distance between points 1 and 2
Column H:  "XY2"  distance between points 2 and 3
Column I:  "XY3"  distance between 3 and 1
Column J:  "S"   semi-perimeter of the triangle
Column K:  "HERON"  Area by Heron's Formula
Column L: "VERT"  Area by Vertices 
Column M:  "DIFF"  Difference between two calculation methods

Formulas for Rows 2 through 51

Column A:  A2 = Fill(0,50)
Column B:  B2 =Fill(0,50)
Column C:  C2 =Seq(Int(22 Ran#) - 1,X,1,50,1)
Column D:  D2 =Seq(Int(41 Ran#) - 21,X,1,50,1)
Column E:  E2 =Seq(Int(22 Ran#) - 1,X,1,50,1)
Column F:  F2 =Seq(Int(22 Ran#)-1, X,1,50,1)
Column G:  G2 Fill:  =√(C2^2 + D2^2) for range G2:G51*
Column H:  H2 Fill:  =√((C2-E2)^2 + (D2-F2)^2) for range H2:H51
Column I:  I2 Fill:  =√(E2^2 + F2^2) for range I2:I51*
Column J: J2  Fill:  =(G2 + H2 + I2) ÷ 2 for range J2:J51
Column K:  K2 Fill =√(J2 (J2 - G2) (J2 - H2) (J2 - I2) ) for range K2:K51
Column L:  L2 Fill =0.5 × Abs( (A2 - C2)(B2 + D2) + (C2 - E2)(D2 + F2) 
+ (E2 - A2)(F2 + B2)) for range L2: L51
Column M:  M2  Fill =K2-L2

 * To take advantage that the first point is (0, 0).  The full distance formula would be needed otherwise.  

This spreadsheet implies that there is no "rounding" the middle results.  


If you want to download the spreadsheet results, click here:


The zip file contains two images, a csv file, and a Casio spreadsheet file that can be ran on Casio calculators with a spreadsheet application. 

Of the sample taken, the areas determined by Heron's Formula and Area by Vertices are substantially equal; any difference is the order of 10^-12.

Happy Thanksgiving,

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. 

Saturday, November 21, 2020

Numworks: 3 x 3 Matrices

 Numworks:   3 x 3 Matrices


The script invthree.py calculates the inverse and determinant of a 3 x 3 matrix.  


Matrices:


[[ a1,  a2,  a3 ]

[ b1, b2, b3 ]

[ c1, c2, c3 ]]



Numworks script invthree.py:

(701 bytes)


from math import *


# 2020-11-12 EWS

print("3x3 Matrix Inverse")

print("[[a1,a2,a3]")

print("[b1,b2,b3]")

print("[c1,c2,c3]]")

a1=float(input('a1: '))

a2=float(input('a2: '))

a3=float(input('a3: '))

b1=float(input('b1: '))

b2=float(input('b2: '))

b3=float(input('b3: '))

c1=float(input('c1: '))

c2=float(input('c2: '))

c3=float(input('c3: '))

# determinant

d=a1*(b2*c3-b3*c2)-a2*(b1*c3-b3*c1)+a3*(b1*c2-b2*c1)

# inverse

d1=(b2*c3-c2*b3)/d

d2=-(a2*c3-c2*a3)/d

d3=(a2*b3-a3*b2)/d

e1=-(b1*c3-c1*b3)/d

e2=(a1*c3-c1*a3)/d

e3=-(a1*b3-a3*b1)/d

f1=(b1*c2-b2*c1)/d

f2=-(a1*c2-a2*c1)/d

f3=(a1*b2-a2*b1)/d

print("det=")

print(d)

print("inv=")

print([d1,d2,d3])

print([e1,e2,e3])

print([f1,f2,f3])


Numworks page:  https://workshop.numworks.com/python/ews31415/invthree


Example:


[[ -5.4, 3.3, -1.7 ], [ 0.6, 8.3, 5.3 ] [ 5.5, 5.4, 1.9 ]] 


returns 


[ -0.05493...,  -0.06604..., 0.13508... ]

[ 0.11974... ,  -0.00389..., 0.11798... ]

[ -0.18130..., 0.20224..., -0.20006... ]


Source:


wikiHow Staff "How to Find the Inverse of a 3x3 Matrix"  WikiHow.   Last Updated November 5, 2020.  https://www.wikihow.com/Find-the-Inverse-of-a-3x3-Matrix  Retrieved November 12, 2020.


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, November 15, 2020

HP 41C and DM41: Operations by Test, Messages, Block Storage

 HP 41C and DM41: Operations by Test, Messages, Block Storage  


The programs are inspired from a great calculator resource, "Calculator Tips & Routines Especially For The HP-41C/41CV", edited by John Dearing (see source below).   


Operations by Test


One of the tips presented is the selection of one of two opposite arithmetic operations based on a comparison between X and Y values.  This tip was provided by Bill Kolb (tip 2-7).  They are:


X?Y

CHS  (subtract if test is true)

+   (add if test is false)


X?Y

1/X  (divide if the test is true)

*  (multiply if the test is false)


X?Y

1/X   (take the root if the test is true)

Y↑X  (take the power if the test is false)


The following programs uses the test X<Y:


TESTAS:  X<Y  (subtract, y - x),  X≥Y (adding, y + x)


(^T represent the beginning of an alpha string)


01 LBL^T TESTAS

02 X<Y?

03 CHS

04 + 

05 END


Example:  

45, 13, XEQ TESTAS returns 32  (45 - 13)

13, 45, XEQ TESTAS returns 58  (13 + 45)


TESTMD:  X<Y  (divide, y/x),  X≥Y (mulitply, y * x)


01 LBL^T TESTMD

02 X<Y?

03 1/X

04 * 

05 END


Example:  

45, 13, XEQ TESTMD returns 3.4615  ( ≈ 45 / 13)

13, 45, XEQ TESTMD returns 585  (13 * 45)


TESTPR:  X<Y  (root, y^1/x),  X≥Y (power, y^x)


01 LBL^T TESTPR

02 X<Y?

03 1/X

04 Y↑X 

05 END


Example:  

49, 3, XEQ TESTPR returns 3.6593  ( ≈ 49 ^ 1/3)

3, 49, XEQ TESTPR returns 2.3930E23  (≈ 3 ^ 49)


Messages


With the use of AVIEW during a loop, you can display a loop up to 12 characters while the loop is running.   A CLD (clear display) is added after the loop's completion to clear the alpha display and show the stack. (tip 2-25)


The program TESTSUM adds a message while the 41C is summing numbers from 1 to X.   While this is not the most efficient way to tackle the problem, this illustrates the use of messages.  


01 LBL^T TESTSUM

02 STO 01

03 0

04 STO 02

05 LBL 01   // loop begins

06 RCL 01

07 ST+ 02

08 ^T ADDING...  // message

09 AVIEW   // display the message

10 DSE 01

11 GTO 01

12 CLD  // clear display

13 RCL 02

14 END


Example:

50, XEQ TESTSUM  

Display: ADDING..., then 1275


Block Storage


You can use indirect storage and the stack to store a constant in a block of consecutive storage registers.  A sample loop:


LBL %%

STO IND Y

ISG Y

GTO %%


Where %% is a label, and the loop variable is B.EEE  (B:  beginning register, E:  ending register) stored in this case, Stack Y.  (tip 10-1)


The program LOADBLK, prompts the user enter the value, beginning register number, and ending register number.


01 LBL^LOADBLK

02 ^T VALUE

03 PROMPT

04 STO Z     // keystrokes:  [ STO ]  [ . ]  ( Y )

05 ^T R%% BGN?

06 PROMPT

07 ^T R%% END?

08 PROMPT

09 1E3

10 /

11 +

12 STO Y  

13 RDN   // R↓

14 X<>Y

15 LBL 01

16 STO IND Y   // keystrokes:  [ STO ] [ shift ] [ . ] ( Y )

17 ^T STORING...    // message

18 AVIEW

19 ISG Y    // keystrokes:  [ shift ] ( ISG ) [ . ] ( Y )

20 GTO 01

21 ^T DONE

22 AVIEW

23 PSE

24 CLD

25 END


Try this:

Store π in R00 to R03 and e^1 in R04 to R07.

 

Results:  (Fix 4)

R00:  3.1416

R01:  3.1416

R02:  3.1416

R03:  3.1416

R04:  2.7183

R05:  2.7183

R06:  2.7183

R07:  2.7183


Source:


Dearing, John.  "Calculator Tips & Routines Especially for the HP-41C/41CV"  Corvallis Software, Inc.   Corvallis, OR.  1981 


Link on HP41.org (account needed):  http://www.hp41.org/LibView.cfm?Command=View&ItemID=320



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. 


Saturday, November 14, 2020

HP Prime: The Percent Function

 HP Prime:  The Percent Function


The Percent Function



The HP Prime has three percent functions.   They are not easily found (through the catalog or in program edit mode, Cmds-More menu).  The functions are:


%

%CHANGE

%TOTAL


% Function


%(x, y)  returns x * y /100.  This returns either x% of y or y% of x.  Due to the communicative multiplication property, you can use the arguments in either order.  


%CHANGE


This the percent change function where the arguments are %CHANGE(old, new).  Formula:  %CHANGE(x, y) = (y - x) / x * 100%


%TOTAL


This calculates the % total given a part and a whole.  Syntax:  %TOTAL(whole, part).  Formula:  %TOTAL(x, y) = y / x * 100%


The program POPTOWN uses the percent functions.  It is a simple game where you invite a certain population to live in a town, and the birth (growth) and death rates are determined by random.


HP Prime Prime Program:  POPTOWN


RESULTS(y,n,g,d,p)

BEGIN

// subroutine

PRINT();

PRINT("Year: "+STRING(y));

PRINT("Population: "+STRING(n));

IF y>0 THEN

PRINT("Growth: "+STRING(g)+"%");

PRINT("Death: "+STRING(d)+"%");

PRINT("Δ%: "+%CHANGE(p,n));

END;

WAIT(0);

END;


// main program

EXPORT POPTOWN()

BEGIN

MSGBOX("You start with 10 

residents, inviting up to 50 

new residents each year.  Can 

growth beat death?");

// 2020-10-24 EWS

// Growth and Death

LOCAL n,y,w,g,d,c,p;

LOCAL v; // number of invites

n:=10;

RESULTS(y,n,g,d,p);

// The game

FOR y FROM 1 TO 5 DO

INPUT({{c,{0,10,20,30,40,50}}},

"Year "+STRING(y),"Invite:");

// all invites move in at the

// beginning of each turn

p:=n;

w:=10*(c-1)+n;

v:=10*(c-1)+v;

g:=RANDINT(5,20);

d:=RANDINT(1,25);

n:=w+IP(%(w,g))-IP(%(w,d));

// empty town scenario

IF n≤0 THEN

MSGBOX("No one survived.");

n:=0; 

END;

RESULTS(y,n,g,d,p);

END;

// End the game results

PRINT("Final Results");

PRINT("Population Change: "+

STRING(n-10));

PRINT("Invited: "+STRING(v));

PRINT("Percent Invite: "+

STRING(ROUND(%TOTAL(n,v),2))

+"%");

END;



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. 


Saturday, November 7, 2020

HP Prime: Approximate of a Quartic Root

 HP Prime: Approximate of a Quartic Root


Introduction


In the article "Square Root & Cube Root Algorithms" (see source below), teacher and educator Dave  Elgin wrote an article on how his Advanced Higher Applied Mathematics class developed algorithms to estimate the square root and cubic roots of numbers.  The algorithms are first based off of Netwon's Method, then uses selected initial guesses and solving for linear systems.


Elgin's Derivation 


Square Root


Suppose x^2 = k.   To set up for Newton's Method, let f(x) = x^2 - k, with df/dx = 2x.  Then


x_n+1 = x_n - (x_n^2 - k) / (2 * x_n) = 1/2 * (x_n + k / x_n^2)


(The article uses N for the number to find the root of, but to eliminate confusion, I use k.  Completely a choice of labels.)


The class used a pattern to determine guesses for the square root of k:


k / (x_n),  (k^2) / (x_n^3),  (k^3) / (x_n^5), and so on.   


Let g(x) be an iterative function where x_n+1 = g(x_n) and for a second-order approximation:


g(x) = a1 * x + a2 * k / x + a3 * k^2 / x^3


Two derivatives of g(x) are taken:


g'(x) = a1 - a2 * k / x^2 - 3 * a3 * k^2 / x^4, with g'(x_n) = 0


g''(x) = 2 * a2 * k / x^3 + 12 * a3 * k^2 / x^5 with g''(x_n) = 0


This requires the following system of equations to be solved for a1, a2, and a3 (after substituting x = √k):


1 = a1 + a2 + a3

0 = a1 - a2 - 3 * a3

0 = 2 * a2 + 12 * a3


leading to the solutions a1 = 3/8, a2 = 3/4, and a3 = -1/8


Hence the second-order recursive function for the square root is (after simplifying):


g(x) = 3/8 * x + (3 * k) / (4 * x) -  k^2 / (8 * x^3)


which translates to 


x_n+1 = 3/8 * x_n + (3 * k) / (4 * x_n) -  k^2 / (8 * x_n^3)


Cube Root


They repeat the same process for the cubic root, which I will briefly outline here:


x^3 = k,   f(x) = x^3 - k,  f'(x) = 3x^2


x_n+1 = x_n - (x^3 - k) / (3x^2) = 1/3 * (2 * x_n - k / (x_n^2))


With guess of k / (x_n^2) and k^2 / (x_n^5) used, the iterative function is set up as:


g(x) = a1 * x + a2 * k / x^2 + a3 * k^2 / x^5


and


g'(x) = a1 - 2 * a2 * k / x^3 - 5 * a3 * k^2 / x^6


g''(x) = 6 * a2 * k / x^4 + 30 * a3 * k^2 / x^7


and with g(x_n) = x_n+1, g'(x_n) = 0, g''(x_n) = 0 and substituting x = k^1/3, the system becomes:


1 = a1 + a2 + a3

0 = a1 - 2 * a2 - 5 * a3

0 = 6 * a2 + 30 * a3


with the solutions a1 = 5/9, a2 = 5/9, and a3 = -1/9, giving the second-order recursive function:


g(x) = 5/9 * x + (5 * k) / (9 * x^2) - k^2 / (9 * x^5)


The article shows the derivation of a third-order recursive function for both square and cube root. 


Deriving a Second-Order Algorithm for Quartic Roots


Let's use a similar approach used in Elgin's article to develop an algorithm to calculate the fourth (quartic) root:  


k^1/4 = x


Let f(x) = x^4 - k,  then f'(x) = 4*x^3, and


x_n+1 = x_n - (x_n^4 - k) / (4 * x_n^3) = 3/4 * x_n - k / (4 * x_n^3)


Use guesses x_n, k / (x_n^3), k^2 / (x_n^7), we set up the equations:


g(x) = a1 * x + a2 * k / x^3 + a3 * k^2 / x^7


g'(x) = a1 - 3 * a2 * k / x^4 - 7 * a3 * k^2 / x^8


g''(x) = 12 * a2 * k / x^5 + 56 * a3 * k^2 / x^9



Setting g(x) = x^1/4, g'(x) = 0, g''(x) = 0, and setting g(k^1/4), we get the system:


1 = a1 + a2 + a3

0 = a1 - 3 * a2 - 7 * a3

0 = 12 * a2 + 56 * a3


The solutions to above system:  a1 = 21/32, a2 = 7/16, a3 = -3/32, which gives the second order recursive  equation:


g(x) = 21/32 * x + (7 * k) / (32 * x^3) - (3 * k) / (32 * x^7)

 

The program FTHROOT use the recursive equation to approximate the quartic root. 



HP Prime Program:  FTHROOT


EXPORT FTHROOT(k)

BEGIN

// EWS 2020-10-21

// Approx 4th Root

LOCAL r,r0,r1,ri;

r:=k^0.25;

r0:=0; 

r1:=√k;

ri:=0;

WHILE ABS(r0-r1)>1á´‡−10 DO

ri:=ri+1;

r0:=r1;

r1:=(21*r0)/32+(7*k)/(16*r0^3)-(3*k^2)/(32*r0^7);

END;

PRINT();

PRINT("4√"+PRINT(k));

PRINT("Root = "+STRING(r));

PRINT("------");

PRINT("Approximation: "+

STRING(r1));

PRINT("Iterations: "+STRING(ri));


END;


The choice of a good first guess is necessary with any iterative root finding process. The program FTHROOT chooses the square root of k for an initial guess.   The goal is to seek a positive root.


Examples


Each example is followed by a set of screen shots, which include setting up Sequences and their graphs on the HP Prime.  


Example 1


k = 176.4

Result:  3.64438831256 (algorithm took 7 iterations with initial guess √176.4)



Example 2

k = 5525
Result:  8.62150472576 (algorithm took 9 iterations with initial guess √5525)




Source

Elgin, Dave.  "Square Root & Cube Root Algorithms"  The Mathematical Association.  Mathematics in School, Jan. 2006, Vol. 35, No. 1 pp. 30-31.  https://www.jstor.org/stable/30215863

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, November 1, 2020

Book Review: Calculus for Middle Schoolers by Serena Swegle

 Book Review: Calculus for Middle Schoolers by Serena Swegle


Just The Facts


Calculus for Middle Schoolers


Author:  Serena Swegle


Publisher:  Sunhut Publishing


Cost:  $26.50 for Paperback, $9.99 for Kindle (as of 10/23/2020)


Link:  https://www.amazon.com/Calculus-Middle-Schoolers-Serena-Swegle/dp/057871275X/ref=sr_1_3?dchild=1&keywords=Calculus+for+Middle+Schoolers&qid=1603471676&sr=8-3


Topics Covered


The number e (2.718281828...)


The common logarithm  (base 10)


The natural logarithm (base e)


Trig Functions (sine, cosine, tangent)


Sums 


Limits


Derivative - the derivative of a polynomial


Integral - the integral of a polynomial


The Derivative and Integral of e^x


An Introduction to Calculus 


The target audience is middle school students.  However, book serves as a great introduction to calculus for high school and college students who are taking calculus for the first time.  The book gives a simple, concrete introduction to various subjects, in an easy-to-read narrative.  Calculus is a complex subject, and this book allows readers, who may be intimidated about the subject, to develop a understanding.   


I would recommend this book to be read prior to the student's first calculus class.   The book can be read in one or two days, but I feel it was meant to read as one chapter a time per day or week.   


Verdict


Swegle's book is well written, in a concise language.  The chapter covers one concept at the time, which serves as a great introduction to a rich subject.   The examples are simple and apply closely to the text.   I wish Swegle put a summary of all the topics covered at the end of the book as a wrap up.  Otherwise, I recommend this book for educators and parents.   For those who have the Kindle app, $9.99 is a good price point.  Recommended.


Thank you, Serena for recommending this book for me to review.  


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. 


Saturday, October 31, 2020

Breaking Down the Factorial

Breaking Down the Factorial


Factorial: It's Not Just For Integers


Let n be a positive number, where n > 0.   n! can be rewritten as:


n! 

= n * (n - 1)!

= n * (n - 1) * (n - 2)!

= n * (n - 1) * (n - 2) * (n - 3)!

...

= n * (n - 1) * (n - 2) * (n - 3) * ... * k


where 0 ≤ k ≤ 1.   Note that 0! = 1.   Keep the loop multiplying n, n - 1, n - 2, n - 3, etc. until you a multiplying a number between 0! and 1! to the total.


For certain k:


0.25! ≈ 0.9064024771

0.50! = ≈ 0.8862269255

0.75! ≈ 0.9190625268

1! = 1


Examples


3! = 3 * 2 * 1! = 3 * 2 * 1 = 6

3.25! = 3.25 * 2.25 * 1.25 * 0.25! = 9.140625 * 0.25! ≈ 8.285085142

3.5! = 3.5 * 2.5 * 1.5 * 0.5! = 13.125 * √Ï€ ÷ 2 ≈ 11.6317284

3.75! = 3.75 * 2.75 * 1.75 * 0.75! = 18.046875 * 0.75! ≈ 16.58620654


4! = 4 * 3 * 2 * 1! = 4 * 3 * 2 * 1 = 24

4.25! = 4.25 * 3.25 * 2.25 * 1.25 * 0.25! = 38.847652625 * 0.25! ≈ 35.21161185

4.5! = 4.5 * 3.5 * 2.5 * 1.5 * 0.5! = 59.0625 * √Ï€ ÷ 2 ≈ 52.3427778

4.75! = 4.75 * 3.75 * 2.75 * 1.75 * 0.75! = 85.72265625 * 0.75! ≈ 78.78448106


Factorial Values of 0 to 1


Below is a chart are the values for 0 to 1, along with several approximation polynomials.  The value and polynomials have been determined using LibreOffice's Calc application.  








Happy Halloween, 

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, October 25, 2020

Swiss Micros DM41X: Custom Menus

 Swiss Micros DM41X: Custom Menus




Customize It


With the new Swiss Micros DM41X, custom menus comes to the HP 41C engine.   The custom menu can hold up to 16 commands or user program shortcuts.   Best yet, the customized menu can be saved and transferred among fellow DM 41X users.   The custom menu is very easy to use and set up.


To access the custom menu, just press the [ CST ] key.   To use one of the commands, just press the corresponding key related to the assigned letter, no prior alpha key is required.  For example, to access the command in the A slot, press [ CST ] [ Σ+ ].  


The custom menu has six other commands that are always present:


1.  Help:  The DM41X's help facility which additional commands that come with the 41X, information about the ISG/DSE loops, date, time, and alarms, and additional topics like Angel's references.


2.  ROM Map:  A map where all the modules are loaded into the virtual ROM facility of the DM41X.


3.  Load a RAW file


4.  Save a RAW file


5.  USB Disk:  Put the DM41X in USB mode, allowing to transfer files between the calculator and the computer


6.  Flags:  A map listing the state of all the DM41X's flags.  0 means the flag is off, 1 means the flag is on.


To customize the custom menu, press [gold shift] [ CST ] (CONF).


Pick any of the slots A through P.  While in this mode, you can customize three additional key sequences:


[ gold shift ] [ blue alpha ]


[ gold shift ]  [ ↑ ] 


[ gold shift ]  [ ↓ ]


When prompted, just type the command, label, or program name.  Alpha mode has been turned on automatically.  Finish and accept by pressing the [ R/S ] key.   Pressing the [ ON ] cancels the customization.   The custom menu does not affect the programming memory.


One more thing, the name cannot have a space.   For example:  ARCL ST X is not allowed.   ARCL is.  


That's all there is to it.  Have fun,


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. 


Saturday, October 24, 2020

HP 42S/DM42/Free42: Drawing Lines and Circles

 HP 42S/DM42/Free42:  Drawing Lines and Circles



Introduction

The HP 42S, Swiss Micros DM42, and Free42 has several graphics commands that allows for drawing and plotting functions.   The following programs draw simple geometric objects on the calculator's screen:

HLINE:  horizontal line

VLINE:  vertical line

DLINE:  a line between two points

DCIRC:  draw a circle given a center point and radius


The graphics screen of the 42S is 131 x 16.  The x axis goes from 1 to 131 to the right, while the y axis goes from 1 to 16 down.  


To plot points along the line, use the equation:

y = slope * x + (y1 - x1 * slope)

where slope = (y1 - y0) / (x1 - x0)


For the circle, the pixels to be plotted are:

x' = x + r * sin θ

y' = x + r * cos θ

for θ from 0° to 360°  (0 to 2Ï€ in radians)


Since a full circle is plotted, we don't have to worry about accounting for the fact that the y axis is inverted.  


Commands used:


CLLCD:  clear the screen


PRLCD:  print the screen.  Depending on whether the printer is on or off and what machine is being used, the screen would printed to the optional infrared printer or saved as a print file.  Turning print off (by the PROFF setting) will just display the screen.  


PIXEL:  Takes the arguments from the y-stack and x-stack and draws a pixel.   There are several flags that can affect how the command operates, that is beyond the scope of this blog entry.  Non-integer numbers can be used as pixels.


HP 42S/DM42/Free42 Program:  HLINE


     00 { 58-Byte Prgm }

          01 LBL "HLINE"

           02 "X START?"

             03 PROMPT  

             04 STO 01  

             05 "X END?"

             06 PROMPT  

             07 STO 02  

             08 "Y?"    

             09 PROMPT  

             10 STO 03  

             11 RCL 02  

             12 1á´‡3     

             13 ÷       

             14 RCL+ 01 

             15 STO 00  

             16 CLLCD   

             17 LBL 01  

             18 RCL 03  

             19 RCL 00  

             20 IP      

             21 PIXEL   

             22 ISG 00  

             23 GTO 01  

             24 PRLCD   

             25 END 


HP 42S/DM42/Free42 Program:  VLINE


    00 { 58-Byte Prgm }

          01 LBL "VLINE"

             02 "X?"    

             03 PROMPT  

             04 STO 03  

           05 "Y START?"

             06 PROMPT  

             07 STO 01  

             08 "Y END?"

             09 PROMPT  

             10 STO 02  

             11 RCL 02  

             12 1á´‡3     

             13 ÷       

             14 RCL+ 01 

             15 STO 00  

             16 CLLCD   

             17 LBL 01  

             18 RCL 00  

             19 IP      

             20 RCL 03  

             21 PIXEL   

             22 ISG 00  

             23 GTO 01  

             24 PRLCD   

             25 END  


HP 42S/DM42/Free42 Program:  DLINE


The x coordinates are entered first.  The point (x0, y0) is the to left of the point (x1, y1) and x0 < x1 is required.  Attempt to draw vertical lines where x0 = x1 using DLINE will result in an error.


 00 { 89-Byte Prgm }

          01 LBL "DLINE"

            02 "X0 < X1"

             03 AVIEW   

             04 STOP    

             05 "X0?"   

             06 PROMPT  

             07 STO 01  

             08 "X1?"   

             09 PROMPT  

             10 STO 03  

             11 1á´‡3     

             12 ÷       

             13 RCL+ 01 

             14 STO 00  

             15 "Y0?"   

             16 PROMPT  

             17 STO 02  

             18 "Y1?"   

             19 PROMPT  

             20 STO 04  

             21 X<>Y    

             22 -       

             23 RCL 03  

             24 RCL- 01 

             25 ÷       

             26 STO 05  

             27 RCL× 03 

             28 +/-     

             29 RCL+ 04 

             30 STO 06  

             31 CLLCD   

             32 LBL 01  

             33 RCL 00  

             34 IP      

             35 RCL× 05 

             36 RCL+ 06 

             37 RCL 00  

             38 IP      

             39 PIXEL   

             40 ISG 00  

             41 GTO 01  

             42 PRLCD   

             43 END     


HP 42S/DM42/Free42 Program:  DCIRC


 00 { 70-Byte Prgm }

          01 LBL "DCIRC"

             02 "X CTR?"

             03 PROMPT  

             04 STO 01  

             05 "Y CTR?"

             06 PROMPT  

             07 STO 02  

            08 "RADIUS?"

             09 PROMPT  

             10 STO 03  

             11 DEG     

             12 0.36005 

             13 STO 00  

             14 CLLCD   

             15 LBL 01  

             16 RCL 00  

             17 IP      

             18 RCL 03  

             19 →REC    

             20 RCL+ 01 

             21 X<>Y    

             22 RCL+ 02 

             23 X<>Y    

             24 PIXEL   

             25 ISG 00  

             26 GTO 01  

             27 PRLCD   

             28 .END.   


These programs and routines can be used stand-alone or as subroutines.  


You can download the four programs here:  

https://drive.google.com/file/d/1FJqVTkGMAtLa-0eMBHQ1LEfdKGt55VNM/view?usp=sharing


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, October 18, 2020

HP 42S/DM42: Height of a Fire, Time to Clear a Corridor

 HP 42S/DM42:  Height of a Fire, Time to Clear a Corridor


HP 42S/DM42/Free42 Program:  FIREHGT


The program FHGT approximates the height of a fire in three scenarios:


* A relatively large fire

* A fire with a base area of approximately 0.5 meter

* A fire set in a corner


The general equation is:


H = factor * Q^0.4


H = height of a fire in meters, including the tip

factor = constant depending on the scenario the fire is set in

Q = energy release rate in kilowatts


00  {119-Byte Prgm}

01 LBL "FIREHGT"

02 "ENERGY? (kW)"

03 PROMPT

04 STO 01

05 LBL 00

06 "TYPE?"

07 AVIEW

08 "LARGE"

09 KEY 1 GTO 01

10 "0.5 M"

11 KEY 2 GTO 02

12 "CORNER"

13 KEY 3 GTO 03

14 MENU

15 LBL 10

16 STOP 

17 GTO 10

18 LBL 01

19 0.23

20 GTO 04

21 LBL 02

22 0.21 

23 GTO 04

24 LBL 03

25 0.075

26 GTO 04

27 LBL 04

28 CLMENU

29 EXITALL

30 RCL 01

31 0.4

32 Y↑X

33 ×

34 "HEIGHT=" 

35 ARCL ST X

36 AVIEW

37 END


Example:


Q = 2650 kW


large fire:  H = 5.38302238231 m

0.5 m fire:  H = 4.9149334795 m

corner fire:  H = 1.7553338554 m


HP 42S/DM42/Free42 Program:  SMOKE


The program SMOKE estimates:


*  The front velocity of the smoke, or how quickly the smoke fills a corridor

*  The time it takes for front velocity to fill the corridor.


Equations used:


V ≈ 0.5 * √(g * (1 - Ta/T) * H)

tf = L / Vf


g = acceleration of gravity, for Earth, g = 9.80665 m/s

Ta = ambient temperature

T = gas temperature  (Ta ≤ T)

H = height of the corridor in meters

L = length of the corridor in meters 


Note 1 - Ta/T = (Da - Dc) / Da

Da = density of the corridor of the ambient air

Dc = density of the fire fluid


00 {99-Byte Prgm}

01 LBL "SMOKE"

02 1

03 "AMB. TEMP?"

04 PROMPT

05 "GAS TEMP?"

06 PROMPT

07 ÷

08 -

09 9.80665

10 ×

11 "HEIGHT? (M)"

12 PROMPT

13 ×

14 SQRT

15 2

16 ÷

17 ENTER

18 "VEL= "

19 ARCL ST X

20 AVIEW 

21 STOP 

22 R↓

23 1/X

24 "LENGTH? (M)"

25 PROMPT

26 ×

27 "TIME="

28 ARCL ST X

29 AVIEW

30 END


Example:


Amb. Temp:  78 °F = 25.555555556 °C

Gas Temp:  103 °F = 39.44444444 °C

Height:  3.048 m

Length:  3.6576 m


Results:


Velocity:  1.622103844 m/s

Time:  2.254849474 s


Source:


Lawson, J.R. and Quintiere, J.G..   "Slide Rule Estimates of Fire Growth". Fire Technology, Vol. 21., No. 4, November 1985, pg. 267



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. 


Saturday, October 17, 2020

Review: Catiga CS-121

Review:  Catiga CS-121








Just the Facts:


Model:  CS-121 (could be other model numbers)

Company: Catiga

Type: Graphing

Battery:  Case contains 2 CS-2032 slots, but can run on 1

Logic: Algebraic

Memory Registers: 9 

Colors:  Many colors including Black, Red, Blue.  I purchased a blue CS-121.  


Case and Keyboard


The cover case and calculator casing for the CS-121 is very light.  When sliding the calculator into the case, you really have to listen for the snap to lock the calculator in place.  The keys are very fast and responsive, you will have no problems typing in expressions quickly.  


Screen


Like most graphing calculators, the CS-121 has a large screen.  However, the CS-121 does not use the screen like most graphing calculators.   The CS-121 operates as a large Casio fx-6300g instead.   Graphs take up part of the left side of the screen and you can see only the X or the Y (not both) coordinates during tracing.   The expression line is reduced to the bottom line of the screen.  


This is my biggest gripe of the CS-121.   This screen scheme may have worked on the fx-6300g and its relatives fx-6200g and HP 9g because they have small screens to work with, but the CS-121 should have full screen graphs and allowed the use of the entire screens for expressions in Home mode. 


Features of the CS-121


Left,  Catiga CS-121;  Right, Casio fx-6300g


The CS-121 isn't an entire clone of the fx-6300g because it does have some nice advanced features.  


Graphing:  Functions (up to 2 functions), Parametric (1 parametric pair)

Calculus:  Numeric Integrals of f(x)

Solver:  Solve for any variable

Complex Number Mode:  Arithmetic, Cube, Cube Root, Square, Square Root, Absolute Value, Argument (angle).   The [ENG] acts as the i key.  Switch between showing the real and complex results by pressing [ SHIFT ] [ = ].  All complex numbers operate in rectangular format (a + bi).  

Regressions:  Linear, Logarithm, Exponential, Power, Inverse, Quadratic.   Get the correlation ( r ) by pressing [SHIFT] [ ( ].  

Base-N:  The CS-121 adds boolean logic functions ([x^3] key):  And, Or, Nxor, Xor, Not, Neg

Drawing Tools:  Plot points, lines including lines between two points, horizontal, vertical, and tangent.   It is a little frustrating that the CS-121 does not use the entire screen for graphs because it would really enhance the use of the drawing tools.  


Memory


Let's talk about the memory.  It is very unusual for a graphing calculator to only have nine memory slots (A, B, C, D, E, F, X, Y, M with M+ and M-).  It's because the CS-121 does not have programming.  Yes, you can store an equation in the form var=f(vars) with the [SHIFT] [ Calc ] (PROG) key sequence and calculate using the stored equation by using [ Calc ].  


It is very rare that a graphing calculator does not have programming.  The rare Casio fx-6200g was a direct relative to the fx-6300g and it did not have programming.  


The Learn (LRN) Key


The [LRN] key allows users to shift graphs or change the size of the graphs.  Handy when learning about functions.  


Verdict


I like the keyboard and I like how responsive the calculator operates.  The CS-121 operates on not much battery (ultimately 1 CS-2032 battery).  As said before, my major gripe is the mismanaged use of the screen.   



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. 


Thursday, October 15, 2020

HPCC 2020 Virtual Conference and Document Website

 HPCC 2020 Virtual Conference and Document Website 


HPCC 2020 Virtual Conference


The HPCC 2020 Virtual Conference took place on October 10, 2020.   The HPCC is the Handheld and Portable Computer Club is a long running calculator and computer site based out of the United Kingdom.  Their meetings are held virtually on the 2nd and 4th Saturday of every month.  I have recently joined the HPCC and glad to be a part of the club. 

You can find more information on the meetings here:  http://www.hpcc.org, under the Home tab.  Membership rates are between £17 to £23 depending where you live.


The conference has the following speakers and topics:


Eric Rechlin:  USB Drive Update

Jake Schwartz:  Updates to the PPC Archive

Bob Prosperi:  Swiss Micros DM41X - A little late; a lot better

Eric Hazen:  HP-25 Re-implementation on Z80 with VFD display

Michael Park:  MP-29 - a tactile touchscreen calculator

Mark Power:  Prime G2

Sylvain Côté:  Clonix & NoV modules for the HP-41

Edward Shore:  CAS and Calculators

Gene Wright and Włodek Mier-Jędrzejowicz: HP's Worst Calculators

Godwin Stewart:  Presentation on DMConnect 

Will Marchant:  DM16 in a satellite launch campaign


Conference web page:  http://www.hpcc.org/conferences/index.html


Each talk has slides for download and the corresponding YouTube video.  Special thanks to Eric Rechlin. 


HP Documentation Website


Eric Rechlin of hpcalc.org has put together a new website where you can download manuals for Hewlett Packard calculators, past and present.  


Link:  https://literature.hpcalc.org


Coming soon:  the USB that contains information calculator conferences including manuals through 2020 will be available his commerce site,  https://commerce.hpcalc.org.


Eddie  (Edward Shore)


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. 


Python – Earth’s Radius and Gravity in US Units

Python – Earth’s Radius and Gravity in US Units Introduction The following script, gravus2.py, estimates the Earth’s gravity i...