Showing posts with label law of sines. Show all posts
Showing posts with label law of sines. Show all posts

Saturday, May 25, 2024

Swiss Micros DM32: Spherical Triangle ft. Law of Cosines

Swiss Micros DM32: Spherical Triangle ft. Law of Cosines



Introduction


The state file spheretri.d32 is about solving triangles on the spherical space.





The programs solve spherical triangles in two common problems: SSS (side-side-side, really arc lengths) and SAS (side-angle-side). All the inputs are in decimal degrees.


Also calculated are the surface area and perimeter, both in radians. The radius is assumed to be 1.


Surface Area = ( A° + B° + C° ) * π / 180 – π = A + B + C – π


Perimeter = ( X° + Y° + Z°) * π / 180 = X + Y + Z


The sum of the angles (A, B, C) must be greater than 180° (π radians). Due to this requirement, in solving for angles and sides, the Law of Cosines will be used in each instance. The Law of Sines is only advised to check ratios.



Equation listing


Law of Sines – can be used as a check on triangles:

SIN(A)÷SIN(X)=SIN(B)÷SIN(Y)


Law of Cosines – two equations:

COS(Z)=COS(X)×COS(Y)+SIN(X)×SIN(Y)×COS(C)

COS(C)=-COS(A)×COS(B)+SIN(A)×SIN(B)×COS(Z)


Here the variables are general place holders.



Program Listing


Labels:

Label H: help program

Label I: Initialization routine. Sets the angles mode to degrees and clears the variables.

Label C: Starts the solve spherical triangle routine: given the three arc lengths X, Y, and Z.

Label Z: Starts the solve spherical triangle routine: given the arc lengths X and Y and and the angle between the arcs, angle C

Label F: Routine to solve for angles A and B, perimeter, and area



General Instructions


  1. To start a new problem, execute program I.

  2. To solve a spherical triangle given the sides (arc lengths), execute program C. (SSS)

  3. To solve a spherical triangle given two sides and the internal angle, execute program Z. (SAS)


This program also solves for the surface area, assuming a radius of 1, and perimeter of the triangle.


Program Code



H01 LBL H

H02 SF 10

H03 EQN: A N G L E _ A _ B _ C

H04 EQN: S I D E S _ X _ Y _ Z

H05 EQN: X E Q _ C _ S S S

H06 EQN: X E Q _ Z _ S A S

H07 EQN: E Q N S _ A R E _ S I N E

H08 EQN: A N D _ C O S I N E _ L A W S

H09 CF 10

H10 RTN


I01 LBL I

I02 DEG

I03 CLVARS

I04 CLx

I05 RTN


C01 LBL C

C02 INPUT X

C03 INPUT Y

C04 INPUT Z

C05 RCL Z

C06 COS

C07 RCL X

C08 COS

C09 RCL Y

C10 COS

C11 ×

C12 -

C13 RCL X

C14 SIN

C15 RCL Y

C16 SIN

C17 ×

C18 ÷

C19 ACOS

C20 STO C

C21 VIEW C

C22 XEQ F

C23 RTN


Z01 LBL Z

Z02 INPUT X

Z03 INPUT Y

Z04 INPUT C

Z05 RCL X

Z06 COS

Z07 RCL Y

Z08 COS

Z09 ×

Z10 RCL X

Z11 SIN

Z12 RCL Y

Z13 SIN

Z14 ×

Z15 RCL C

Z16 COS

Z17 ×

Z18 +

Z19 ACOS

Z20 STO Z

Z21 VIEW Z

Z22 XEQ F

Z23 RTN


F01 LBL F

F02 RCL X

F03 COS

F04 RCL Z

F05 COS

F06 RCL Y

F07 COS

F08 ×

F09 -

F10 RCL Z

F11 SIN

F12 RCL Y

F13 SIN

F14 ×

F15 ÷

F16 ACOS

F17 STO A

F18 RCL Y

F19 COS

F20 RCL X

F21 COS

F22 RCL Z

F23 COS

F24 ×

F25 -

F26 RCL X

F27 SIN

F28 RCL Z

F29 SIN

F30 ×

F31 ÷

F32 ACOS

F33 STO B

F34 RCL A

F35 RCL+ B

F36 RCL+ C

F37 →RAD

F38 π

F39 -

F40 STO R

F41 RCL X

F42 RCL+ Y

F43 RCL+ Z

F44 →RAD

F45 STO P

F46 VIEW A

F47 VIEW B

F48 VIEW R

F49 VIEW P

F50 RTN


You can download the DM32 state file here:


https://drive.google.com/file/d/1qX-y2G5sCOmm4ktmZbnGoPI3uzrx6IfF/view?usp=sharing



Examples  (FIX 5)


SSS Problem (LBL C)


X = 18.66°

Y = 20.49°

Z = 19.95°


Results:

C = 62.04726°

A = 55.92702°

B = 64.98954°

R = 0.05173 radians (surface area)

P = 1.03149 radians (perimeter)


SAS Problem (LBL Z)


X = 17.00 °

Y = 23.32°

C = 64.55°


Results:

Z = 21.88733°

A = 45.08768°

B = 73.51096 °

R = 0.05495 radians (surface area)

P = 1.08572 radians (perimeter)



Sources


Wikipedia. “Spherical Triangle” Updated April 9, 2024. Retrieved April 11, 2024.

https://en.wikipedia.org/wiki/Spherical_trigonometry#:~:text=Spherical%20trigonometry%20is%20the%20branch,sphere%2C%20geodesics%20are%20great%20circles.


Gray, Glen. “Spherical Trigonometry – An Introduction and Basic Theorems” Video. February 12, 2023. Retrieved April 11, 2024. https://www.youtube.com/watch?v=McWv9bcvMYg



Note: The blog will be posted on Saturdays only on June and July 2024.


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.

Friday, July 26, 2019

DM42S/Free42/HP 42S: Hyperbolic Triangles: Law of Sines and Cosines

DM42S/Free42/HP 42S:  Hyperbolic Triangles: Law of Sines and Cosines



There are three solvers: 

HYPSIN:  Law of Sines - Hyperbolic Triangles

sinh SA / sin ∠A = sinh SB / sin ∠B = sinh SC / sin ∠ C

The solver uses sinh SA / sin ∠A = sinh SB / sin ∠B .  Use the clever use of the labels is needed with the solver.

HYPANG:  Law of Cosines - Angle Dominant - Hyperbolic Triangles

cos ∠A = - cos ∠B * cos ∠C + sin ∠B * sin ∠C * cosh SA

HYPSDE:   Law of Cosines - Side Dominant - Hyperbolic Triangles

cosh SA = cosh SB * cosh SC - sinh SB * sinh SC * cos ∠A

HP 42S/DM42/Free 42 Solver Programs

HYPSIN:  Law of Sines - Hyperbolic Triangles

00 { 51-Byte Prgm }
01▸LBL "HYPSIN"
02 MVAR "SA"
03 MVAR "∡A"
04 MVAR "SB"
05 MVAR "∡B"
06 RCL "SA"
07 SINH
08 RCL "∡A"
09 SIN
10 ÷
11 RCL "SB"
12 SINH
13 RCL "∡B"
14 SIN
15 ÷
16 -
17 END

HYPANG:  Law of Cosines - Angle Dominant - Hyperbolic Triangles

00 { 63-Byte Prgm }
01▸LBL "HYPANG"
02 MVAR "∡A"
03 MVAR "∡B"
04 MVAR "∡C"
05 MVAR "SA"
06 RCL "∡B"
07 COS
08 +/-
09 RCL "∡C"
10 COS
11 ×
12 RCL "∡B"
13 SIN
14 RCL "∡C"
15 SIN
16 ×
17 RCL "SA"
18 COSH
19 ×
20 +
21 RCL "∡A"
22 COS
23 -
24 .END.

HYPSDE:   Law of Cosines - Side Dominant - Hyperbolic Triangles

00 { 66-Byte Prgm }
01▸LBL "HYPSDE"
02 MVAR "SA"
03 MVAR "SB"
04 MVAR "SC"
05 MVAR "∡A"
06 RCL "SB"
07 COSH
08 RCL "SC"
09 COSH
10 ×
11 RCL "SB"
12 SINH
13 RCL "SC"
14 SINH
15 ×
16 RCL "∡A"
17 COS
18 ×
19 -
20 RCL "SA"
21 COSH
22 -
23 END

Examples

Degrees mode is used

Example 1



Step 1:  Solve for Z, use HYPSDE:

23° -> ∠A
1.766 -> SB
1.8 -> SC
Solve for SA:  1.0969

Step 2:  Solve for X°, use HYPSIN:

1.8 -> SA
23° -> ∠A
1.766 -> SB
Solve for ∠B:  22.1432°

Step 3: Solve for Y°, use HYPSIN:

1.8 -> SA
23° -> ∠A
1.0969 -> SB
Solve for ∠B:  10.1773°

Example 2



Step 1:  Solve for Z°, use HYPANG

40° -> ∠A
42° -> ∠B
1.365 -> SA
Solve for ∠C:  57.0139°

Step 2:  Solve for X, use HYPSIN

40° -> ∠A
42° -> ∠B
1.365 -> SA
Solve for SB: 1.4004

Step 3:  Solve for Y, use HYPSIN

40° -> ∠A
57.10739° -> ∠B
1.365 -> SA
Solve for SB: 1.6050

Sources:

Martin, Angel  "Hyperbolic Triangles for the HP-41"  http://hp41programs.yolasite.com/hyperbolictriangle.php  Retrieved May 15, 2019

Wikipedia "Hyperbolic Triangles" Last edited May 29, 2019.  https://en.wikipedia.org/wiki/Hyperbolic_triangle  Retrieved June 9, 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, June 2, 2013

HP 35S: Planar Triangles

This program is set to solve common problems in plane (regular) triangles.

The programs can be adapted to any side lengths and angles necessary.

Variables of Plane Triangles

Side length a with corresponding angle A,
Side length b with corresponding angle B, and
Side length c with corresponding angle C.

Labels and Stack Set Up: HP 35S

Angle-Angle-Side, Label P001, Stack: B, A, b, Goal: a

Side-Side-Angle, Label P009, Stack: b, a, B, Goal: A

Angle-Side-Angle, Label P015, Stack: b, A, c, Goal: a

Side-Side-Side, Label P033, Stack: a, b, c, Goal: A (angle corresponding to first side length entered)

* If you use a 15C, 32Sii, or other another RPN calculator, you will need to create four labels. The nice thing with the HP 35S is that you can create multiple programs within in one label. Memory registers B and C are temporary.

Program P (Planar Triangles)

\\ Angle-Angle-Side: Law of Sines
\\ Stack: B, A, b; Find: a

P001 LBL P
P002 x<>y
P003 SIN
P004 ×
P005 x<>y
P006 SIN
P007 ÷
P008 RTN

\\ Side-Side-Angle: Law of Sines
\\ Stack: b, a, B; Find: A
P009 SIN
P010 ×
P011 x<>y
P012 ÷
P013 ASIN
P014 RTN

\\ Side-Angle-Side: Law of Cosines
\\ Stack: b, A, c; Find: a
P015 STO C
P016 x<>y
P017 COS
P018 ×
P019 x<>y
P020 STO B
P021 ×
P022 2
P023 ×
P024 +/-
P025 RCL B
P026 x^2
P027 +
P028 RCL C
P029 x^2
P030 +
P031 √
P032 RTN

\\ Side-Side-Side: Law of Cosines
\\ Stack: a, b, c; Find: A
P033 STO C
P034 x^2
P035 x<>y
P036 STO B
P037 x^2
P038 +
P039 x<>y
P040 x^2
P041 -
P042 2
P043 ÷
P044 RCL÷ B
P045 RCL÷ C
P046 ACOS
P047 RTN


Examples (Degrees Mode Used):
AAS: B = 30, A = 40, b = 4; a ≈ 5.1423

SSA: b = 5, a = 4, B = 90°; A ≈ 53.1301°

SAS: b = 8, A= 30°, c = 9; a ≈ 4.5047

SSS: a = 5, b = 4, c = 3; A = 90°


Hope this helps. I plan to post a program regarding spherical triangles.

Take care,

Eddie


This blog is property of Edward Shore. 2013

Saturday, July 14, 2012

Programs for HP 48S and What's Coming Up

HP 48: Law of Sines and Cosines, Quadratic Formula, and Cubic Formula.

Hi everyone! Recently, a poster on the MoHPC HP Calculator Forum asked for programs for solving triangles and finding roots for polynomials. (link here)

I will repost the programs here. They have been done with the HP 48S.

Law of Sines:

sin(θ1)/S1 = sin(θ2)/S2. Apply this to any of the two sides and their corresponding angels.

θ which can be typed by pressing:
HP 48S: [alpha] [right shift] (F)
HP 48G: [alpha] [right shift] (F)
HP 50g: [alpha] [right shift] (T)

LAWSIN:

<< 'SIN(θ1)/S1=SIN(θ2)/S2' STEQ 30 MENU>>

Law of Cosines:

A^2=B^2+C^2-2BC cos θ

LAWCOS:

<< 'SQ(A)=SQ(B)+SQ(C)-2*B*C*COS(θ)' STEQ 30 MENU>>

30 MENU brings up the calculator's solver using whatever is stored in STEQ.

QD: (Quadratic Formula) - Credit goes to the document "1 Minute Marvels" by Wldoek Mier-Jedrzejowicz and Richard Nelson (They have this program named 'quad')

Input:

3: A
2: B
1: C

Output:

2: root 1
1: root 2

<< 3 PICK / SWAP ROT -2 * / DUP SQ ROT - √ + LASTARG - >>

SQRT: Square Root

CU: Cubic Formula Uses the program QD above. This program finds the roots of AX^3+BX^2+CX+D=0

Input:
4: A
3: B
2: C
1: D

Output:
3: root 1
2: root 2
1: root 1

Program:

<< → A B C D
<<
C 3 A * / B SQ 9 A SQ * / - 'Q' STO
C B * A SQ / 3 D * A / - 6 / B 3 ^ 27 A 3 ^ * / - 'R' STO
R Q 3 ^ R SQ + √ + 3 XROOT 'S' STO
R Q 3 ^ R SQ + √ - 3 XROOT 'T' STO
S T + B 3 A * / - 'X' STO
X
B A X * +
C B X * + A X SQ * +
QD
{Q,R,S,T,X} PURGE >> >>

What is Coming Up

Coming in August, I will do a short series which I will use a graphing calculator with programming capabilities, most likely the TI-84 Plus, to demonstrate how programming is used to assist in mathematical applications: including finding the amount of miles between two places, projectile motion, and random walks.

If you get a chance, check out the Math/Maths Podcast. Link: Pulse Project

Until then,

Eddie


This blog is property of Edward Shore. © 2012

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