Sunday, February 26, 2017

Hyperbolic Functions: Algebra with sinh x, cosh x, e^x

Hyperbolic Functions:  Algebra with sinh x, cosh x, e^x

sinh x and cosh x defined in terms of e^x

sinh x = ( e^x - e^-x) / 2     (I)

cosh x = ( e^x + e^-x) / 2     (II)

x can be real or complex

sinh^2 x and cosh^2 x

sinh^ 2 x
= (sinh x)^2
= (( e^x - e^-x) / 2)^2
= 1/4 * ((e^x)^2 – 2*e^x*e^-x + (e^-x)^2)
= 1/4 * ((e^x)^2 – 2 + (e^-x)^2)     (III)

cosh^ 2 x
= (cosh x)^2
= (( e^x + e^-x) / 2)^2
= 1/4 * ((e^x)^2 + 2*e^x*e^-x + (e^-x)^2)
= 1/4 * ((e^x)^2 + 2 + (e^-x)^2)     (IV)

Product of sinh x and cosh x

sinh x * cosh x
= (e^x – e^-x)/2 * (e^x + e^-x)/2
= 1/4 * ((e^x – e^-x) * (e^x + e^-x))
= 1/4 * ( e^x*e^x + e^x*e^-x – e^-x*e^x – e^-x*e^-x )
= 1/4 * ( e^(2*x) – e^(-2*x) )   (V)

Note that e^x * e^-x = 1.

Sums and Differences with sinh^2 x and cosh^2 x

sinh^2 x + cosh^2 x
= 1/4 * ( (e^x)^2 – 2 (e^-x)^2 ) + 1/ 4 * ( (e^x)^2 + 2 + (e^-x)^2 )
= 1/4 * ( 2 * (e^x)^2 + 2 * (e^x)^-2 )
= 1/2 * ( (e^x)^2 + (e^-x)^2 )   (VI)

sinh^2 x - cosh^2 x
= 1/4 * ( (e^x)^2 – 2 (e^-x)^2 ) - 1/ 4 * ( (e^x)^2 + 2 + (e^-x)^2 )
= 1/4 * ( -4 )
= -1   (VII)

This implies that cosh^2 x – sinh^2 x = 1.

Binomial expansions of involving sums and differences of e^x and e^-x

(e^x + e^-x)^2 = (e^x)^2 + 2 + (e^-x)^2
(e^x – e^-x)^2 = (e^x)^2 – 2 + (e^-x)^2
( (e^x)^2 + (e^-x)^2 )^2 = (e^x)^4  + 2 + (e^-x)^4
( (e^x)^2 – (e^-x)^2 )^2 = (e^x)^4 – 2 + (e^-x)^4    (VIII)

Product of sinh^2 x and cosh^2 x

Substitutions:  α = e^x and β = e^-x, therefore α*β = e^x * e^-x = 1

sinh^2 x * cosh^2 x
= 1 /4 * (α^2 – 2 + β^2) * 1 /4 * (α^2 + 2 + β^2)
= 1/16 * (α^4 + 2*α^2 + α^2*β^2 – 2*α^2 – 4 – 2*β^2 + α^2*β^2 + 2*β^2 + β^4)
= 1/16 * (2*α^2*β^2 + α^4 + β^4 – 4)

Back substitute:
= 1/16 * (2 + (e^x)^4 + (e^-x)^4 – 4)
= 1/16 * ( (e^x)^4 – 2 + (e^-x)^4 )
= 1/16 * ( (e^x)^2 – (e^-x)^2 ) ^2    (IX)

See you in March!  I am working on coordinate conversions of very unusual (at least in my opinion) coordinate systems, more programs, and hopefully making sense of basic tensor calculus.

Eddie

This blog is property of Edward Shore, 2017

Friday, February 17, 2017

Retro Review: Canon FS-5 Solar Card Scientific Calculator

Retro Review:  Canon FS-5 Solar Card Scientific Calculator

Company:  Canon
Model:  FS-5
Type:  Scientific, One Variable Statistics
Year: 1983
Power: Solar
Memory Registers: 1
Operating System:  AOS (prefix)
Statistics:  One Variable
Forensic:  8.9789682 (9, sin, cos, tan, atan, acos, asin)

A Credit-Card Sized Delight

The Canon FS-5 is a thin as a credit card calculators that came popular during the 1980s.  Other calculators that belong to the credit card size are Casio fx-82 and TI-30 SLR.  All the buttons are small, but are responsive, especially the small round clear all ([CA]) button.

The display is 8 digits (which reduces to 5 digits when powers of ten are displayed).

One thing to note, the power function is labeled by a^x.

Statistics

The statistics package that the FS-5 offers is very simple:  mean, sample deviation (labeled by σ^(n-1)), and population variance (labeled by v^n).  You enter statistics mode automatically by pressing the [SUM] button and delete last entry by the [INV] [SUM] (DLT).  To return to mathematics mode and clear all statistics registers, press the [CA] button.

Going Green

The FS-5 run by solar power, with no battery backup.  Be sure to be in adequate light.

This Calculator is Thin!

I think the picture below says it all:

(Thickness comparison:  Casio fx-115 ES, Canon FS-5, Sharp EL-510RN)  (left to right)

Verdict

This is a nice, thin, and simple scientific calculator.  I like the key design, especially since the buttons are small, they are responsive.  The calculator looks pretty cool too.  If you can find one online, consider getting it.  I paid \$15, I think that is reasonable, somewhere in the teens.

Until next time,

Eddie

This blog is property of Edward Shore, 2017.

Wednesday, February 15, 2017

Retro Review: Casio CM-100 Computer Math Calculator

Retro Review:  Casio CM-100 Computer Math Calculator

Company:  Casio
Model:  CM-100
Type:  Computer Math, Boolean Algebra
Year: 1986
Power: Solar
Memory Registers: 1

Being Green

The CM-100 is fully ran by solar power, so make sure you have adequate light to operate the CM-100.

Base Calculations

The CM-100 is part of a rare genre of scientific calculator: the calculator that is dedicated to base conversions, bit shifting and rotating, and displaying integers up to 32 bits (dwords).  Perhaps the most famous calculator of this family is the much sought after Hewlett Packard HP-16C.  On the Texas Instruments side, there was the TI-Programmer.

There are five modes on the CM-100:

COMP:  Math Mode.  All numbers are represented in decimal with floating point arithmetic.  The parenthesis, %, √, x^2, 1/x, HMS conversions, and memory functions are the primary functions on the 2nd and 3rd row of keys.  Pressing [ ON ] clears the calculator and sets the CM-100 to COMP mode.

Entering numbers in degrees-minutes-seconds requires a repeated press of [ hms ].

Note: For the BIN, OCT, DEC, HEX modes, the parenthesis and memory functions become shifted functions, and instead of the %, √, x^2, 1/x, DMS conversions, we have BLK (block scrolling), shifting, NOT, AND, OR, XOR, and rotation.

BIN:  Binary Mode.  All integers are represented in base 2.   Pressing [BIN] converts the integer to binary.

OCT: Octary Mode.  All integers are represented in base 8.  Pressing [OCT] converts the integer to octave.

DEC:  Decimal Mode.  All integers are presented in base 10.  Pressing [DEC] converts the integer to decimal.

HEX:  Hexadecimal Mode.  All integers are presented in base 16.  Pressing [HEX] converts the integer to hexadecimal.  The keys A-F become available.  As a reminder:

A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

Seeing Blocks

The CM-100 allows the user to set the bit sizes from 1, 4, 8, 10, 16, and 32.  Since the calculator can only fit so many digits on the screen, up to 10, the [BLK] key is to available for the user to cycle through the blocks:

Block 4 | Block 3 | Block 2 | Block 1

Example:  Display 3,723,601 in binary bits.  Assuming base 32 is set (which I think is the default).  Press [BLK] to cycle through the blocks.  The decimal points indicate which block you are viewing.

 Block 1  (3 decimal points to the left) .1.0.01001 Block 2   (2 left, 1 right) .1.1010001. Block 3   (1 left, 2 right) .0011100.0. Block 4   (3 right) 000000.0.0.

Hence, 3,723,601 in binary is 00000000 00111000 11010001 1001001.

To Sign or Not To Sign

The CM-100 has two modes when comes to signs:

Unsigned (no display indicator):  All integers are 0 or positive.  The range is from 0 to (2^n) -1, where n is the number of bits.

Signed (a SIGN indicator):  Integers can be positive or negative.  The first bit is the sign bit which dictates the sign of the integer (easiest to understand in Binary mode).  The range is from -2^(n-1) to 2^(n-1) – 1.

Example:  In Binary, 4 Bits:
 Binary Unsigned Mode Representation Signed Mode Representation 1000 8 -8 1111 15 -1

Shifting Integers

It is well known that most calculators that have base calculations include the Boolean algebra functions NOT, AND, OR, and XOR; pretty standard.  What the CM-100 adds is the shift and rotate functions. I am going to try to explain the shifts as far I understand them – if you have a better explanation, please comment and it will be appreciated.  I think this is best understood in the context of Binary.

A-Shift:  Arithmetic Shift Left/Right.  This moves the bits left or right by 1.  Any bit that “shoved” off is discarded.  In Signed mode, Arithmetic Shift Right replaces the sign bit with whatever was the previous signed bit.  Otherwise, the new bit is 0.

Shift:  Logical Shift Left/Right.  This moves the bits left or right by 1.  Any bit that “shoved” off is discarded.  The replaced bit is always 0.

Rotate:  The bits rotates left or right by one digit.  All bits are otherwise retained.

Arithmetic Shift vs. Logical Shift

The only difference is when you are working with signed integers and when the shifts are to the right.

To illustrate, I executed both shifts on the CM-100, in Signed and Binary modes with 4 bit size set.  Arithmetic Shift Right ([ S ] [OCT] (A S>)),  Logical Shift Right ([ S ] [AND] (Shift>)).

Starting Integer:  0101

 Arithmetic Shift Right 0010 (Logical) Shift Right 0010 Arithmetic Shift Right 0001 (Logical) Shift Right 0001 Arithmetic Shift Right 0000 (Logical) Shift Right 0000

Starting Integer:  1001

 Arithmetic Shift Right 1100 (Logical) Shift Right 0100 Arithmetic Shift Right 1110 (Logical) Shift Right 0010 Arithmetic Shift Right 1111 (Logical) Shift Right 0001

Vs. the HP-16C

New Price of a CM-100:  \$20(?)
New Price of an HP-16C:  \$150

Obviously, the HP-16C was also programmable (203 bytes) and operated in RPN mode.  Furthermore, the HP-16C had double arithmetic (multiplication, division, and remainder).  However, the CM-100 has the decimal/decimal-degrees-seconds conversion and it was solar.

If you want to have a base-dedicated calculator and you had the budget in mind, consider buying the CM-100.  I bought one through eBay (Wolfs Big Bad Garage) for about \$25.  The HP-16C would cost at least \$100.

Verdict

I recommend this model.  It is convenient way to convert between bases, work with common bit sizes, and execute computer algebra on the CM-100.  It’s well worth the price.

If you want to take a look at the manual, check out this link (scroll to the bottom):  http://casio.ledudu.com/pockets.asp?type=1300&lg=eng

Eddie

This blog is property of Edward Shore, 2017

Wednesday, February 8, 2017

HP Prime, TI-84 Plus CE, Sharp EL-5500 III: Pythagorean Triples

HP Prime, TI-84 Plus CE, Sharp EL-5500 III:  Pythagorean Triples

Criteria

The program PYTHA calculates a Pythagorean triple.  A Pythagorean triple is a set of three positive integers A, B, and C that represent the lengths of a right triangle, with C being the hypotenuse.  Hence, A^2 + B^2 = C^2.

Pythagorean triples can be generated with three arbitrary positive integers M, N, and K with the following criteria:

1.  M > N
2.  M and N are coprime.  That is, gcd(M, N) = 1 (gcd, greatest common denominator)

A, B, and C are generated by:

A = K * (M^2 – N^2)
B = K * (2 * M * N)
C = K * (M^2 + N^2)

Verification

We can verify that the above formulas for A, B, and C work by showing A^2 + B^2 = C^2.

A^2 + B^2
= (K * (M^2 – N^2))^2 + (K * 2 * M * N)^2
= (K * M^2 – K * N^2)^2  + 4 * K^2 * M^2 * N^2
= K^2 * M^4 – 2 * K^2 * M^2 * N^2 + K^2 * N^2 + 4 * K^2 * M^2 * N^2
= K^2 * M^4 + 2 * K^2 * M^2 * N^2 + K^2 * N^2
= (K * M^2 + K * N^2)^2
= K^2 * (M^2 + N^2)^2
= C^2

Programs

HP Prime Program PYTHA

EXPORT PYTHA(M,N,K)
BEGIN
// 2017-02-08 EWS
// Pythagorean Triangle
LOCAL A,B,C;

// checks (not for minimum)
M:=IP(M); N:=IP(N); K:=IP(K);

IF M≤0 OR N≤0 OR
gcd(M,N)≠1 OR M≤N THEN
RETURN "INVALID"; KILL;
END;

// calculations
A:=K*(M^2-N^2);
B:=K*(2*M*N);
C:=K*(M^2+N^2);

RETURN {A,B,C};
END;

TI-84 Plus Program PYTHA

"EWS 2017-02-08"
Prompt M,N,K
iPart(M)→M
iPart(N)→N
iPart(K)→K
If M≤0 or N≤0 or K≤0 or M≤N or gcd(M,N)≠1
Then
Disp "INVALID"
Stop
End
K*(M²-N²)→A
K*(2*M*N)→B
K*(M²+N²)→C
Pause {A,B,C}

Sharp EL-5500 III Pythagorean Triple
(RUN 450 (line numbers are arbitrary))

450 PAUSE “Pythagorean Triple”
455 INPUT “M:”; M, “N:”; N, “K:”; K
460 IF M<=0 OR N<=0 OR K<=0 OR M<=N THEN 480
462 A = K*(M^2 - N^2)
464 B = K*2*M*N
466 C = K*(M^2 + N^2)
468 IF A^2 + B^2 <> C^2 THEN 480
470 PRINT A; “^2+”; B; “^2=”; C; “^2”
472 END
480 PRINT “INVALID”
482 END

Examples:

M: 2, N: 1, K: 1. Result:  A: 3, B: 4, C: 5

M: 7, N: 2, K: 1. Result:  A: 45, B: 28, C: 53

M: 5, N: 3, K: 2. Result:  A: 32, B: 60, C: 68

Source:

“Pythagorean Triple” Wikipedia. Last Modified February 7, 2017.
Accessed February 7, 2017

Have a great day, love you all for the support,

Eddie

This blog is property of Edward Shore, 2017

HP 12C: Finding Two Factors of an Integer

HP 12C:  Finding Two Factors of an Integer  Introduction This program finds two factors of the integer N, where one of the factors ...