Showing posts with label hyperbolic functions. Show all posts
Showing posts with label hyperbolic functions. Show all posts

Saturday, July 6, 2024

HP 12C: Hyperbolic Sine and Cosine, and their Inverses

HP 12C: Hyperbolic Sine and Cosine, and their Inverses


Introduction


The following program calculates four hyperbolic functions:


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

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

arcsinh x = ln(x + √(x^2 + 1))

arccosh x = ln(x + √(x^2 - 1)) (principal arccosh x)



HP 12C Program: sinh x, cosh x, arcsinh x, arccosh x



Step #: Step Code: [ keys ]


# sinh x: GTO 01, R/S

01: __, 43, 22: [ g ] e^x

02: __, 43, 36: [ g ] LST x

03: __, __, 16: [ CHS ]

04: __, 43, 22: [ g ] e^x

05: __, __, 30: [ - ]

06: __, __, _2: [ 2 ]

07: __, __, 10: [ ÷ ]

08: 43, 33, 00: [ g ] GTO 00


# cosh x: GTO 09, R/S

09: __, 43, 22: [ g ] e^x

10: __, 43, 36: [ g ] LST x

11: __, __, 16: [ CHS ]

12: __, 43, 22: [ g ] e^x

13: __, __, 40: [ + ]

14: __, __, _2: [ 2 ]

15: __, __, 10: [ ÷ ]

16: 43, 33, 00: [ g ] GTO 00


# arcsinh x: GTO 17, R/S

17: __, __, 36: [ ENTER ]

18: __, __, 36: [ ENTER ]

19: __, __, _2: [ 2 ]

20: __, __, 21: [ y^x ]

21: __, __, _1: [ 1 ]

22: __, __, 40: [ + ]

23: __, 43, 21: [ √ ]

24: __, __, 40: [ + ]

25: __, 43, 23: [ g ] LN

26: 43, 33, 00: [ g ] GTO 00


# arccosh x: GTO 27 R/S

27: __, __, 36: [ ENTER ]

28: __, __, 36: [ ENTER ]

29: __, __, _2: [ 2 ]

30: __, __, 21: [ y^x ]

31: __, __, _1: [ 1 ]

32: __, __, 30: [ - ]

33: __, 43, 21: [ √ ]

34: __, __, 40: [ + ]

35: __, 43, 23: [ g ] LN

36: 43, 33, 00: [ g ] GTO 00



Instructions


1. Enter x

2. To calculate, press [ g ] GTO ##, then press [ R/S ].

* GTO 01 R/S: sinh x

* GTO 09 R/S: cosh x

* GTO 17 R/S: arcsinh x

* GTO 27 R/S: arccosh x


Examples

(Fix 4)

x

sinh x

cosh x

-0.64

-0.6846

1.2119

0.59

0.6248

1.1792

1.23

1.5645

1.8568

3.74

21.0371

21.0609


Note: arccosh(1.2119) returns 0.64



Source


Selby, Samuel M. Ph. D. Sc. D. CRC Standard Mathematics Tables: Nineteenth Edition. The Chemical Rubber Co. Cleveland, OH. 1971. pp. 202, 211



Until next time,

Eddie


All original content copyright, © 2011-2024. 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, July 14, 2022

TI-58/TI-59 Week: Hyperbolic Functions

 TI-58/TI-59 Week:  Hyperbolic Functions


Introduction


The program listing sets up the soft keys as the following:


[ A ] :  calculate sinh


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


[ 2nd ] ( A' ):  calculate arcsinh (principal branch)


arcsinh x = ln | x + √(x^2 + 1) |


[ B ]:  calculate cosh


cosh x = (e^x + 1/e^x) / 2


[ 2nd ] ( B' ): calculate arccosh (principal branch)


arccosh x = ln | x + √(x^2 - 1) |


[ C ]:  calculate tanh


tanh x = sinh x / cosh x = (e^x - e^(-x)) / (e^x + e^(-x))


[ 2nd ] ( C' ):  calculate arctanh


arctanh x = ln | √((x^2 + 1) / (1 - x)) |


R00 is used in calculation.  Note:  INV ln x, e^x



Program Listing


000 76 LBL   (sinh x)

001 11 A

002 53 (

003 22 INV

004 23 ln x  

005 42 STO

006 00 00

007 75 -

008 43 RCL

009 00 00

010 35 1/x

011 54 )

012 55 ÷

013 02 2

014 95 = 

015 92 INV SBR  (RTN)


016 76 LBL   (arcsinh x)

017 16 A'

018 42 STO

019 00 00

020 85 +

021 53 (

022 43 RCL

023 00 00

024 33 x^2

025 85 -

026 01 1

027 54 )

028 34 √

029 95 =

030 50 |x|

031 23 ln x

032 92 INV SBR


033 76 LBL (cosh x)

034 12 B

035 53 (

036 22 INV

037 23 ln x 

038 42 STO

039 39 00

040 85 +

041 43 RCL

042 00 00

043 35 1/x

044 54 )

045 55 ÷

046 02 2

047 95 =

048 92 INV SBR


049 76 LBL (arccosh x)

050 17 B'

051 42 STO

052 00 00

053 85 +

054 53 (

055 43 RCL

056 00 00

057 33 x^2

058 75 -

059 01 1

060 54 )

061 34 √

062 95 =

063 50 |x|

064 23 ln x

065 92 INV SBR


066 76 LBL (tanh x)

067 13 C

068 53 (

069 22 INV

070 23 ln x

071 42 STO

072 00 00

073 75 -

074 43 RCL

075 00 00

076 35 1/x

077 54 )

078 55 ÷

079 53 (

080 43 RCL

081 00 00

082 85 +

083 43 RCL

084 00 00

085 35 1/x

086 54 )

087 95 =

088 92 INV SBR


089 76 LBL (arctahn x)

090 18 C'

091 53 (

092 42 STO

093 00 00

094 85 +

095 01 1

096 54 )

097 55 ÷

098 53 (

099 01 1

100 75 -

101 43 RCL

102 00 00

103 54 )

104 95 =

105 34 √

106 50 |x|

107 23 ln x

108 92 INV SBR


Examples


sinh 3.96;  3.96 [ A ] returns 26.21913142


arcsinh 40;  40 [ 2nd ] (A') returns 4.382182848


cosh -2.22;  -2.22 [ B ] returns 4.657969987


arccosh 100:  100 [ 2nd ] (B') returns 5.298292366


tanh 0.58:  0.58 [ C ] returns 0.5226654297


arctanh 0.96:  0.96 [ 2nd ] (C') returns 1.94591014906


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Saturday, July 25, 2020

Fun with the 71B '20

Fun with the 71B '20

Differential Equations:  Runge Kutta Method 4th Order

Find a numerical solution to the differential equation:

dy/dx = f(x, y)

x is the independent variable, y is the dependent variable.  You define f(x,y) on line 10.   For example, dy/dx = sin(x * y) should have this as line 10:

10 DEF FNF(X,Y) = SIN(X*Y)

Line 5 is a remark line.  Remarks are followed by exclamation points on the HP 71B.

HP 71B Program: RK4 

Size: About 300 - 330 bytes

5 ! FNF(X,Y) = dY/dX
10 DEF FNF(X,Y) = [ insert f(x,y) here ]
15 DESTROY X,Y,H,K1,K2,K3,K4
20 INPUT "X0? "; X
25 INPUT "Y0? "; Y
30 INPUT "STEP? "; H
40 K1 = FNF(X,Y)
45 K2 = FNF(X+H/2,Y+H*K1/2)
50 K3 = FNF(X+H/2,Y+H*K2/2)
55 K4 = FNF(X+H,Y+H*K3)
60 X=X+H
65 Y=Y+H*(K1+2*K2+2*K3+K4)/6
80 DISP "(";X;",";Y;")" @ PAUSE
85 DISP "NEXT? Y/N"
90 A$=KEY$
95 IF A$="Y" THEN 40
99 IF A$="N" THEN DISP "DONE" @ END ELSE 85

Example:
dy/dx = sin(x * y) with inital condition y(0) = 0.5,  h = 0.2 * Ï€

First three results:
( .628318530718 , .607747199386 )   ( [ f ] [ +] (CONT), [ Y ] )
( 1.25663706144, 1.02432288082 )
( 1.88495559216, 1.51038862362 ) 

Hyperbolic Functions

[ S ] = sinh(x)
[ C ] = cosh(x)
[ A ] = asinh(x)
[ H ] = acosh(x)
[ X ]  to exit

HP 71B Program: HYP

Size:  401 bytes
acosh(x) requires that | x | ≥ 1

100 DESTROY A,X
115 DISP "sinh S/A, cosh C/H, X"
120 A$=KEY$
125 IF A$="S" THEN INPUT "X? ";X @ CALL SINH(X)
130 IF A$="C" THEN INPUT "X? ";X @ CALL COSH(X)
135 IF A$="A" THEN INPUT "X? ";X @ CALL ASINH(X)
140 IF A$="H" THEN INPUT "X? ";X @ CALL ACOSH(X)
145 IF A$="X" THEN 150 ELSE 115
150 DISP "DONE" @ END
200 SUB SINH(X)
205 DISP (EXP(X)-EXP(-X))/2 @ PAUSE
210 END SUB
300 SUB COSH(X)
305 DISP (EXP(X)+EXP(-X))/2 @ PAUSE
310 END SUB
400 SUB ASINH(X)
405 DISP LOG(X+SQR(X^2+1)) @ PAUSE
410 END SUB
500 SUB ACOSH(X)
510 DISP LOG(X+SQR(X^2-1)) @ PAUSE
515 END SUB

Example:
X = 2.86

sinh(2.86) returns 8.70212908815
cosh (2.86) returns 8.75939784845
asinh(2.86) returns 1.77321957441
acosh(2.86) returns  1.71190019325

Arithmetic-Geometric Mean

The arithmetic-geometric mean (AGM) is found by the iterative process:

a = 0.5 * (x + y)
g = √(x * y)

The values of a and g are stored into x and y, respectively.  The process repeats until the values of a and g converge.   A tolerance of 10^(-9) is used to display an 8-digit approximation.

HP 71B Program: AGM

Size:  148 Bytes

10 DESTROY X,Y,A,B
15 DISP "AGM(X,Y)" @ WAIT .5
20 INPUT "X? ";X
25 INPUT "Y? ";Y
30 A=.5*(X+Y)
35 G=SQR(X*Y)
40 X=A
45 Y=G
50 IF ABS(X-Y)>1E-9 THEN 30
55 DISP USING 60;X
60 IMAGE 10D.8D    // (10 digit integer parts with rounding to 8 decimal places)
65 END

Example:
AGM(178, 136)

Result:  156.29380544

Pythagorean Triple Generator

Given two positive integers m, n; where m > n, a Pythagorean triple is generated with the following calculations:

a = 2*m*n
b = m^2 - n^2
c = m^2 + n^2

Properties:

a^2 + b^2 = c^2
Perimeter: p = a + b + c
Area: r = a * b / 2

HP 71B Program: PYTHTRI

Size: 217 bytes

10 DESTROY M,N,A,B,C,R,P
20 DISP "M>N, INTEGERS" @ WAIT .5
25 INPUT "M? "; M
30 INPUT "N? "; N
35 A=2*M*N
40 B=M^2-N^2
45 C=M^2+N^2
50 P=A+B+C
55 R=A*B/2
60 DISP 'A = ';A @ PAUSE
65 DISP 'B = ';B @ PAUSE
70 DISP 'C = ';C @ PAUSE
75 DISP 'PERIM.=';P @ PAUSE
80 DISP 'AREA =';R
85 END

Example:
M = 16, N = 11

Results:
A = 352, B = 153, C = 377, P = 864, R = 23760

Impedance of An Alternating Current

The program ALTCURR calculates the impedance (magnitude and phase angle) of a sinusoidal alternating current consisting of one resistor, one capacitor, and one inductor in a series.

HP 71B Program: ALTCURR

Size: 210 bytes

10 DESTROY F,L,C, R,W,Z,T
15 DEGREES
20 INPUT "FREQUENCY? ";F
25 INPUT "INDUCTANCE? ";L
30 INPUT "CAPACITANCE? ";C
35 INPUT "RESISTANCE? ";R
40 W=2*PI*F
45 Z=SQR(R^2+(W*L-1/(W*C))^2)
50 T=ATAN((W*L-1/(W*C))/R)
55 DISP "MAGNITUDE= "; Z @ PAUSE
60 DISP "PHASE ANGLE = "; T

Example:
F = 152 Hz
L = 4.75E-3 H  (4.75 mH)
C = 8E-6 F  (8 μF)
R = 6400 Ω

Results: 
Magnitude:  6401.24704262
Phase Angle: -1.1309750812°

Source:
Rosenstein, Morton.  Computing With the Scientific Calculator Casio.  Japan. 1986.  ISBN 1124161430


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, 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







RPN HP 12C: Fibonacci and Lucas Sequences

  RPN HP 12C: Fibonacci and Lucas Sequences Golden Ratio, Formulas, and Sequences Let φ be the Golden Ratio: φ = (1 + √5) ÷ 2...