## Sunday, September 29, 2019

### fx-260 Solar Algorithms Part II

fx-260 Solar Algorithms Part II

Decimal to Binary Conversions

This is probably best demonstrated by example.

Algorithm:

To the decimal integer D to binary integer B:

1.  Determine the number of digits (zeroes or ones) that the binary integer is going to have.  Also, we'll store D in memory.

n = int(log D/log 2)

Each digit will represent the powers 2^(n) to 2^0.

Keystrokes: D [SHIFT] (Min) [ log ] [ ÷ ] 2 [ log ] [ = ]  // ignore the decimal part

2.  Starting with n and going to 0, calculate 2^n.  Compare 2^n to the number in memory.

If 2^n ≤ Memory, then write a 1.  Subtract 2^n from memory:  2^n [ +/- ] [M+].  Decrease n by 1 and continue.

If 2^n > Memory, then write a 0.  Decrease n by 1 and continue.

Each digit will be written to the right of the preceding digit.

Example:  Convert 462 to binary.

Determine n:
462 [SHIFT] (Min) [ log ] [ ÷ ] 2 [ log ] [ = ]
Result:  8.851749041

In M:  462  (n = 8)
2 [ x^y ] 8 [ = ] 256,  256 ≤ 462,  [+/-] [ M+ ]   // first digit is 1
Binary:   1________

In M:  206 (n = 7)
2 [ x^y ] 7 [ = ] 128,  128 ≤ 206,  [+/-] [ M+ ]  // next digit is 1
Binary:   11_______

In M:  78 (n = 6)
2 [ x^y ] 6 [ = ] 64,  64 ≤ 78,  [+/-] [ M+ ]  // next digit is 1
Binary:   111______

In M:  14  (n = 5)
2 [ x^y ] 5 [ = ] 32,  32 > 14  // next digit is 0
Binary:   1110_____

In M:  14  (n = 4)
2 [ x^y ] 4 [ = ] 16,  16 > 14  // next digit is 0
Binary:   11100____

In M:  14  (n = 3)
2 [ x^y ] 3 [ = ] 8,  8 ≤ 14,  [+/-] [ M+ ]  // next digit is 1
Binary:   1110001___

In M:  6  (n = 2)
2 [ x^y ] 2 [ = ] 4,  4 ≤ 6,  [+/-] [ M+ ]  // next digit is 1
Binary:   11100011__

In M:  2  (n = 1)
2 [ x^y ] 1 [ = ] 2,  2 ≤ 2,  [+/-] [ M+ ]  // next digit is 1
Binary:   111000111_

In M:  2  (n = 0)
2 [ x^y ] 01 [ = ] 1,  1 > 0  // last digit is 0
Binary:   1110001110

Result:  462_10 = 1110001110_2

Combinations that Allow for Repeated Picks

Sometimes when we are choosing r objects out of a group of n objects, repeated picks are allowed.  That is, any object that is picked is put back in the pool and has a chance to be picked again.  The formula to calculate such calculations is:

nHr = (n + r - 1)! / (r! * (n - 1)!)

We can state nHr in terms of nCr (number of combinations where no repeats are allowed).

aCb = a! / (b! * (a - b)!)
Let a = n + r - 1 and b = n - 1.
Then a - b = n + r - 1 - (r - 1) = r

Then:
nHr = (n + r -1)C(n - 1)

Algorithm:
[ ( ] n [ + ] r [ - ] 1 [ ) ] [SHIFT] (nCr) [ ( ] n [ - ] 1 [ ) ] [ = ]

Example:
Find the number of combinations of picking 10 objects out of the pool of 38, where repeats are allowed.

n = 38, r = 10

[ ( ] 38 [ + ] 10 [ - ] 1 [ ) ] [SHIFT] (nCr) [ ( ] 38 [ - ] 1 [ ) ] [ = ]

Result: 5,178,066,751

Harmonic Mean of Numbers

The harmonic mean of a set of n numbers is calculated by:
HM = n / Σ(1 / x_i)

We can use the Statistics mode to calculate the harmonic mean.

Algorithm:
[ON]  // clear everything and reset calculator to COMP mode
[MODE] 0  // Mode 0 is SD mode (single data, standard deviation)
x_i [SHIFT] (1/x) [M+](DATA)
....
[SHIFT] (n) [ × ] [SHIFT] (Σx) [ = ]

Example:
Data:  3.8, 4.6, 5.9, 7.1, 7.6, 9.0  (n = 6)

[ON]
[MODE] 0
3.8 [SHIFT] (1/x) [M+](DATA)
4.6 [SHIFT] (1/x) [M+](DATA)
5.9 [SHIFT] (1/x) [M+](DATA)
7.1 [SHIFT] (1/x) [M+](DATA)
7.6 [SHIFT] (1/x) [M+](DATA)
9.0 [SHIFT] (1/x) [M+](DATA)
[SHIFT] (n) [ × ] [SHIFT] (Σx) [ = ]

Result:  6.20145512

Atwood Machine

Given the masses of two weights (in kg) on an Atwood Machine, the following system describes the relationship between the masses, tension, and acceleration of the system:

T + M1 * a = M1 * g
T - M2 * a = M2 * g

where:
T = tension of the system (N)
a = acceleration, positive means the pulley rotates counter-clockwise; negative means the pulley rotates clockwise (m/s^2)
g = Earth's gravity constant, 9.80665 m/s^2

Assumptions:
1.  The mass of both the pulley and the string are negligent
2.  Mass 1 is on the left side of the pulley while Mass 2 is on the right.

Solving for T and a give:
a = (M1 - M2) * g / (M1 + M2)
T = M1 * (g - a) = M2 (g + a)

Algorithm:
[ ( ] M1 [ - ] M2 [ ) ] [ × ] 9.80665 [ ÷ ] [ ( ] M1 [ + ] M2 [ ) ] [ = ]
// acceleration is displayed

[ +/- ] [ + ] 9.80665 [ = ] [ × ] M1 [ = ]
// tension is displayed

Example:
M1 = 18 kg, M2 = 12 kg

[ ( ] 18 [ - ] 12 [ ) ] [ × ] 9.80665 [ ÷ ] [ ( ] 18 [ + ] 12 [ ) ] [ = ]
Acceleration: 1.96133 m/s^2  (pulley is rotating counter-clockwise)

[ +/- ] [ + ] 9.80665 [ = ] [ × ] 18 [ = ]
Tension:  141.21576 N

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.

## Saturday, September 28, 2019

### HHC 2019: The Videos (Eric Rechlin) and Commentary

HHC 2019:  The Videos (Eric Rechlin) and Commentary

My favorite time of the year:  HHC (HP Handheld Conference) 2019, which took place in Reno, Nevada on September 21 and 22, 2019.

I was blessed to be able to go this year, it's always good to meet with close friends again.

The conference was all about classic RPN calculators, primarily the HP 41C, Swiss Micros DM41, HP 42S, and Swiss Micros DM42.    The DM42 is becoming my preferred calculator.

Thanks to both Eric Rechlin and Jake Schwartz for the videos and editing.

Cubic Chess - Jeremy Smith

Want to have a chess board everywhere you are but you are not a fan of how much space the board takes?   Cubic chess solves this problems by putting all the chess pieces, from rook to queen to king, in a form of a cube.  Cubic chess was first created by Graham Lanier in 1966.

Shop Projects Update - Jim Donnelly Cubic Chess set - Jim Donnelly

Jim Donnelly updates us on his latest projects:  a cubic chess set, harmonic transformer, a beautiful cometarium, Genaille-Lucas Rulers, and Napier's bones. Cometarium - Jim Donnelly (also in the pic:  HP 12C (cut-off), HP 32S, HP Prime G2, DM42)

A cometarium is a classic mechanical device that calculates the position of celestial objects, such as Halley's Comet and the Moon, depending on the time of year.   Genaille-Lucas Rulers are a set of rules, created in the turn of the 20th century, as a device to aid in multiplication and division.  Those rules confused me.

SwissMicros DM41X Announcment - Bob Propseri

The next product to come from Swiss Micros is the DM41X, a four line calculator that runs HP 41C hardware.  Features include USB storage and saving calculator states.  All 41C software and mods will run on the DM41X.  The calculator is set to be released in early 2020.

Newton Method Interpolations - Namir Shammas

Shammas introduces a Newton's Method that uses a modified central difference method to calculate the derivative.

Overview of the WP 34C - Günter Schink

Adopting a Swiss Micros DM42 machine to run WP 34C software.

My Role as an Archivist; or, What's on the HHC USB Drives

One benefit of attending of an HHC conference is that you get a USB drive that is full of documents, manuals, and articles involving calculators, primarily Hewlett Packard, but other brands get some coverage.

You can order a HHC 2019 USB drive from hpcalc.org here - cost is \$40 US dollars:  https://commerce.hpcalc.org/hhcusb.php

What's New in the PPC Archive DVD - Jake Schwartz

New additions to the PPC DVD, which are included in the 2019 USB drive mentioned above.

Percent Change, Logarithms, and their Interpolation - Richard Schwatz

Schwartz introduces a new approach to calculating percent change.

Impromptu Report from Across the Pond - Bruce Horrocks

Multi Variable Solver - Namir Shammas

Shammas presents how you use vectors or arrays to aid in solving equations where you can solve for any variable.

The Nature of Time - David Ramsey Bulova Accutron watch (1960) - David Rasmey

Ramsey has a beautiful presentation of the history of time making devices, including sundials, Egyptian water clocks, fusee, and super expensive and exquisite chronometers.

Graphics on the DM42 - Jim Johnson

Johnson presents how to generate graphics on the Swiss Micros DM42 (and by extension, HP 42S).  The DM42 has three sizes for graphics output.

Percentages on the 48 - Richard Nelson

A technique on how to work with percentages on the HP 48S/48G family.  This is one of the few talks the focus is on other calculators.

RIP HP Calcs - Richard Nelson

USB Power - Richard Nelson

How to measure current and voltage with a USB powered device.

Woodstock Low Power and ConnKit - Bob Prosperi

The kit that will update the classic HP Woodstock series from the 1970s (HP-21, HP-22, HP-25, HP-27, HP-29).

The Financial Calculators (via Skype) - Gene Wright

Think that all the financial calculators came from Hewlett Packard and Texas Instruments?  Nope!  Wright presents the history of the financial calculators during the 1970s.  There is one particular model that gets repeated cloned by many companies, see if you can spot it.

Scout Evolutionary Optimization Method - Namir Shammas

The Scout Evolutionary Optimization method aims to find global optimum (extrema, minimums and maximums) of a function.

DIY Calculators - Joey Shepard

Shepard, while saving up to purchase an HP 48, turned his Casio Algebra FX 2.0+ into an RPN programmable calculator.  Shepard also presents two small RPN calculators he created.  He is the HHC 2019 Best Speaker.

Aural Clocks and Big Ben on the 48 - Tom Chrapkiewicz

Chrapkiewicz continues his HHC 2018 talk, this year he shows how to use the HP 48G as a clock which beeps every five minutes.

The HP 39G/49G Overhead Projector - Bruce Horrocks

Horrocks chronicles on his journey of fixing the projector for the HP 48SX and HP 39g/49g.

On a side note:  I saw projector for the TI-82 and TI-83 Plus at a local Christian thrift store, but I didn't buy one.

HHC 2019: Programming Contest Winners

The contest:  find all four 3-digit numbers where the cube of its digits are equal to the number itself.  Example:  153 is one of the four because:

1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153

Check out some of the community's solutions here (starts on page 2 of the thread):

Door Prizes

The big door prize was an HP-75C.  The HP 75C was a large BASIC computer that was sold in the mid 1980s.  The intial memory was 16,000 bytes which could be extended, with a ROM card, to 48,000 bytes.  More information can be found here:  https://www.hpmuseum.org/hp75.htm

As for me, I won some much needed calculator cases.  There were a lot of books, of various subjects, and a few calculators that were up for grabs.

That weekend went by so darn fast!

By the way, I recommend the Redwood Rotisserie + Grill in Reno.  The food is so good!

My Quick thoughts on the future of Hewlett Packard Calculators

There was no talk about the HP Prime this year.  Hewlett Packard is slowing down when it comes to calculator production.  Sad to say that there is almost no new development for the HP Prime, nor any development for future scientific calculators.

I don't think HP is going away completely, but as far as calculators, the focus will be on its finance models (primarily the 12C, 10BII+, and 17BII+).

The future on these conference is going to depend on independent developers such as Joey Shepard, Swiss Micros, and everyone who develops emulators, Olivier De Smet comes to mind, for smartphones and tablets.  I am encouraged that there is an enthusiasm for mathematics, calculators, and other calculating devices.

The HHC 2019 conference web site is here:  https://hhuc.us/2019/index.htm.  Keep an eye out for the HHC 2020 conference, probably around late winter of next year.

Happy Calculating,

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.

### fx-260 Solar Algorithms Part I

fx-260 Solar Algorithms Part I

All results are shown to screen accuracy.

Sphere:  Surface Area and Volume

the surface area is S = 4 * π * r^2
the volume area is V = 4/3 * π * r^3

Algorithm:
r  [SHIFT] (Min) [ x² ] [ × ] [EXP](π) [ × ] 4 [ = ]    // surface area is displayed
[ × ] [ MR ] [ ÷ ] 3 [ = ]   // area is displayed

M = r

Example:
Input:
r = 3.86

Results:
3.86  [SHIFT] (Min) [ x² ] [ × ] [EXP](π) [ × ] 4 [ = ]
Surface Area = 187.2338956

[ × ] [ MR ] [ ÷ ] 3 [ = ]
Volume = 204.9076123

Monthly Payment of a Mortgage or Auto Loan

Input:
A = amount of the mortgage/loan
I = annual interest rate
N = number of months

The monthly payment can be found by:
PMT = ( 1 - (1 + I/1200)^-N) / (I/1200)

Algorithm:
I [ ÷ ] 1200 [ = ] [SHIFT] (Min)   // stores I/1200 into M
1 [ - ] [ ( ] 1 [ + ] [ MR ] [ ) ] [ x^y ] N [ +/- ] [ = ]
[SHIFT] (1/x) [ × ] [ MR ] [ × ] A [ = ]     // monthly payment

Example:
Input:
I = 4  (4%)
N = 360
A = 85000

Result:
4 [ ÷ ] 1200 [ = ] [SHIFT] (Min)   // stores I/1200 into M
1 [ - ] [ ( ] 1 [ + ] [ MR ] [ ) ] [ x^y ] 360 [ +/- ] [ = ]
[SHIFT] (1/x) [ × ] [ MR ] [ × ] 85000 [ = ]     // monthly payment

PMT = 405.8030014   (\$405.80)
(I/1200 = M = 3.333333333E-03)

Electromagnetic Field Strength

Given the EIRP (effective isotropic radiated power) of a microwave (in Watts), we can calculate the following:

Power Flux Density:
S = EIRP / (4 * π * d^2)   (W/m^2,  d = distance from the wave source in meters)

Electric Field:
E = √(30 * EIRP) /  d   (W/m)

Magnetic Field:
H = √(EIRP / (480 * π^2 * d^2) )  (A/m)

Algorithm:

Calculating Power Flux:
EIRP [ ÷ ] [ ( ] 4 [ × ] [EXP](π) [ × ]  d [ x² ] [ ) ] [ = ]

Calculating Electric Field:
[ ( ] EIRP [ × ] 30 [ ) ] [SHIFT] (√) [ ÷ ] 0.5 [ = ]

Calculating Magnetic Field:
[ ( ] EIRP [ ÷ ] [ ( ] 480 [ × ] [EXP](π) [ x² ] [ × ] d [ x² ] [ ) ] [ ) ] [ √ ] [ = ]

Example:
Input:
EIRP = 1800 W
d =  0.5 m   (distance)

Results:

Calculating Power Flux:
1800 [ ÷ ] [ ( ] 4 [ × ] [EXP](π) [ × ]  0.5 [ x² ] [ ) ] [ = ]
Power Flux: 572.9577951 W/m^2

Calculating Electric Field:
[ ( ] 1800 [ × ] 30 [ ) ] [SHIFT] (√) [ ÷ ] 0.5 [ = ]
Electric Field: 464.7580015 W/m

Calculating Magnetic Field:
[ ( ] 1800 [ ÷ ] [ ( ] 480 [ × ] [EXP](π) [ x² ] [ × ] 0.5  [ x² ] [ ) ] [ ) ] [ √ ] [ = ]
Magnetic Field: 1.232808888 A/m

Source:  Barue, Gerardo.  Microwave Engineering: Land & Space Radiocommunications John Wiley & Sons, Inc.  Hoboken, NJ  ISBN 978-0-470-08966-5 2008

Slope and Intercept with Two Points

Given two points of a line (x1, y1) and (x2, y2) we can find the slope (a) and y-intercept (b) of the general linear equation y = a*x + b.

The trick is to use the rectangular to polar conversion to find the slope:
θ = atan((y2 - y1)/(x2 -x1))
tan θ = (y2 - y1)/(x2 -x1) = slope = a

Once the slope is found, we can solve for the y-intercept:
y = a*x + b
b = y - a*x

Algorithm:
[ ( ] x1 [ - ] x2 [ ) ] [SHIFT] (R→P) [ ( ] y1 [ - ] y2 [ ) ] [ = ] [SHIFT] (X<>Y) [ tan ]
// slope is displayed

[ × ] x1* [ +/- ] [ + ] y1* [ = ]
// intercept is displayed

*x2 and y2 can be used instead

Example:
(x1, y1) = (8, 5.5)
(x2, y2) = (4, 9.5)

Result:
[ ( ] 8 [ - ] 4 [ ) ] [SHIFT] (R→P) [ ( ] 5.5 [ - ] 9.5 [ ) ] [ = ] [SHIFT] (X<>Y) [ tan ]

Slope: -1

[ × ] 8 [ +/- ] [ + ] 5.5 [ = ]

Slope: 13.5

Tomorrow will be Part II.

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, September 26, 2019

### Retro Review: Texas Instruments TI-66

Retro Review:  Texas Instruments TI-66

Quick Facts

Company:  Texas Instruments
Years in Production: 1982 to 1985
Original Price: I estimate the original price to be from \$70 to \$100
Battery:  2 x LR44 or 2 x AR76
Type:  Scientific, Keystroke Programmable
Operating System: AOS
Number of Digits: 10
Memory:  512 steps, which can be allocated to a maximum of 64 memory registers
Accessories: Carrying Case, PC-200 Printer

I paid \$7.99 at a Goodwill in Cerritos, CA.  The calculator came with the carrying case, User Guide, and Quick Start Guide, all boxed up.  What a lucky find!

The Next Generation of TI-58C

The TI-66 was slated to be the next generation of the TI-58C of 1978.  Virtually the keyboard design and commands of the TI-58C are present in the TI-66, but there are some differences:

*  The TI-66 is an landscape form with a gray keyboard, where as the TI-58C (and the related TI-58 and TI-59 has a black keyboard).

*  The TI-66 lacks a card reader.

*  The TI-66 also lacked a slot for modules.

*  However, the TI-66 runs on coin batteries (AR76 or LR44), which can be found easily.  The TI-58C family had rechargeable battery packs, which cannot be easily purchased (few vendors sell them online).

*  In learn mode, when a step is registered, the TI-66 displays the key you just pressed with its mnemonic.

Programming With The TI-66

Keystroke programming is fairly simple with the TI-66.  As I mentioned before, the TI-66 displays a mnemonic when a key stroke is registered (think HP 42S, HP 41C, or HP 32SII).  Examples are:

[ x^2 ] displays x↑2
[ π ] displays PI
[ Σ+ ] displays Σ+
[ √x ] displays √x

However, when it comes to programming the TI-66, patience is key!  The TI-66 takes on average, 1.5 seconds to register a new keystroke in learn (LRN) mode.  This is not for the speedy programmers among us.  This is my down point about the calculator, but it is not a deal breaker.

Other Programming Features

*  User labels A, B, C, D, and E; along A', B', C', D', and E'.  There are five keys dedicated to user labels.

*  Local labels have an unusual scheme.  They are defined by (almost) any key that is not a numeric key.  Therefore, we have labels such as 1/x, sin, and ÷.   This is carries over from the 1970s TI programmables (TI-57, TI-58, TI-58C, and TI-59).

* 10 user flags: 0-9.

*  Storage arithmetic:  SUM (STO+), INV SUM (STO-), Prd (STO*), INV Prd (STO÷)

*  Comparisons:  compare the value in the display with register t.  Store amounts in register t with [ x<> t ].  Example:  a [ x<>t ] b [ 2nd ] (x≥t) tests whether b ≥ a).

A Partial List of OP Commands

OP 01 - 08 deal with printing, while 09 is not a valid code.

OP 10:  sign(x)
OP 11:  variance(x), variance(y)
OP 12:  slope, intercept  (linear regression)
OP 13:  correlation (linear regression)
OP 14:  x'  (predict x, linear regression)
OP 15:  y' (predict y, linear regression)

OP 2#:  increase register R0# (0-9) by 1
OP 3#:  decrease register R0# (0-9) by 1

Keyboard

Other than registering new programming commands, the keys are immediately responsive.  The keys are nice to the touch.

Verdict

I would recommend the TI-66, especially if you want a TI-58, TI-58C, or TI-59, but don't want to deal with 1970s rechargeable batteries, or you are on a budget.  It is a very nice, feature rich calculator to have.

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.

## Sunday, September 22, 2019

### The Error Function and Normal Distribution: Norm(x) and Erf(x)

The Error Function and Normal Distribution:  Norm(x) and Erf(x)

Introduction

The error function is defined as:

erf(x) = 2/√π * ∫( e^(-t^2) dt, 0, x)

norm(x) = 1/√(2*π) * ∫( e^(-z^2/2) dx, -∞, x)

We were assuming that the mean μ = 0 and variance σ = 1.

Derivation:  norm(x) in terms of erf(x)

norm(x)

= 1/√(2*π) * ∫( e^(-z^2/2) dx, -∞, x)

= 1/√(2*π) * ∫( e^(-z^2/2) dx, -∞, 0) + 1/√(2*π) * ∫( e^(-z^2/2) dx, 0, x)

= 1/2 + 1/√(2*π) * ∫( e^(-z^2/2) dx, 0, x)

-----------------------------
Substitution:

t^2 = z^2/2
t = z/√2
√2 * t = z
√2 dt = dz

z = 0,  t = 0
z = x,  t = x/√2
-----------------------------

= 1/2 + 1/√(2*π) * ∫( e^(-z^2/2) dx, 0, x)

= 1/2 + 1/√(2*π) * ∫(√2 *  e^(-t^2) dt, 0, x/√2)

= 1/2 + 1/√π * √π/2 * 2/√π * ∫(√2 *  e^(-t^2) dt, 0, x/√2)

= 1/2 + (1/√π * √π/2) * (2/√π * ∫(√2 *  e^(-t^2) dt, 0, x/√2))

= 1/2 + 1/2 * 2/√π * ∫(√2 *  e^(-t^2) dt, 0, x/√2)

= 1/2 + 1/2 *erf(x/√2)

norm(x) = 1/2 + 1/2 *erf(x/√2)

norm(x) - 1/2 = 1/2 *erf(x/√2)

2 norm(x) - 1 = erf(x/√2)

Let t = x/√2, then:

2 norm(√2 * t) - 1 = erf(t)

Summary

norm(x) = 1/2 + 1/2 * erf(x/√2)

erf(t) = 2 * norm(√2 * t) - 1

with μ = 0 and σ = 1.

Examples

norm(1) = 1/2 + 1/2 * erf(1/√2) ≈ 0.841344746069

erf(1) = 2 * norm(√2) - 1 ≈ 0.84270079295

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.

## Saturday, September 21, 2019

### Casio fx-CG50 and TI-84 Plus CE: Multilinear Regression with Correlation

Casio fx-CG50 and TI-84 Plus CE: Multilinear Regression with Correlation

Introduction

The program MULT2LIN calculates multiple linear regression with 2 independent variables x_1 and x_2 and correlation of the data.  The data will be used to fit the plane:

y = b + a_1 * x_1 + a_2 * x_2

by least squares.

The correlation is a calculated by:

R = √(( Y^2 + Z^2 - 2 * X * Y * Z) / (1 - X^2))

where:

Y = correlation between x_1 and y
Z = correlation between x_2 and y
X = correlation between x_1 and x_2

The general correlation between two variables (x,y) is calculated by:

r = ( n * Σxy - Σx * Σy ) / √( (n * Σx^2 - (Σx)^2) - (n * Σy^2 - (Σy)^2) )

Casio fx-CG 50 Program MULT2LIN

This is the text version (MULT2LIN.txt)

'ProgramMode:RUN
"EWS 2019-08-07"
"MULTILINEAR"
"REGRESSION"
"LIST X1: "?->List 2
"LIST X2: "?->List 3
"LIST Y: "?->List 1

If Dim List 1<>Dim List 2 Or Dim List 1<>Dim List 3
Then
"UNEQUAL LENGTH"DispsStop
IfEnd

LinearReg(a+bx) List 2,List 1
Regression_r->Y
LinearReg(a+bx) List 3,List 1
Regression_r->Z
LinearReg(a+bx) List 2,List 3
Regression_r->X
Sqrt((Y^<2>+Z^<2>-2*X*Y*Z)/(1-X^<2>))->R
"CORRELATION: "RDisps
Dim List 1->Dim List 4
Fill(1,List 4)
List->Mat(List 4,List 2,List 3)->Mat X
List->Mat(List 1)->Mat Y
(Trn Mat X*Mat X)^<-1>*Trn Mat X*Mat Y->Mat B
"_Mat _B:"DispsMat B

Notes:

<>  is ≠

Disps is ⊿

Sqrt is √

Regression_r can be found by [ VARS ] , (STAT), (GRAPH), ( > ), ( r ).   The character r is in bold font.

fx-CG 50 syntax:

LinearReg(a+bx) y data, x data

List->Mat(column list, column list, ... )

This is what it would look like on the calculator:

"MULTILINEAR"
"REGRESSION"
"LIST X1: "?->List 2
"LIST X2: "?->List 3
"LIST Y: "?->List 1

If Dim List 1 ≠ Dim List 2 Or Dim List 1 ≠ Dim List 3
Then
"UNEQUAL LENGTH"⊿
Stop
IfEnd

LinearReg(a+bx) List 2,List 1
r->Y
LinearReg(a+bx) List 3,List 1
r->Z
LinearReg(a+bx) List 2,List 3
r->X
√((Y²+Z²-2*X*Y*Z)/(1-X²))->R
"CORRELATION: " ⊿
Dim List 1->Dim List 4
Fill(1,List 4)
List->Mat(List 4,List 2,List 3)->Mat X
List->Mat(List 1)->Mat Y
(Trn Mat X*Mat X)⁻¹*Trn Mat X*Mat Y->Mat B
"_Mat _B:"⊿
Mat B

TI-84 Plus CE Program MULT2LIN

* Can be used on all of the TI-84 and TI-83 family
* This program needs to be typed in

"EWS 2019-08-07"
Disp "MULTLINEAR",
"REGRESSION"
Input "LIST X1: ", L1
Input "LIST X2: ", L2
Input "LIST Y: ", L3
If (dim(L1) ≠ dim(L2)) or (dim(L1) ≠ dim(L3))
Then
Disp "UNEQUAL LENGTH"
Stop
End
LinReg(ax+b) L1, L3
r → Y
LinReg(ax+b) L2, L3
r → Z
LinReg(ax+b) L1, L2
r → X
√( ( Y² + Z² - 2*X*Y*Z ) / (1 - X²) ) → R
Disp "CORRELATION:"
Pause R
dim(L1) → dim(L4)
Fill(1, L4)
List>matr(L4,L1,L2,[A])
List>matr(L3,[C])
([A]^T * [A])⁻¹ * [A]^T * [C] → [B]
Disp "[B] ="
Pause [B]

Notes:

^T is the transpose

TI-84 Syntax:

LinReg(ax+b) x list, y list

List>Mat(column list, column list, column list, .... , matrix)

The output of MULT2LIN

R: correlation of the mutilinear data

A 3 x 1 matrix that represents the coefficients for  b + a_1 * x_1 + a_2 * x_2:

[ [ b ]
[ a_1 ]
[ a_2 ] ]

Example

A hiring firm collects data on six potential employees based on the criteria:

* Number of years of education (12 = High School Graduate, 16 = 4-Year Degree, 18 = Masters Degree, 20 = Ph.D)
* Number of years of work experience, including part-time and full-time
* Starting salary at a professional firm

Are education and work experience factors to predicting starting salary?  Data from 7 employees are taken below:

X1 Data: {12, 12, 14, 16, 15, 18, 20}
X2 Data: {0.5, 2, 1.5, 2, 3, 3.5, 5}
Y Data: {30000, 35000, 35000, 50000, 52000, 64000, 100000}

Results:

Correlation:  R = 0.9650583083

Coefficient Matrix:
[ [ -24932.24299 ]
[ 3539.719626 ]
[ 9042.056075 ] ]

The estimate equation is:
y = -24932.24299 + 3539.719626 * x1 + 9042.056075 * x2
x1 = Number of years of education
x2 = Number of years of work experience

Source:

Higgins, Jim Ed. D.  "Chapter 4: Introduction to Multiple Regression" Excerpt from the Radical Statistician 2005.  http://www.biddle.com/documents/bcg_comp_chapter4.pdf  Retrieved August 6, 2019

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.

## Sunday, September 15, 2019

### Retro Review: Radio Shack EC-2024

Quick Facts

Years in Production: Around 1994
Original Price: \$24.99
Battery:  Solar with Battery backup  (RS 389A)
Type:  Desktop- Fold-able
Number of Digits: 10

Initial cost and year came from the CALCUSUEM web site:  http://www.calcuseum.com/SCRAPBOOK/BONUS/46394/1.htm  (retrieved August 4, 2019)

I paid \$3 for this at a swap meet.

Keyboard

The some of the keys are larger than the others.  The plus key has an L-shape, while the minus key is large, and the equals key, labeled the "ANSWER BAR".

The keyboard is alright.  If you type at a reasonable pace, the keys are responsive.  If you are speed typist, prepare to be disappointed.

The EC-2024 works best when the calculator is under full light.

Settings

There are two settings switches:

Rounding:  always round up, always round down, or 5/4 (use the general rounding rules)

Decimal Setting:  float, 0 decimal places, 2 decimal places, 3 decimal places, or add mode.  In add mode, every number that is added or subtracted is automatically divided by 100.  This allows for rapid entry of dollars and cents without having to enter the decimal point.

The Δ% Key

How the percent key [ Δ% ] depends on what arithmetic operation is used with it.

x [ + ] y [ Δ%] returns (x + y)/y * 100%

Example:  250 [ + ] 300 [ Δ% ] returns 183.3333333

x [ - ] y [ Δ% ] returns (x - y)/y * 100%

Example:  250 [ - ] 300 [ Δ% ] returns -16.66666666

(This is the true percent change function, x is new, y is old)

x [ * ] y [ Δ% ] returns x + x * y / 100

Example:  250 [ * ] 300 [ Δ% ] returns 1000

x [ ÷ ] y [ Δ% ] returns x/(1 - y/100)

Example:  250 [ ÷ ] 300 [ Δ% ] returns -125

Verdict

It's a nice calculator and will fulfill the basic needs.  The keyboard is nice and fold-able.  If you get it, spending a few dollars (like no more than \$5) is good.

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.

## Saturday, September 14, 2019

### TI-84 Plus CE and Casio fx-5800P: Highway Transition Spiral

TI-84 Plus CE and Casio fx-5800P:  Highway Transition Spiral

Introduction

For any given parameters of a highway transition spiral:

PI:  point of intersection of the vertices (X coordinate, Y coordinate; Program Variables A, B)
∆:  intersection angle  (Program variable I)
D_C:  degree of the curve (Program variable D)
L_S:  length of the spiral (Program variable L)

Outputs:

Z:  Angle between the radii of spiral at TS and SC
TS:  point of intersection of main tangent and approach spiral   (Program Variables U, V)
SC:  point of intersection of main tangent and circular curve
ST:  short tangent

Formulas:

Z = L * D / 200

Z is in degrees
Convert Z to radians:  Q = Z * π /180

x = L * (1 - Q^2/10)
y = L * (Q/3 - Q^3/43)
k = x - R * sin Z
p = y - R * (1 - cos Z)
T = (R + P) tan (∆/2) + K
S = Y * csc Z = Y / sin Z

Coordinates of TS:
[ PI_X - intg(T/100),  PI_Y - 100 * frac(T/100)]

Coordinates of SC:
[ TS_X + intg(L/100), TS_Y + 100 * frac(L/100)]

TI-84 Plus CE Program HYSPIRAL
(program to be typed)

Degree
"EWS 2019-08-03"
Disp "HWY SPIRAL"
Input "PI X: ",A
Input "+ PI Y: ",B
Input "INT-ANGLE: ",I
Input "LENGTH: ",L
Input "DEGREE: ",D
L*D/200→Z
100/(D*π/180)→R
Zπ/180→Q
L(1-Q²/10)→X
L(Q/3-Q³/43)→Y
X-R sin(Z)→K
Y-R (1-cos(Z))→P
(R+P) tan(I/2)+K→T
Y/sin(Z)→S
Pause
A-iPart(0.01T)→U
B-100 fPart(0.01T)→V
Disp "TS:",U,"+",V
Pause
Disp "SC:",U+iPart(0.01L),"+",V+100 fPart(0.01L)
Pause
Disp "ST:",S

Casio fx-5800P Program HWYSPIRAL

Deg
"HIGHWAY SPIRAL"
"PI X: "?→A
"PI Y: "?→B
"INT-ANGLE: "?→I
"LENGTH: "?→L
"DEGREE: "?→D
L*D÷200→Z
100÷(D*π÷180)→R
Z*π÷180→Q
L*(1-Q²÷10)→X
L*(Q÷3-Q^(3)÷43)→Y
X-R sin(Z)→K
Y-R (1-cos(Z))→P
(R+P) tan(I÷2)+K→T
Y÷sin(Z)→S
"ANGLE TS-SC:"
Z⊿
R⊿
A-Int(0.01T)→U
B-100 Frac(0.01T)→V
"TS X:"
U⊿
"TS Y:"
V⊿
"SC X:"
U+Int(0.01L)⊿
"SC Y:"
V+100 Frac(0.01L)⊿
"ST:"
S

Example

A highway with a transition spiral is at station 50 + 64.84, with the intersection angle 50°, and the degree of the curve at 6°.  The length of the curve is said to be 360 ft.

Inputs:

PI X = 50
PI Y = 64.84
INT-ANGLE = 50
LENGTH = 360
DEGREE = 6

Outputs:

ANGLE TS-SC = 10.8
TS:  (X + Y) = 44 + 37.12990632
SC:  (X + Y) = 47 + 97.12990632
ST = 120.4143341

Source:

Hicks, Tyler P.E.  Handbook of Civil Engineering Calculations McGraw Hill: New York.  2000  ISBN 0-07-028814-3

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, September 12, 2019

### HP 32SII and TI-66: Curve Fitting

HP 32SII and TI-66:  Curve Fitting

Introduction

The curve fitting program uses the linear regression module to determine the parameters b ("intercept") and m ("slope") in non-linear curves using following transformations:

Logarithmic Regression:  y = b + m * ln x
Transformations:  ( ln x, y, b, m )

Inverse Regression:  y = b + m / x
Transformations:  ( 1/x, y, b, m )

Exponential Regression:  y = b * e^(m * x)
Transformation:  ( x, ln y, e^b, m )

Power Regression:  y = b * x^m
Transformation:  ( ln x, ln y, e^b, m )

Geometric (Exponent) Regression:  y = b * m^x
Transformation:  ( x, ln y, e^b, e^m )

Simple Logistic Regression:  y = 1 / (b + m * e^(-x))
Transformation:  ( e^(-x), 1/y, b, m )

HP 32SII Program:  Curve Fitting

Note:
1.  This can be adapted into the HP 35S under one label.  Just take note of the where the label points are.
2.  The total amount of bytes used is 90.
3.  Flags 1 and 2 are used.  If flag 1 is set, e^m is calculated as slope.  If flag 2 is set, e^b is calculated as intercept.

Program:
// Initialize - LBL X
LBL X
CF 1
CF 2
CLΣ
0
RTN

// Calculation - LBL Y
LBL Y

FS? 2
e^x
STO B
VIEW B
m
FS? 1
e^x
STO M
VIEW M

STO R
VIEW R
RTN

// Logarithmic Regression - LBL L
LBL L
LN
R/S
GTO L

// Inverse Regression - LBL I
LBL I
1/x
R/S
GTO I

// Exponential Regression - LBL E
LBL E
SF 2
x<>y
LN
x<>y
R/S
GTO E

// Power Regression - LBL P
LBL P
SF 2
LN
x<>y
LN
x<>y
R/S
GTO P

// Geometric/Exponent Regression - LBL G
LBL G
SF 1
SF 2
x<>y
LN
x<>y
R/S
GTO G

// Simple Logistic Regression - LBL S
LBL S
+/-
e^x
x<>y
1/x
x<>y
STOP
GTO S

Instructions:
1.  Clear the statistics data and flags by pressing [XEQ] X.
2.  Enter data points, run the proper label, and press [ Σ+ ] or [ Σ- ].

For example, for Logarithmic fit:
y_data [ENTER] x_data [XEQ] L [ Σ+ ]

Subsequent Data:
y_data [ENTER] x_data [R/S] [ Σ+ ]

This scheme allows for undoing data:
y_data [ENTER] x_data [XEQ] L [ Σ- ]

3.  Calculate intercept (B), slope (M), and correlation (R), press [XEQ] Y.

TI-66 Program:  Curve Fitting

Notes:
1.  This program should be able to entered on a TI-58, TI-58C, or TI-59.  At the time of the posting, I have not done it, so I don't have the key codes.
2.  94 steps are used.  [INV] [SBR] is merged into the RTN step.
3.  Flags 1 and 2 are used.  If flag 1 is set, e^m is calculated as slope.  If flag 2 is set, e^b is calculated as intercept.

Program:
// Initialize - key [ A ]
000 LBL
001 A
002 INV
003 ST.F
004 01
005 INV
006 ST.F
007 02
008 CSR
009 0
010 RTN

// Calculation - key [ A' ]
011 LBL
012 A'
013 OP
014 12
015 INV
016 IF.F
017 02
018 (   // left parenthesis
019 INV
020 LN X
021 LBL
022 (  // left parenthesis
023 STO
024 08
025 R/S
026 X<>T
027 INV
028 IF.F
029 01
030 )  // right parenthesis
031 INV
032 LN X
033 LBL
034 )  // right parenthesis
035 STO
036 07
037 R/S
038 OP
039 13
040 STO
041 09
042 RTN

// Logarithmic Regression - key [ B ]
043 LBL
044 B
045 LN X
046 X<>T
047 R/S
048 RTN

// Inverse Regression - key [ C ]
049 LBL
050 C
051 1/X
052 X<>T
053 R/S
054 RTN

// Exponential Regression - [ D ]
055 LBL
056 D
057 ST.F
058 02
059 X<>T
060 R/S
061 LN X
062 R/S
063 RTN

// Power Regression - [ B' ]
064 LBL
065 B'
066 ST.F
067 02
068 LN X
069 X<>T
070 R/S
071 LN X
072 R/S
073 RTN

// Geometric/Exponent Regression - [ C' ]
074 LBL
075 C'
076 ST.F
077 01
078 ST.F
079 02
080 X<>T
081 R/S
082 LN X
083 R/S
084 RTN

// Simple Logistic Regression - [ D' ]
085 LBL
086 D'
087 +/-
088 INV
089 LN X
090 X<>T
091 R/S
092 1/X
093 R/S
094 RTN

Instructions:
1.  Clear the statistics data and flags by pressing [  ].
2.  Enter data points: enter x, run the proper label, enter y, press [R/S] and press [2nd] ( Σ+ ) or [INV] [2nd] ( Σ+ )  (for  Σ- ).

For example, for Logarithmic fit:
x_data [ B ] y_data [R/S]  [2nd] (Σ+)

This scheme allows for undoing data:
x_data [B] y_data [R/S] [INV] [2nd] (Σ+)

3.  Calculate intercept (B), slope (M), and correlation (R), press [2nd] [ A' ].

Examples

All results are rounded.

Example 1: Logarithmic Regression
Data (x,y):
(33.8, 102.4)
(34.6, 103.8)
(36.1, 105.1)
(37.8, 106.9)

Results:
B:  -33.4580
M:  38.6498
R:  0.9941

y ≈ -33.4580 + 38.6498 ln x

Example 2:  Inverse Regression
Data (x,y):
(100, 425)
(105, 429)
(110, 444)
(115, 480)

B:  823.80396
M:  -40664.72143
R:  -0.91195

y ≈ 823.80396 - 40664.72143/x

Example 3: Simple Logistic Regression
Data (x,y):
(1, 11)
(1.3, 9.615)
(1.6, 8.75)
(1.9, 8.158)
(2.6, 7.308)

B: 0.14675
M: -0.15487
R:  -0.99733

y ≈ 1 / (0.14675 - 0.15487*e^(-x))

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.

## Sunday, September 8, 2019

### TI-84 Plus CE and Casio fx-5800P: Lateral Pressure of Cohesionless Soils

TI-84 Plus CE and Casio fx-5800P:  Lateral Pressure of Cohesionless Soils

Introduction

The following equations calculates the total thrust of soil against a wall.  The soil is assumed to be cohesionless, free running soil.  This applies to soils like sand and gravel, but not clay.

SI units (meters, seconds, kilograms) are assumed in these calculations.

Inputs:

Φ = angle of internal friction of soil.  For cohesionless soils, such as medium and coarse sands, the angle of internal friction typically ranges from 30° to 35°.  The program assigns Φ to the variable I.

H = the height of the wall (m).

γ = unit weight of soil (kg/m^3).  The program assigns γ to W.

Outputs:

K_A = pressure coefficient (unit-less).  The program assigns K_A to K.

P = total thrust of the soil (kg/m) of the wall.

Equations:

K_A = (tan(45° - Φ/2))^2

P = 1/2 * γ * H^2 * K_A  (kg/m)

TI-84 Plus CE Program SOILPRES

(this program needs to be typed in)

Degree
Disp "LATERAL PRESSURE","SAND/GRAVEL","ANGLE INTERNAL"
Input "FRICTION: ",I
tan(45-I/2)²→K
Disp "WALL HEIGHT"
Input "(M): ",H
Disp "SOIL WEIGHT"
Input "(KG/M³): ",W
0.5*W*H²*K→P
Disp "PRESSURE COEF: ",K,"SOIL THRUST: ",P

Casio fx-5800P Program SOILPRESSURE

Deg
"LATERAL PRESSURE"
"SAND OR GRAVEL"
"ANGLE INTERAL"
"FRICTION: "?→I
(tan(45-I÷2))²→K
"WALL HEIGHT"
"(M): "?→H
"SOIL HEIGHT"
"(KG÷M^(3)): "?→W
0.5*W*H²*K→P
"PRESSURE COEF:"
K⊿
"SOIL THRUST:"
P

Example

Input:
Φ = I = 37°
H = 15 m
γ = W = 0.64 kg/m^3

Output:

K_A = K = 0.2485836199
P = 17.89802063 (kg/m)

Source:

Hicks, Tyler P.E.  Civil Engineering Formulas 2nd Ed.   McGraw Hill: New York.  2000.   ISBN 978-0-07-161470-2

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.

## Saturday, September 7, 2019

### TI NSpire CX II: Animation Demo

TI NSpire CX II:  Animation Demo

Introduction

This blog entry demonstrates the use of drawing commands from the TI Nspire CX II (and TI Nspire CX II CAS) to animate objects.  The main loop used in these animations used has the structure:

...
Local variables needed including coordinates
For coordinate 1, begin, end, step
For coordinate 2, begin, end, step (if necessary)
UseBuffer
...
SetColor red, green, blue
draw objects
....
PaintBuffer
Wait  seconds
EndFor
EndFor (if a second for loop is used)
...

Demo 1:  Animation of a Circle Across the Screen

Define ani1()=
Prgm
:© animate a circle across the screen part 1
:Local x
:SetWindow 0,10,0,10
:For x,1,9,2
:  UseBuffer
:  Clear
:  SetColor 255,27,34
:  FillCircle x,9,2
:  PaintBuffer
:  Wait 1
:
:EndFor
:EndPrgm

Demo 2:  Animation of a Circle Across and Down the Screen

Define ani2()=
Prgm
:Local x,y
:For y,10,190,20
:  For x,10,270,20
:    UseBuffer
:    Clear
:    SetColor 255,27,34
:    FillCircle x,y,20
:    PaintBuffer
:    Wait 0.25
:  EndFor
:EndFor
:
:SetColor 0,0,0
:DrawText 10,10,"Done!"
:EndPrgm

Demo 3:  Animation of a Circle with Alternating Colors

Define ani3()=
Prgm
:Local x,y,flag
:flag:=0
:For y,10,190,20
:  For x,10,270,20
:    UseBuffer
:    Clear
:    If flag=0 Then
:      SetColor 255,27,34
:      flag:=1
:    Else
:      SetColor 0,228,221
:      flag:=0
:    EndIf
:    FillCircle x,y,20
:    PaintBuffer
:    Wait 0.175
:  EndFor
:EndFor
:
:SetColor 0,0,0
:DrawText 10,10,"Done!"
:EndPrgm

Demo 4:  Barbell Animation

Define ani4()=
Prgm
:Local x,y,xc,yc,θ
:
:setMode(2,1)
:
:For θ,0,8*π,((π)/(12))
:  UseBuffer
:  Clear
:  xc:=60*cos(θ)+159
:  yc:=60*sin(θ)+106
:  SetColor 48,48,48
:  DrawLine 159,106,xc,yc
:  SetColor 205,127,50
:  FillCircle xc,yc,15
:  SetColor 0,0,0
:  FillCircle 159,106,15
:  PaintBuffer
:  Wait 0.15
:EndFor
:DrawText 0,25,"Done!"
:EndPrgm

Demo 5:  Bouncing Box Animation

Define ani5()=
Prgm
:Local r,g,b,x,y,t,θ
:x:=106
:y:=159
:setMode(2,2)
:
:θ:=randInt(1,359)
:
:For t,1,1000
:UseBuffer
:Clear
:r:=randInt(0,255)
:g:=randInt(0,255)
:b:=randInt(0,255)
:SetColor r,g,b
:FillRect x,y,10,10
:
:x:=10*cos(θ)+x
:y:=10*sin(θ)+y
:
:If x≥310 or x≤10 or y≥200 or y≤10 Then
: θ:=mod(θ+90,360)
:EndIf
:SetColor 0,15,96
:DrawPoly {10,10,310,310,10},{10,200,200,10,10}
: PaintBuffer
: Wait 0.05
:EndFor
:EndPrgm