Showing posts with label sphere. Show all posts
Showing posts with label sphere. Show all posts

Sunday, October 2, 2022

Swiss Micros DM41X: Setting Up Keys Through a Program

Swiss Micros DM41X:  Setting Up Keys Through a Program


Assigning User Keys Through a Program


On the HP 41/DM 41 family, it is possible to store programs or commands in a program (see Caution below).


ASN vs PASN


Both ASN and PASN assigns a user key.  ASN is not a programmable command, but PASN is.  


ASN will prompt for a key with the program or command in the alpha register. 


PASN is a programmable command with the following syntax:


^T  (program or command name)

(key code)

PASN


The key codes start in the upper left hand corner of the classic HP 41C calculators.  If you are using a Swiss Micros version, please keep in mind that the keyboard is different from the classic HP 41C but the key codes are retained.


Some common user keyboard key codes are:

[ Σ+ ] 11

[ 1/x ] 12

[ √x ] 13

[ LOG ] 14

[ LN ] 15


[x<>y] 21

[ R↓ ] 22

[SIN] 23

[COS] 24

[TAN] 25


[ENTER↑] 41

[ - ] 51

[ + ] 61

[ × ] 71

[ ÷ ] 81


Shifted user keys have a negative value, for example:

[ (shift) ] [ Σ+ ] ( Σ- )  -12

[ (shift) ] [ 1/x ] (y^x)  -13

 and so on.


Clearing Assigned Keys


To clear a single user key, assign a blank alpha string to it.  This works for both ASN and PSAN.  


You can clear all the keys by the CLKEYS command. (see Caution below).


Caution:  Unless modifications or additional ROMs are added, the commands PASN and CLKEYS are not available on the HP 41C and the HP 41CV.  The commands are available on the HP 41CX, DM41X,  DM 41, and DM 41L.  



Template



Give the user a choice to clear or load the user keys: 


LBL ^T  (main name of the program)

^T 0 CLR 1 LOAD

PROMPT

STO 00

GTO IND 00


Fortunately we can use indirect addressing with the GTO command. 


This section clears all the keys.  I put a DONE message to tell the user that the process is done.  


LBL 00

CLRKEYS

^T DONE

AVIEW

RTN          


This section loads the commands and programs to user keys.  Detailed programs will follow. 


LBL 01 

^T  (program or command name)

(key code)

PASN

...

RTN


Now for the programs and calculations created:


LBL ^T (program or command name)

(contents)

RTN

...


END 


Add an END command after the last RTN.  


The Program UFX


The program UFX presents the user with two options:  enter 0 to clear all the user keys.  Entering 1 loads the following functions:


SSPH:  Surface area of a sphere.  Assigned to the user key [ Σ+ ], key code 11.

Surface area of a sphere = 4 * π * x^2


VSPH:  Volume of a sphere.  Assigned to the user key [ x<>y ], key code 21.

Volume of a sphere = 4/3 * π * x^3


STOR:  Surface area of a torus.  Assigned to the user key [ 1/x ], key code 12. 

Surface area of a torus = 4 * π * y * x 

y = larger radius, x = smaller radius


VTOR:  Volume of a torus.  Assigned to the user key [ R↓ ], key code 22.

Volume of a torus = 2 * π^2 * y * x^2

y = larger radius, x = smaller radius


Swiss Micros DM41X Program UFX


(^T:  alpha string indicator)


01 LBL ^T UFX

02 ^T 0 CLR 1 LOAD

03 PROMPT

04 STO 00

05 GTO IND 00

06 LBL 00

07 CLRKEYS

08 ^T DONE

09 AVIEW

10 RTN          \\ RTN outside a subroutine stops the program

11 LBL 01      \\  assign the keys first, add the programs later

12 ^T SSPH

13 11

14 PASN

15 ^T VSPH

16 21

17 PASN

18 ^T STOR

19 12

20 PASN

21 ^T VTOR

22 22

23 PASN

24 ^T DONE    

25 AVIEW

26 RTN              \\ this ends the loading processing, the detialed subroutines follow 

27 LBL ^T SSPH

28 X↑2

29 PI

30 *

31 4

32 *

33 RTN

34 LBL ^T VSPH

35 3

36 Y↑X

37 4

38  *

39  3

40  /

41 PI

42  *

43 RTN

44 LBL ^T STOR

45 *

46 PI

47 X↑2

48  *

49  4

50  * 

51  RTN

52 LBL ^T VTOR

53 X↑2

54  *

55  PI

56 X↑2

57  *

58  2

59  *

60  RTN

61  END     \\ we want to end the program with END


Source (for the Torus formulas):


Mathematics Program Library:  Sinclair Enterprise Programmable  Sinclair Radionics Inc.  New York; Cambridgeshire, London.  1975


That is all this time, see you next time!


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. 



Sunday, August 15, 2021

Construction Pro 5: Geometry Algorithms

Construction Pro 5:  Geometry Algorithms


Before We Begin


Before we begin, some things to note:


1.  The [ Circ ] [ Circ ] sequence gives the area of a circle given by the denominator.  Area = (π * diameter^2) / 4 


2.  The [ Conv ] [ Rcl ] will clear the Construction Master 5's memory register.  So will [ Rcl ] [ Rcl ], the only difference is that the former sequence will not recall the memory's contents.


3.  The [ Rcl ] [ M+ ] sequence will recall the memory register's contents.


4.  The Construction Master 5 operates in Chain mode, like standard four-function calculators.  


5.  The algorithms presented today is one way to approach these calculation, most of them demonstrate the [ Circ ] [ Circ ] and memory features.   


Area:  Donut Driveway




Area = ((2D + I)^2 - I^2) * π/4


Key Sequence:


[ Conv ] [ Rcl ]

2 [ x ] D [ + ] I [ = ] [ Circ ] [ Circ ] [ M+ ]

I [ Circ ] [ Circ ] [ Conv ] ( M- )

[ Rcl ] [ M+ ]


Example:

D = 50 feet, I = 10 feet


[ Conv ] [ Rcl ]

2 [ x ] 50 [ Feet ] [ + ] 10 [ Feet ] [ = ] [ Circ ] [ Circ ] [ M+ ]

10 [ Feet ] [ Circ ] [ Circ ] [ Conv ] ( M- )

[ Rcl ] [ M+ ]


Result:  9,424.778 ft^2


Volume:  One-Hole Concrete Block




Note:  The border length (d) is equal around the entire block.


V = ( ( W + L ) * 2 * d - 4 * d^2 ) * t


Key Sequence:


[ Conv ] [ Rcl ]

W [ + ] L [ x ] 2 [ x ] d [ M+ ]

d [ Conv ] ( x^2 ) [ x ] 4 [ M- ]

[ Rcl ] [ M+ ] [ x ] t [ = ]


Example:

L = 12 in, W = 8 in, d = 1 in, t  10 in


[ Conv ] [ Rcl ]

8 [ Inch ] [ + ] 12 [ Inch ] [ x ] 2 [ x ] 1 [ Inch ] [ M+ ]

1 [ Inch ] [ Conv ] ( x^2 ) [ x ] 4 [ M- ]

[ Rcl ] [ M+ ] [ x ] 10 [ Inch ] [ = ]


Result:  360 in^3


Volume: Right Triangular Prism




V = D * H * B / 2 


Key Sequence:


D [ x ] H [ x ] B [ ÷ ] 2 [ = ]


Example:

D = 325 ft, H = 77 ft, B = 148 ft


325 [ Feet ] [ x ] 77 [ Feet ] [ x ] 148 [ Feet ] [ ÷ ] 2 [ = ]


Result:  1,851,850 ft^3 ≈ 68,587.04 yd^3


Volume:  Sphere Using the Circ Function





V = 4/3 * π * r^3 = π * d^3 / 6 = area_circle * d / 1.5

where area_circle = π * d^2 / 4


Key Sequence:


[ Conv ] [ Rcl ]

D [ M+ ] [ = ] [ Circ ] [ Circ ] [ x ] [ Rcl ] [ M+ ] [ ÷ ] 1.5 [ = ]


Note:  The first equals key "locks" in the value of D on to the register and allows it to be picked up with the Circ function without having to re-type it.  


Example:

D = 5 ft


[ Conv ] [ Rcl ]

5 [ Feet ] [ = ] [ M+ ] [ Circ ] [ Circ ] [ x ] [ Rcl ] [ M+ ] [ ÷ ] 1.5 [ = ]


Result: 65.44985 ft^3


Volume:  Column Using the Circ Function



V = π * D^2 * H / 4 = area_circle * H

where area_circle = π * d^2 / 4


Key Sequence:


D [ Circ ] [ Circ ] [ x ] H [ = ]


Example:

D = 2 ft 2 in, H = 1 ft 8 in


2 [ Feet ] 2 [ Inch ] [ Circ ] [ Circ ] [ x ] 1 [ Feet ] 8 [ Inch ] [ = ]


Result:  6.145013 ft^3


Commas added for readability.  


Eddie


All original content copyright, © 2011-2021.  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

fx-260 Solar Algorithms Part I

fx-260 Solar Algorithms Part I

All results are shown to screen accuracy. 

Sphere:  Surface Area and Volume

With the radius r,
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.

Sunday, January 22, 2017

Geometric Relationships: Circle, Sphere, and Equilateral Triangle

Geometric Relationships: Circle, Sphere, and Equilateral Triangle

Circle:  Relationship between Area and Circumference

We know that π is a constant (π ≈ 355/113, but more accurately, π ≈ 3.141592654).  And:

Circumference of a Circle:  C  = 2 * π * r
Area of a Circle: A = π * r^2

Observe that:
C = 2 * π * r
π = C / (2 * r)

And:
A = π * r^2
π = A / r^2

Hence:
C / (2 * r) = A / r^2
(2 * r) / C = r^2 / A
A * 2 * r = r^2 *C
A = C * r / 2

Sphere:  Relationship between Area and Circumference

Volume of a Sphere:  V = 4/3 * r^3 * π
Surface Area of a Sphere:  S = 4 * π * r^2

Solving for π:

V = 4/3 * r^3 * π
3 * V = 4 * r^3 * π
π = (3 * V) / (4 * r^3)

And:

S = 4 * π * r^2
π = S / (4 * r^2)

Then:
(3 * V) / (4 * r^3) = S / (4 * r^2)

Multiply both sides by 4 * r^2:
S = 3 * V / r


Equilateral Triangle:  Relationship between Perimeter and Area


Let a (small a) be the length’s side.   Then the area of the triangle:

A = 2 * (1/2 * a/2 * √3/2 * a) = a^2 * √3/4

With the perimeter:  P = 3 * a,

P = 3 * a
P^2 = 9 * a^2
a^2 = P^2 / 9

And

A = a^2 * √3 / 4
a^2 = 4 * A / √3

P^2 / 9 = 4 * A / √3
A = P^2 * √3 / 36

To summarize:

Circle:  Area and Circumference:  A = C * r / 2
Sphere:   Volume and Surface Area:  S = 3 * V / r
Equilateral Triangle:  Area and Perimeter:  A = P^2 * √3 / 36

The next blog will cover Platonic solids.  At least that’s the plan.  Have a great rest of the weekend.  

Eddie

This blog is property of Edward Shore, 2017.

Sunday, October 2, 2016

HP 12C Programming: Circles, Spheres, and Right Triangle

HP 12C Programming:  Circles, Spheres, and Right Triangle


Links to other HP 12C Programs:


HP 12C Programming Part II:  Weekday Number, Gross Up Calculation:  http://edspi31415.blogspot.com/2016/07/hp-12c-programming-part-ii-weekday.html

HP 12C Programming III: Refinancing, Advance Payments in a Lease, NPV, NFV, NUS

HP 12C:  Combination/Binomial Distribution/Negative Binomial Distribution

If you want on to calculate the date of Easter and you have the expanded HP 12C Platinum Edition:

HP 12C Platinum:  Finding the Day of Easter

Approximating π

The HP-12C does not have a π key.   We can tackle this in one of two ways:

* We can input the full approximation of π until the display no longer accepts numbers, which is up to 10 numbers.  π typed to screen capacity is 3.141592654.  Since each digit entered plus the decimal point takes a step, it will require 11 steps to enter.

* We can use the approximation π ≈ 355/113.  355/113 ≈ 3.141592920.  355/113 is an accurate approximation of π to 6 digits.  It will take a total of 8 steps to enter this approximation.   Since most of the time the HP 12C is used at Fix 2 mode (2 decimal places), this may be for most practical purposes an adequate approximation.  Just a caution:  make number of calculations low and the factors should be relatively small.

The programs represented on this blog will use the 355/113 to save space.  If you require a better approximation of π and have the space, feel free to replace 355/113 with the 3.141592654.

HP 12C:  Circles – Circumference and Area

The program calculates an approximate circumference and area of a circle given radius r.

C = 2*π*r
A = π*r^2

Here, we take 355/113 as an approximation for π.

STEP
CODE
KEY
01
44, 0
STO 0
02
3
3
03
5
5
04
5
5
05
36
ENTER
06
1
1
07
1
1
08
3
3
09
10
÷
10
44, 1
STO 1
11
20
*
12
2
2
13
20
*
14
31
R/S
15
45, 0
RCL 0
16
2
2
17
21
Y^X
18
45, 1
RCL 1
19
20
*
20
43, 33, 00
GTO 00

Registers used:
R0 = r, R1 = 335/113 ≈ π

Input:
Enter radius, r, and press [R/S].

Output:
Obtain the approximate circumference.  Press [R/S] for the area.

Examples (FIX 2):

Radius = 2.96.  Results:  Circumference ≈ 18.60, Area ≈ 27.53

Radius = 5.00    Results:  Circumference ≈ 31.42, Area ≈ 78.54

Alternate:  This uses the following shortcuts:
Number, [ENTER], [ + ] doubles the number.
Number, [ENTER], [ * ] squares the number.
That and the use of LST X reduces the number of steps to 19 and only uses one register, R0.

STEP
CODE
KEY
01
44, 0
STO 0
02
36
ENTER
03
40
+
04
3
3
05
5
5
06
5
5
07
36
ENTER
08
1
1
09
1
1
10
3
3
11
10
÷
12
20
*
13
31
R/S
14
43, 36
LST X
15
45, 0
RCL 0
16
36
ENTER
17
20
*
18
20
*
19
43, 33, 00
GTO 00



Fun fact:  A circle of radius 2 will have the same circumference and area, approximately 12.56637.                                                                                                                                                                                                                                                                                        
HP 12C:  Sphere – Surface Area and Volume

This program calculates the surface area and volume of a sphere give the radius r.  Again we take 355/113 as an approximation for π.  The well-known formulas:

S = 4*π*r^2
V = 4/3*π*r^3 = S * r/3

STEP
CODE
KEY
01
44, 0
STO 0
02
2
2
03
21
Y^X
04
4
4
05
20
*
06
3
3
07
5
5
08
5
5
09
36
ENTER
10
1
1
11
1
1
12
3
3
13
10
÷
14
20
*
15
31
R/S
16
3
3
17
10
÷
18
45, 0
RCL 0
19
20
*
20
43, 33, 00
GTO 00

Registers used:
R0 = r

Input:
Enter radius, r, and press [R/S].

Output:
Obtain the approximate surface area.  Press [R/S] for the volume.

Examples:
Radius = 2.  Surface area ≈ 50.27, Volume ≈ 33.51

Radius = 8.64.  Surface area ≈ 938.07, Volume ≈ 2701.65



Fun fact:  A sphere of radius 3 will have the same surface area and volume, at approximately 113.09734.       

HP 12C:  Right Triangles – Area, Hypotenuse, and Grade given Rise and Run

Let y be the rise (height) and x be the run (length) of a right triangle.  Then:

Area = 1/2 * x * y
Hypotenuse = √(x^2 + y^2)
Grade = y/x * 100%   (like slope)

STEP
CODE
KEY
01
44, 1
STO 1
02
34
X<>Y
03
44, 0
STO 0
04
20
*
05
2
2
06
10
÷
07
31
R/S
08
45, 1
RCL 1
09
2
2
10
21
Y^X
11
45, 0
RCL 0
12
2
2
13
21
Y^X
14
40
+
15
43, 21
16
31
R/S
17
45, 0
RCL 0
18
45, 1
RCL 1
19
10
÷
20
1
1
21
26
EEX
22
2
2
23
20
*
24
43, 33, 00
GTO 00

Registers Used:
R0 = rise (y), R1 = run (x)

Input:  rise [ENTER] run [R/S],  height [ENTER] length [R/S]

Output:  area of a triangle [R/S], hypotenuse [R/S], grade

Example:  rise = 430, run = 1600
Input:  430 [ENTER] 1600 [R/S]
Results:  Area: 344000, Hypotenuse: 1656.77, Grade: 26.88 (%)

I hope you find this helpful.  Can you believe it is already October?  How fast time flies,

Eddie
  
This blog is property of Edward Shore, 2016.

                                                                                                                                                                                                                                                                  

RPN: DM32 and DM42: Stopping Sight Distance (Metric)

RPN: DM32 and DM42: Stopping Sight Distance (Metric) The Stopping Sight Distance Formula – Derivation The stopping sight di...