Showing posts with label Gudermannian function. Show all posts
Showing posts with label Gudermannian function. Show all posts

Sunday, August 11, 2024

Swiss Micros DM41X and fx-6500G: Complex Gudermannian Function and Its Inverse

Swiss Micros DM41X and fx-6500G: Complex Gudermannian Function and Its Inverse


Introduction


The Complex Gudermannian Function and the inverse are calculated as:


gd(x + yi) = u +vi where:

i = √-1

u = arctan( sinh x / cos y) = angle( cos y + i*sinh x )

v = arctanh( sin y / cosh x )


gd^-1(u + vi) = x + yi where:

i = √-1

x = arctanh( sin u / cosh v )

y = arctan( sinh v / cos u ) = angle(cos u + i*sinh v )


Notes:


* The calculator is set to radians mode during program execution.

* The arctangent function is handled using the rectangular to polar conversion (using the angle part). Doing so will increase the range between -π to π. The results are normalized.

* The results may not necessarily be the only answer but an attempt to get the principle branch.



Swiss Micros DM41X: Gudermannian and Inverse Gudermannian Functions


The DM41X is similar to the Hewlett Packard HP 41C series. Assuming we have no mathematical modules plugged in, the hyperbolic functions must be programmed as they were not included in the original function set.


Keeping with RPN notation, the imaginary part is placed on the Y stack and the real part is placed on the X stack. The memory registers used:


R01 = X

R02 = Y

R03 = U

R04 = V

gd(X + Yi) = U + Vi


The hyperbolic functions operate on real values only, and the in the Gudermannian and its inverse functions handle the real and imaginary parts separately.


DM41X: Hyperbolic Sine Routine: SINH


01 LBL^T SINH

02 ENTER↗

03 E↗X

04 X<>Y

05 CHS

06 E↗X

07 -

08 2

09 /

10 RTN

11 END


DM41X: Hyperbolic Cosine Routine: COSH


01 LBL^T COSH

02 ENTER↗

03 E↗X

04 X<>Y

05 CHS

06 E↗X

07 +

08 2

09 /

10 RTN

11 END


DM41X: Hyperbolic Arctangent Routine: ATANH


01 LBL^T ATANH

02 ENTER↗

03 ENTER↗

04 1

05 +

06 X<>Y

07 CHS

08 1

09 +

10 /

11 LN

12 2

13 /

14 RTN

15 END


Now to the main programs:


DM41X: Complex Gudermannian Function: CDG


01 LBL^T CGD

02 RAD

03 STO 01

04 X<>Y

05 STO 02

06 RCL 01

07 XEQ^T SINH

08 RCL 02

09 COS

10 R-P

11 X<>Y

12 STO 03

13 RCL 02

14 SIN

15 RCL 01

16 XEQ^T COSH

17 /

18 XEQ^T ATANH

19 STO 04

20 RCL 03

21 RTN

22 END


DM41X: Inverse Complex Gudermannian Function: CGDI


01 LBL^T CGDI

02 STO 03

03 X<>Y

04 STO 04

05 RAD

06 RCL 03

07 SIN

08 RCL 04

09 XEQ^T COSH

10 /

11 XEQ^T ATANH

12 STO 01

13 RCL 04

14 XEQ^T SINH

15 RCL 03

16 COS

17 R-P

18 X<>Y

19 STO 02

20 RCL 01

21 RTN

22 END


Casio fx-6500G: Gudermannian and Inverse Gudermannian Functions


The code can easily be adapted to other Casio calculators.


gd(X + Yi) = U + Vi


In these program listings, the real and imaginary parts are handled separately. For the fx-6500G (and same for the fx-7000G, 7500G, and 8000G), the Rectangular to Polar (Pol(x,y)) conversion stores the radius in the variable I and angle (θ) in the variable J. For the early Casio models, switch to Radians mode by pressing [ MODE ] [ 5 ].


gd(X + Yi) → U + Vi

Code:

Rad

“GD(X+YI)”

“X”:? → X

“Y”:? → Y

Pol(cos Y, sinh X)

J → U

tanh^-1 (sin Y ÷ cosh X) → V

“U + VI=”

U ⊿

V


gd^-1(U + Vi) → X + Yi


Code:

Rad

“GD^-1(U+YI)”

“U”:? → U

“V”:? → V

tanh^-1 (sin U ÷ cosh V) → X

Pol(cos U, sinh V)

J → Y

“X + YI=”

X ⊿

Y


Examples


Results are rounded to six decimal places. Be aware only one answer is given.


1. gd(3 + 4i) ≈ 1.635952 – 0.075314i

2. gd(-7 + 2i) ≈ -1.571555 + 0.001658i

3. gd(0 + 3i) ≈ 3.141593 + 0.142068i

4. gd(-3 + 0i) ≈ -1.471304 + 0i



Sources


“The Complex Gudermannian Function” analyticphysics.com. Uploaded June 16, 2021. Accessed June 23, 2024. https://analyticphysics.com/Complex%20Variables/The%20Complex%20Gudermannian%20Function.htm


“Gudermannian function” Wikipedia. Last Edited May 23, 2024. Accessed June 20, 2024.

https://en.wikipedia.org/wiki/Gudermannian_function#:~:text=The%20Gudermannian%20function%20relates%20the,sector%20is%20%CF%95%20%3D%20gd%20%CF%88.



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.

Saturday, August 10, 2024

Some Equations for the HP 22S

 Some Equations for the HP 22S




The [ 2 ] key has the letter X.  


These equations should work for the HP 27S, HP 32S/DM32, or Plus42.


Equations


Answers are shown to five decimal places.


Snell’s Law


Equation: Set Degrees Mode

N × SIN(T) = M × SIN(I)


T, I: reflection angles

N, M: refractive indices (1 for air, about 1.33 for water, etc.)


Examples:

Inputs: N = 1, T = 30°, I = 60°, Result: M ≈ 0.57735

Inputs: N = 1, M = 1.3333, I = 35.4°, Result: T ≈ 50.56589°

Inputs: N = 1, M = 1.3333, T = 100°, Result: I ≈ 47.61436°



Gudermannian and Inverse Gudermannian Functions


Equation: Set Radians Mode

G = 2 × ATAN( TANH( X ÷ 2 ) )


G = gd(X)

X = gd^-1(G)


Examples:

Input: X = 0.5, Result: G ≈ 0.48038

Input: X = 2.3, Result: G ≈ 1.37095

Input: G = -0.1, Result: X ≈ -0.10017

Input: G = 1, Result: X ≈ 1.22619



AC Current Equation


Equation: Set Radians Mode

I = P × SIN( W × T + H )


I = current at time T seconds in amps

P = peak current in amps

W = radian frequency = 2 * π * f

H = phase angle in radians


Examples:

Inputs: P = 10, W = 0.8, H = 0, T = 10, Result: I ≈ 9.89358

Inputs: P = 10, W = 2 * π * 60, H = 0.7, T = 10, Result: I ≈ 6.44218

Inputs: I = 15, W = 2 * π * 60, H = 0.6, T = 10, Result: P ≈ 26.56548



Air Pressure Up to 36,089 Feet


Equation:

P = 29.92126 × (1 – 6.875E-6 × H) ^ 5.255876329


H = height in feet

P = standard pressure in inHg (inches of Mercury)

The equation is giving with all the constants calculated.


(see https://edspi31415.blogspot.com/2024/06/casio-fx-4000p-programs-i-took-on.html , Prog 8)


Inputs: H = 1347, Result: P ≈ 28.49332

Inputs: H = 4126, Result: P ≈ 25.72143

Inputs: P = 22, Result: H ≈ 8266.49833




Law of Cosines





SQ(Z) = SQ(X) + SQ(Y) – 2 × X × Y × COS( C )


SQ: square function (x^2)

X, Y, Z = sides

C = angle that correspond to side Z


Examples:

Inputs: X = 10, Y = 12, C = 30°

Result: Z ≈ 6.01281 or Z ≈ 14.38679 (depending on the initial guess for Z)


Inputs: X = 55.44, Y = 37.85, Z = 62.17

Result: C ≈ 81.21305°



Ellipse Equation


The center of the ellipse is set at (0, 0).





Equation:

SQ(X ÷ A) + SQ(Y ÷ B) = 1


If A = B, we are working with a circle.


Examples:

Inputs: A = 5, B = 5, X = 4.9,

Result: Y ≈ 0.99499 (1 as a guess)

or Y gives a no solution error (0 as a guess)

(Your mileage may vary)


Inputs: A = 10, X = 8, Y = 12, Result: B = 20


Inputs: A = 10, X = -4, Y = 6

Result: B ≈ 6.54654 (10 as a guess)

but returns a divide by zero error for other guesses (20)


To store an initial guess on the HP 22S, be out of equation mode and store the guess in the variable you are trying to solve for.


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.


Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...