## Wednesday, December 30, 2015

### Pascal’s Triangle: Polynomials and TI-84 Plus

Pascal’s Triangle:  Polynomials and TI-84 Plus Pascal's Triangle

Powers of 2

Pascal’s Triangle holds a great number of properties.   For instance, the sum of each row (R) is a power of two (2^R).  The top row is referred to as row 0.  Hence:

1 = 2^0
1 + 1 = 2 = 2^1
1 + 2 + 1 = 4 = 2^2
1 + 3 + 3 + 1 = 8 = 2^3
1 + 4 + 6 + 4 + 1 = 16 = 2^4
1 + 5 + 10 + 10 + 5 + 1 = 32 = 2^5
1 + 6 + 15 + 20 + 15 + 6 + 1 = 64 = 2^6
and so on…

Binomial Expansion

Take a look what happens when you expand the binomial (x + y)^R:

(x + y)^0 = 1

(x + y)^1 = 1*x + 1*y

(x + y)^2 = 1*x^2 + 2*x*y + 1*y^2

(x + y)^3 = 1*x^3 + 3*x^2*y + 3*x*y^2 + 1*y^3

(x + y)^4 = 1*x^4 + 4*x^3*y + 6*x^2*y^2 + 4*x*y^3 + 1*y^4

(x + y)^5 = 1*x^5 + 5*x^4*y + 10*x^3*y^2 + 10*x^2*y^3 + 5*x*y^4 + 1*y^5

(x + y)^6 = 1*x^6 + 6*x^5*y + 15*x^4*y^2 + 20*x^3*y^3 + 15*x^2*y^4 + 6*x*y^5 + 1*y^6

and so on…

Notice the coefficients (in blue)?  They represent rows of the Pascal’s Triangle.

Combinatorics

The formula for find the number of combinations of N items from R is:

COMB(R, N) = R nCr N = R! / ((R – N)! * N!)

If you R stand for a row of the Pascal’s Triangle and N stand for an entry (starting from 0), you can get R nCr N from the triangle.

For instance, for the 4th row (R = 4 with entries 1, 4, 6, 4, 1), 2nd entry (N = 2, with left most entry designated as 0), Pascal’s Triangle will state that 4 nCr 3 = 4! / (2! * 2!) = 6.

For the 5th Row (R = 5):
N = 0, 5 nCr 0 = 1
N = 1, 5 nCr 1 = 5
N = 2, 5 nCr 2 = 10
N = 3, 5 nCr 3 = 10
N = 4, 5 nCr 4 = 5
N = 5, 5 nCr 5 = 1

Sierpinksi Triangle

One of the books I got for Christmas is the book “The Magic of Math: Solving for x and Figuring Out Why” written by Arthur Benjamin.  The book is well written and if you want a good read I recommend this book.  It has something for everyone. One of things I learned from Benjamin’s book is that if you mark all the odd numbers, and you take many rows, you get the famous fractal the Sierpinski Triangle.

Take a look at the diagram below: Making the Sierpinski Triangle

TI-84 Plus:  Generating a Row of Pascal’s Triangle

A short program to generate a row of Pascal’s Triangle.  The result is stored in list L6.  The first entry is the 0th entry.

Input "ROW:",R
R+1→dim(L₆)
For(K,0,R)
R nCr K→L₆(K+1)
End
Disp "L₆:"
Pause L₆

I think this is self-explanatory.

Eddie

HAPPY NEW YEAR!

Source:

Benjamin, Arthur.  The Magic of Math: Solving for x and Figuring Our Why.  Basic Books:  New York.  2015

This blog is property of Edward Shore.   2015.

## Friday, December 18, 2015

### Mathematical Art with the HP Prime and TI-84 CE (December 18, 2015 edition)

Mathematical Art with the HP Prime and TI-84 Plus CE (December 18, 2015 edition)

More visuals for your pleasure.  Happy Holidays and Merry Christmas,

Eddie TI 84 Plus CE: Linear Box Illusion HP Prime:  Confetti 2016 HP Prime: The Random-Colored Diamond HP Prime:  Cutting the Line HP Prime: A Tear HP Prime: Open Wide TI-84 Plus CE: Child’s Flowers

This blog is property of Edward Shore. 2015.

Next time will probably be after Christmas!   Thank you all for your support!   Eddie

## Sunday, December 13, 2015

### Mathematical Art with the HP Prime and TI-84 CE (December 13, 2015 edition)

Mathematical Art with the HP Prime and TI-84 Plus CE (December 13, 2015 edition)

Math is not only fun but can also be creative.  If you want to know I did these plots, please leave a comment below.  Enjoy and best always,

Eddie HP Prime: Linear Waves TI -84 Plus CE:  The Arms of Sine TI-84 Plus CE: Icicles HP Prime:  Fire From the Flask TI-84 Plus CE:  Pyramid Illusion TI-84 Plus CE:  Circular Illusion HP Prime: Folium Roller Coaster HP Prime:  Mantra TilesThis was inspired by this morning's visit to Mantra Coffee in Azusa, CA

The last graphic was inspired by a visit to the Mantra Coffee Company in Azusa, CA (http://www.mantracoffeeco.com/).

This blog is property of Edward Shore.  2015

## Thursday, December 10, 2015

### HP Prime and Casio Prizm: 3 Point Neville's Method

HP Prime and Casio Prizm: 3 Point Neville's Method

Introduction

Neville’s Method is an interpolation method to find an approximation of f(x) at point x.  The function may or may not be known.  The method uses Lagrange interpolation polynomials.

For this blog entry, we will work with 3 known points to interpolate a fourth point.  We certainly can use a higher order interpolation if desired or needed.  In general for the 3 known points (x0, y0), (x1, y1), and (x2, y2):

 P(0,0) P(0,1) P(1,1) P(0,2) P(1,2) P(2,2)

Think of this like a collapsing bracket, collect two neighboring points until a column is completed.  Repeat the process until P(0,n) is reached.   In this case of 3 points, the approximate answer is y ≈ P(0,2).

Formulae:

P(0,0) = (x0, y0)
P(1,1) = (x1, y1)
P(2,2) = (x2, y2)

P(0,1) = ((x1 – x)*y0) + (x – x0)*y1) / (x1 – x0)
P(1,2) = ((x2 – x)*y1) + (x – x1)*y2) / (x2 – x1)

P(0,2) = ((x2 – x)*P(0,1) + (x – x0)*P(1,2)) / (x2 – x0)
Y = P(0,2)

The NEVILLE3 program works with the 3-point interpolation where lists presents the points {x0, x1, x2} and {y0, y1, y2}.  If you use a TI-84 Plus, the Casio Prizm version can be adopted (with appropriate changes).

HP Prime Program:  NEVILLE3

Input:  lx and ly and list of three elements, {x0, x1, x2} and {y0, y1, y2}, respectively, and x is the target point.

EXPORT NEVILLE3(lx,ly,x)
BEGIN
// Neville 3-Point Approx.
// EWS 2015-12-07

LOCAL la,a,y,k,n;

la:={0}; // for consistency

FOR k FROM 1 TO 3 DO

IF k==3 THEN
a:=((lx(3)-x)*la(2)+(x-lx(1))*
la(3))/(lx(3)-lx(1));
ELSE

a:=((lx(k+1)-x)*ly(k)+(x-lx(k))*
ly(k+1))/(lx(k+1)-lx(k));
END;
la:=CONCAT(la,{a});
END;
y:=la(4); RETURN y;
END;

Casio Prizm Program NEVILLE3

Input:  List 1 and List 2 and list of three elements, {x0, x1, x2} and {y0, y1, y2}, respectively, and x is the target point.

“3 PT NEVILLE”
“LIST X”? → List 1
“LIST Y”? → List 2
“X?” → X
{0} → List 3
For 1 → K To 3
If K = 3
Then
(( List 1 – X ) * List 3 + ( X – List 1) * List 3 )
÷ (List 1 – List 1) → A
Else
(( List 1[K+1] – X ) * List 2[K] + (X – List 1[K]) * List 2[K+1] )
÷ (List 1[K+1] – List 1[K] ) → A
IfEnd
Augment(List 3,{A}) → List 3
Next
List 3 → Y
Y

Examples:

Example 1;
List X/List 1 = {16, 64, 100}
List Y/List 2 = {0.25, 0.125, 0.1}
X = 81

Result:  0.1058511078

Example 2:
List X/List 1 = {-2, 0, 2}
List Y/List 2 = {11, 4, 11}
X = 3

Result:  19.75

Sources:

Mitchell, Kevin.  “Neville’s Method”  Simon Fraser University. MACM 316 – Fall 2010.   http://people.math.sfu.ca/~kevmitch/teaching/316-10.09/neville.pdf    Retrieved December 4, 2015

Wikiversity.  “Topic:  Numerical analysis/Neville’s algorithm examples”  https://en.wikiversity.org/wiki/Topic:Numerical_analysis/Neville%27s_algorithm_examples  Retrieved December 4, 2015

This blog is property of Edward Shore.  2015

## Friday, December 4, 2015

### HP Prime: Slopefield (Differential Equations)

HP Prime:  Slopefield (Differential Equations)

Here is a program that graphs the slopefield of a differential equation in the form dy/dx = f(x,y).  This program is adopted from Alan Ziv’s SLPFIELD program, which Ziv programmed for the Casio fx-9850G.  The link to the original program is here:  http://www.spiderpixel.co.uk/caspro/progs/9x50g/slopefield.txt

For the HP Prime version, enter dy/dx in quotes, and use capital letters X and Y.  I recommend that you are in the Function app for this.  The window should be set up before running SLOPEFIELD.

Program SLOPEFIELD

EXPORT SLOPEFIELD(dxy)
BEGIN
// dxy: dx/dy = f′(x,y)
// Adopted from Alan Ziv -
// Casio
// dxy is in quotes
LOCAL X,Y,C,D,J,K,G,H;
LOCAL F,xa,xb,ya,yb,E;

// Use the Function App
RECT();
C:=(Ymax-Ymin)/220;
D:=(Xmax-Xmin)/320;

FOR J FROM 0 TO 50 DO
E:=Xmin+(8*J+3)*D;
FOR K FROM 0 TO 27 DO
F:=Ymin+(8*K+3)*C;

X:=E;
Y:=F;
G:=EXPR(dxy);
H:=2*D;

IF ABS(G)>C/D THEN
H:=2*C/ABS(G);
END;

IF 2*H>D THEN
xa:=E-H; ya:=G*(xa-E)+F;
xb:=E+H; yb:=G*(xb-E)+F;
LINE(xa,ya,xb,yb);
ELSE
LINE(E,F+2*C,E,F-2*C);
END;
END;
END;

// Draw Axis
LINE(Xmin,0,Xmax,0,#C0C0C0h);
LINE(0,Ymin,0,Ymax,#C0C0C0h);
WAIT(0);

END;

Examples: dy/dx = X*^Y^2 + 3*X

This blog is property of Edward Shore.  2015

Eddie

### HP Prime: Gauss-Jordan Elimination Method

HP Prime:  Gauss-Jordan Elimination Method

I received an email requesting some programs of various numerical methods.   One of the methods is the Gauss-Jordan Elimination Method.

Basically, the Gauss-Jordan Elimination Method is a step-by-step method of matrix row operations to reduce a matrix A = [ X | Y ] where X is (mostly) a square component joined by a column vector Y to the form [ I | R ], which I represents an identity matrix portion where the diagonal elements are 1.

You can quickly execute the method by use of the RREF (Reduced Row Echelon Form) function, which is present on many graphing calculators (if not all of them these days).

The HP Prime program GAUSSJORDAN is shows a step by step method.  What the program does is:

1. Take the dimensions of the matrix.
2. Starting with column 1, pivot on element (1,1).  This is accomplished by one of two operations.  SCALEADD which multiplies the first row by a factor and adds it to a target row k.  The goal is reduce the element (k,1) to 0, for all k ≠ 1.
3. Once step 2 is completed, the SCALE command is used to divide the value of element (1,1) to reduce it to 1, if necessary.
4. Repeat steps 2 and 3 for each column until the number the rows is reached.

Notes:

1. HP Prime’s SCALEADD is the *Row+ command for the Casio and TI graphing calculators.  Similarly, HP Prime’s SCALE is the *Row command for the Casio and TI graphing calculators.
2. The program requires that the matrix have all elements that are (1,1), (2,2), (3,3), etc. are non-zero.  Otherwise an error occurs.  You can swap rows by the rowSwap command if necessary to get the matrix in proper form.
3. While the program GAUSSJORDAN shows you step by step, it shows one order of approach, which may or may not be the most efficient number of steps.
4.  If the HP Prime is in Standard mode, you may see 0.9999999999999 or some number to the 10^-13 power.   This is due to the rounding mechanisms.  Feel free to round these numbers to 1 and 0, respectively.

With all this in mind, here is the program:

Program GAUSSJORDAN

EXPORT GAUSSJORDAN(mat)
BEGIN
// Guass-Jordan Elimination
// 2015-12-04
// Matrix MUST have
// mat[k,k]≠0

LOCAL l,r,c,j,k,h,v;
PRINT();

l:=SIZE(mat);
r:=l; c:=l;
j:=1;

// Main row loop
FOR k FROM 1 TO r DO

// Secondary row loop
FOR h FROM 1 TO r DO

// k = target row
// h = test row
// Pivot operation
IF h≠k THEN
v:=−mat[h,k]/mat[k,k];
PRINT();
PRINT("After Step "+j);
PRINT(mat);
WAIT(0);
j:=j+1;
END;

IF mat[k,k]≠1 THEN
v:=1/mat[k,k];
mat:=SCALE(mat,v,k);
PRINT();
PRINT("After Step "+j);
PRINT(mat);
WAIT(0);
j:=j+1;
END;

END;
END;

PRINT();
PRINT("Result:");
PRINT(mat);

// Final WAIT not needed

RETURN mat;

END;

Examples:

M2 = [[1,2,4,1] [3, -3, 3, 0] [6, 6, 8, 5]]
Final Result* (see Note 4) of GAUSSJORDAN(M2):
[[1,0,0,0.53333333333]. [0,1,0,0.43333333333], [0,0,1,-0.1]]

M3 = [[0,4,-1,-1], [2,5,2,2], [3,3,6,3]].
Running GAUSSJORDAN(M3) with M3 as is will get an error.  Why?  See M3[1,1] = 0.  We must make it non-zero.  Do this by swapping rows.
M3≔rowSwap(M3,1,2) to make the matrix [[2,5,2,2], [0,4,-1,-1], [3,3,6,3]].  Now you are ready to go.
GAUSSJORDAN(M3) returns [[1,0,0,2.6], [0,1,0,-0.4], [0,0,1,-0.6]]

Thank you Luis for the email and the suggestions.

Source:  Cazelais, Gilles. “Gauss-Jordan Elimination Method”  http://pages.pacificcoast.net/~cazelais/251/gauss-jordan.pdf  Retrieved December 4, 2015

Until next time, stay safe everyone because it is a crazy planet we live on.

Eddie

## Sunday, November 29, 2015

### HP Prime: Approximate Length of Daylight

I hope you had a great weekend and a great Thanksgiving.  For those of you in the United States, hopefully Friday was peaceful and not crazy.

HP Prime: Approximating the Length of Daylight in Hours

This time, we are taking a slightly more complex formula.   The inputs are:

lat = Earth's latitude of the observer.  (from -90° (South) to 90° (North))

day = the number of days since the December solstice (around December 21-22).  Note that is different from many approximate formulas which used the vernal equinox as a starting point.

The formula used is a simplification of the Final Formula presented by Herbert Glarner (http://www.gandraxa.com/).  For the complete article and the derivation, please click on link:

http://www.gandraxa.com/length_of_day.xml    (Retrieved November 23, 2015)

The algorithm used in the DAYLIGHT is:

With the inputs lat and day:

m = 1 – tan(lat°) * tan(23.439° * cos(480/487 * day))

If m > 2, let m = 2.   If m < 0, let m = 0.

Then:

b = acos(1 – m)/180 *24

Where b is the length of daylight in hours.

I adjusted the formula to allow for all inputs to be in degrees.  Glamer had mixed inputs for the trigonometric functions.

Here is the program:

Program DAYLIGHT:

EXPORT DAYLIGHT(lat,day)
BEGIN
// latitude, days from
// December solstice
LOCAL m,b,a:=HAngle;
HAngle:=1; // Degrees
m:=1-TAN(lat)*TAN(23.439*COS(
480/487*day));
IF m<0 THEN
m:=0;
END;
IF m>2 THEN
m:=2;
END;
b:=ACOS(1-m)/180*24; // hours
RETURN b;
HAngle:=a;
// www.grandraxa.com
END;

Examples:

Let’s assume a 365 day and the December solstice was December 22.

Latitude:  -60°, March 1  (day = 69)
Result:  Approx. 16.67808 hours

Latitude: 54°,  July 24  (day = 214)
Result:  Approx. 16.03426 hours

For another approximate formula, I wrote on one for the HP 35S here:  http://edspi31415.blogspot.com/2013/05/hp-35s-approximate-length-of-sunlight.html

Have a great day,

Eddie

This blog is property of Edward Shore.  2015

## Wednesday, November 18, 2015

### Quick Tips for the Casio fx-115ES Plus and fx-991EX Classwiz

Quick Tips for the Casio fx-115ES Plus and fx-991EX Classwiz

This applies to other similar and earlier Casio calculators.   Please consult your manual if you have a different model.   This refers to Casio models that have textbook entry and output, such as the fx-115ES (Plus), fx-991ES (Plus), fx-991EX Classwiz, and fx-570EX Classwiz.

In the Math input mode, the Casio attempts to return an exact answer (fractions, terms of π, terms of square roots).  If you want to get an approximate answer from the get go, all that is needed is to press [SHIFT], [ = ] (≈).

Using a Formula

Steps:

2.  Press [CALC].
3.  Enter a value for each variable prompted, then press [ = ].
4.  For the Classwiz models:  You can scroll up and down between variables.

Example:

(A^2 + B^2)^(1/3)

A = 3, B = 4, result 2.924017738
A = 5, B = 10, result 5

Solve f(X) = 0

Steps:

1.  Enter f(X).  On the Classwiz series, you can use the [ x ] button.  There is no need to enter the “=0”.

2.  Press [SHIFT], [ CALC ] (SOLVE)

3.  Enter a guess and press [ = ].

Example:

X sin(X) – 1 with guess X = π, result:  X = 2.772604708

Tip:  I prefer to use X, but you should be able to use any of the other variables available (A, B, C, D, E*, F*, Y, M).  *E and F are available on later models.

Solve f(X) = g(X)

Steps:

1.  Enter f(X).  On the Classwiz series, you can use the [ x ] button.

2.  Press [ALPHA], [CALC] ( = ) for the equals symbol.  This is very important.   Then enter g(X).

3.  Press [SHIFT], [ CALC ] (SOLVE)

4.  Enter a guess and press [ = ] (the equals key).

Example:

ln(X) = X^2 – 2 with guess X = 1, result X = 1.564462259

Unit Conversion

1.  Enter a number that is needed to be converted.

2.  Depending on what version for Casio you have:

For the fx-991EX Classwiz (I think this applies to the fx-570EX Classwiz as well):  Press [SHIFT] [ 8 ] (CONV).  Select a category and select a conversion.

For the fx-115ES PLUS and earlier models (non-Classwiz models):  Press [SHIFT] [ 8 ] (CONV) and enter a code.  For the fx-115ES PLUS, the conversions are listed both in the manual and the hard slide on case.

Here is a sample of the conversions offered on the fx-115ES PLUS:

 01 in → cm 19 km/h → m/s 35 lbf/in^2 → kPa 02 cm → in 20 m/s → km/h 36 kPa → lb/in^2 07 mi → km 21 oz → g 37 °F → °C 08 km → mi 22 g → oz 38 °C → °F 23 lb → kg 24 kg → lb

3.  Press [ = ].

Please be aware the older models may not have the conversion function.

Factoring an Integer

‘1.  Enter an integer then press [ = ].

‘2.  Press [SHIFT], [ ° ‘ ‘’ ] (FACT)

Examples:

188 = 2^2 * 47

2506 = 2 * 7 * 179

Please be aware the older models may not have the factoring function.

Calculus

Remember for derivative (d/dx), integral ( ∫ ), sum ( Σ ), and product ( Π )*, the variable used is X.  *Product may not be available on all models.

Inverse and Determinant of a Matrix

For these calculators, matrices are a separate mode.  I assume that you know how to edit and define matrices.

Casio fx-115 ES Plus and Non-Classwiz Modes that have a Matrix mode:

Matrices are mode 6 (at least for the fx-115EX Plus.)

Inverse:

[SHIFT] [ 4 ] (MATRIX), choose 3, 4, or 5 for Matrix A, B, or C respectively, [ x^-1 ], [ = ].

Determinant:

[SHIFT] [ 4 ] (MATRIX), 7 for det, [SHIFT] [ 4 ] (MATRIX), choose 3, 4, or 5 for Matrix A, B, or C respectively, [ = ].

Casio fx-991EX Classwiz and other Classwiz models:

Matrices are mode 4 (matrix icon).

Inverse:

[OPTN], choose 3, 4, 5, or 6 for Matrix A, B, C, or D respectively, [ x^-1 ], [ = ]

Determinant:

[OPTN], [ down ], 2 for det, [OPTN], choose 3, 4, 5, or 6 for Matrix A, B, C, or D respectively, [ = ].

Hope you find these tips helpful.  Have a great day!

Eddie

This blog is property of Edward Shore.  2015.

### HP 32S II Statistical Formulas

HP 32S II Statistical Formulas Statistics Formulas The 32S II can store formulas for evaluations, including formulas involving stat variable...