Any Browser Campaign

"Goat's Pasture Ground" for HP-41CX
deutsche Version

Pictures do come later !

Let this task be given : There is a spherical pasture with area AP. At the boundary a goat is put on the lead. How long is the lead to be permitted, so that the goat can graze up to exactly one half (or any other percentage p) of the pasture ground ?

The task is solved as follows :

AG consists of A1 + A2 (picture 2).

The area of segment A1 can be calculated as follows :


A1 = r12
2

p2a
180
- sin2a
(picture 3)

Correspondingly A2 is calculated :


A2 = r22
2

pb
90
- sin2b

The variables r2 and b are then calculated (see picture 4) :


y
= r1 ·cosa
x
= r1 ·cosg = r1 ·cos(90 - a)
z
= r1 - y
r2
=   ______
x2 + z2
 
cosb
= z
r2
b = arccos z
r2

(Note : equations translated from TEX by TTH, version 2.70.)

Now the calculation is done in this manner : r1 is given (radius of pasture ground), a (not 2a !) has to be entered by the user. Now the HP-41CX computes A1, A2, and AP. Then it is checked, whether

If the calculated value of A1 + A2 is greater than the target value, then a is decremented by a tenth power lesser. If it is lesser than the target value, it is a tenth power lesser incremented. In this way the area is approximated more and more, until the desired accuracy is achieved.

Admissible values of A1 + A2 (= AG) lie in the range 0% < p < 100%.

Course of Program :

On starting the program first r1 has to be entered. Then the user must provide the percentage of the pasture ground AP, which the goat is permitted to graze. Now a seed for a must be entered (a suitable value for 50% will be 60°). The better the given angle coincides with the real angle a, the faster the program converges, of course. Finally the desired accuracy (number of digits) must be entered.

Now the HP-41CX computes a first approximation for r2, i.e. the length of the goat's lead. This value remains in the display, until a new one is found. Has the desired accuracy for r2 been reached, the BEEP will sound. After clearing the display with "<-" the a value appears (X register), while b is stored in Y register.

If battery voltage decreases too much during program execution the HP-41CX powers off itself. After power on "BATTERY" is displayed to indicate the problem. Program execution must be terminated now.

Contents of Registers :

R00 : number of digits (accuracy)
R01 : r1
R02 : r2
R03 : a
R04 : b
R05 : x
R06 : y
R07 : z
R08 : AP
R09 : A1
R10 : increment / decrement of a
R11 : value of AG = A1 + A2 in percentage of the value AP

Program Listing :

001 LBL "GOAT"
001  ,011
003  CLRGX
004  CF 00
005  CF 01
006  CLST
007 LBL 00
008  CF 22
009  "R1 ="
010  PROMPT
011  FC? 22
012  GTO 00
013  X<=0?
014  GTO 00
015  STO 01
016 LBL 05
017  CF 22
018  "%-AREA ?"
019  PROMPT
020  FC? 22
021  GTO 05
022  X<=0?
023  GTO 05
024   E2
025  /
026  STO 11
027 LBL 08
028   E1
029  "START-A ="         (Instead of "A" I typed the angle sign (hexadezimal 0D))
030  PROMPT
031  ABS
032  STO 03
033 LBL 01
034  CF 22
035  "NUM. DIGITS ?"
036  PROMPT
037  FC? 22
038  GTO 01
039   E3
040  /
041  STO 00
042 LBL 15
043  FC? 49
044  GTO 07
045  "BATTERY"
046  SF 11
047  OFF
048  AVIEW
049  STOP
050 LBL 07
051  RCL 01
052  RCL 03
053  COS
054  *
055  STO 06
056  RCL 01
057  90
058  RCL 03
059  -
060  COS
061  *
062  STO 05
063  RCL 01
064  RCL 06
065  -
066  STO 07
067  X^2
068  RCL 05
069  X^2
070  +
071  SQRT
072  STO 02
073  RCL 07
074  X<>Y
075  /
076  ACOS
077  STO 04
078  PI
079  RCL 01
080  X^2
081  *
082  STO 08
083  LASTX
084  PI
085  RCL 03
086  *
087  90
088  /
089  RCL 03
090  XEQ 02
091  STO 09
092  RCL 02
093  X^2
094  PI
095  RCL 04
096  *
097  90
098  /
099  RCL 04
100  XEQ 02
101  RCL 09
102  +
103  FIX IND 00
104  RND
105  RCL 08
106  RCL 11
107  *
108  RND
109  X=Y?
110  GTO 03
111  X>Y?
112  GTO 04
113  FS? 01
114  GTO 09
115  RCL 03
116  STO 10
117  2
118  ST/ 03
119  GTO 10
120 LBL 09
121  XEQ 13
122  -
123  STO 03
124 LBL 10
125  SF 00
126  GTO 15
127 LBL 04
128  FS? 00
129  GTO 11
130  RCL 03
131  STO 10
132  2
133  ST* 03
134  GTO 12
135 LBL 11
136  XEQ 13
137  +
138  STO 03
139 LBL 12
140  SF 01
141  GTO 15
142 LBL 13
143  RCL 03
144  RCL 10
145  -
146  ABS
147  2
148  /
149  RCL 03
150  STO 10
151  X<>Y
152  RTN
153 LBL 02
154  2
155  *
156  SIN
157  -
158  *
159  2
160  /
161  RTN
162 LBL 03
163  TONE 7
164  RCL 00
165  ISG X
166  ""            (NOP)
167  CLA
168  FIX 0
169  SF 28
170  ARCL X
171  " APPROX. :"
172  AVIEW
173  PSE
174  CF 28
175  FIX IND 00
176  "R2 = "
177  ARCL 02
178  AVIEW
179  ISG 00
180  GTO 15
181  BEEP
182  RCL 04
183  RCL 03
184  ,011
185  CLRGX
186  CLA
187  CF 00
188  CF 01
189  FIX 4
190  R^
191  CLX
192  RDN
193  CLX
194  STO L
195  RDN
196  END


Back to HP-41CX Selected (game) programs

Back to Natural Sciences and Mathematical Games

Back to the starting page

Kai Schröder, 30.5.2001