Tides(3) for the HP-41
Overview
1°) 4 M-Code Routines
2°) Los Angeles
3°) Miami
4°) Seattle
5°) Washington
-The 4 M-Code routines listed in §1 employ a polynomial approximation to calculate Cos x
>>> The formula is: Cos x ~ 1 - 1.5127 E-4 x2 + 3.445 E-9 x4 where x is between -90° & +90°
-The maximum error is about 0.00074
-So, it may be used to calculate the water-levels with a very small error.
-This method is already employed in one version of "WL37" but this program is very long and uses a lot of registers.
-So, if you want to calculate the water-levels for just one port, you can rewrite one of the programs listed in "Tides(2) for the HP41"
which will run significantly faster than the focal version.
1°) 4 M-Code Routines
08C "L"
013 "S"
003 "C"
288 SF 7
0B3 JNC+22d
0AF "/"
013 "S"
003 "C"
248 SF 9
02B JNC+05
0AA "*"
013 "S"
003 "C"
244 CF 9
0F8 C=X
10E A=C ALL
0B8 C=Y
0E8 X=C
0AE A<>C ALL
0A8 Y=C
108 SF 8
033 JNC+06
093 "S"
003 "C"
284 CF 7
244 CF 9
104 CF 8
2A0 SETDEC
0F8 C=X
128 L=C
05E C= | C |
10E A=C ALL
04E C
35C
050 =
210
226
226 180
268 Q=C
1FA C=C+C M
044 C
070 =
171
064 AmodC
10E A=C ALL
278 C=Q
2BE C=-C
01D C=
061 A+C
05E C= | C |
070 N=C ALL
10E A=C ALL
04E C
2BE
35C =
250
226 -90
268 Q=C
01D C=
060 A+C
2FE ?C<0
047 JC+08
278 C=Q
025 C=
060 AB+C
070 N=C ALL
278 C=Q
2BE C=-C
268 Q=C
0B0 C=N ALL
10E A=C ALL
135 C=
060 A*C
070 N=C ALL
04E C
35C
0D0
110
110
150 =
21C
250
250
050 3.445 E-9
13D C=
060 AB*C
04E C
35C
2BE
050
150 =
050
090
1D0
21C
250
250
190 -1.5127 E-4
025 C=
060 AB+C
0B0 C=N ALL
13D C=
060 AB*C
001 C=
060 AB+1
10E A=C ALL
278 C=Q
11E A=C MS
0AE A<>C ALL
0E8 X=C
10C FS? 8
067 JC+12d
28C FS? 7
3A0 ?NC RTN
078 C=Z
028 T=C
0B8 C=Y
068 Z=C
0F8 C=X
0A8 Y=C
138 C=L
0E8 X=C
3E0 RTN
10E A=C ALL
0B8 C=Y
24C FS? 9
05F JC+11d
135 C=
060 A*C
0E8 X=C
078 C=Z
0A8 Y=C
046 C
270 =
038 T
068 Z=C
3E0 RTN
261 C=
060 A/C
3B3 JNC-10d
( 140 lines )
"CS" calculates Cos x with the polynomial approximation: 1 - 1.5127 E-4 x2 + 3.445 E-9 x4 ( -90° <= x <= +90° )
"CSL" is "CS" LASTX
"CS*" calculates X Cos Y
"CS/" returns ( Cos Y ) / X
Warning: These routines do not check for alpha data
-Here are a few examples:
2°) Los Angeles CA 9410660
Data Registers: R00 to R07: temp
Flags: /
Subroutine: "J2" ( or "J0" or "J1" cf "Julian & Gregorian Calendars for the HP41" )
01 LBL "WLLA" 02 HR 03 24 04 / 05 X<>Y 06 XEQ "J2" 07 + 08 STO 00 09 .985647 10 * 11 STO 01 12 96 13 + 14 66 15 CS* 16 RCL 00 17 360 18 * 19 STO 02 20 46 21 + 22 3 23 CS* 24 - 25 RCL 02 26 RCL 01 27 - 28 STO 03 29 35 30 - 31 STO 07 32 RCL 00 33 .052954 34 * 35 235 36 + 37 STO 04 38 - 39 89 40 CS/ 41 RCL 07 42 CS 43 - 44 107 45 * 46 + 47 RCL 02 48 RCL 03 49 + |
50 53 51 + 52 12 53 CS* 54 - 55 RCL 01 56 ST+ 01 57 RCL 02 58 + 59 STO 03 60 17.7 61 - 62 STO 07 63 CSL 64 RCL 04 65 ST+ 07 66 - 67 50 68 CS/ 69 - 70 RCL 07 71 7.4 72 CS/ 73 + 74 343 75 * 76 - 77 RCL 02 78 ST+ 02 79 RCL 03 80 + 81 9 82 + 83 3 84 CS* 85 + 86 RCL 00 87 13.064993 88 * 89 STO 05 90 RCL 03 91 + 92 81 93 - 94 CSL 95 RCL 04 96 + 97 5 98 CS/ |
99 + 100 20 101 * 102 + 103 RCL 03 104 RCL 05 105 - 106 19 107 + 108 CSL 109 RCL 04 110 + 111 5 112 CS/ 113 + 114 12 115 * 116 + 117 RCL 00 118 26.352793 119 * 120 STO 06 121 RCL 03 122 X<>Y 123 ST- 03 124 + 125 17 126 + 127 CSL 128 RCL 04 129 + 130 STO 07 131 .64 132 CS* 133 + 134 RCL 07 135 RCL 04 136 + 137 7 138 CS/ 139 + 140 11 141 * 142 - 143 RCL 03 144 65.8 145 - 146 CSL 147 RCL 04 |
148 - 149 STO 07 150 5.3 151 CS/ 152 + 153 RCL 07 154 RCL 04 155 - 156 166 157 CS/ 158 - 159 218 160 * 161 + 162 RCL 03 163 RCL 05 164 + 165 32 166 + 167 4 168 CS* 169 - 170 RCL 03 171 RCL 05 172 - 173 STO 00 174 7 175 - 176 CSL 177 RCL 04 178 - 179 5.3 180 CS/ 181 + 182 39 183 * 184 - 185 RCL 00 186 RCL 05 187 - 188 44 189 + 190 4 191 CS* 192 + 193 RCL 02 194 38.9 195 + 196 203 |
197 CS* 198 - 199 RCL 02 200 RCL 05 201 - 202 65 203 + 204 3 205 CS* 206 - 207 RCL 01 208 ST- 06 209 RCL 02 210 + 211 STO 00 212 64 213 + 214 STO 07 215 CSL 216 RCL 04 217 ST+ 07 218 - 219 77 220 CS/ 221 - 222 RCL 07 223 .3 224 CS* 225 + 226 RCL 07 227 RCL 04 228 + 229 31 230 CS/ 231 + 232 60 233 * 234 + 235 RCL 00 236 RCL 05 237 - 238 63 239 - 240 2 241 CS* 242 + 243 RCL 03 244 RCL 06 245 - |
246 STO 03 247 RCL 05 248 + 249 29 250 + 251 CSL 252 RCL 04 253 - 254 5.3 255 CS/ 256 + 257 8 258 * 259 - 260 RCL 02 261 RCL 06 262 - 263 STO 03 264 9 265 - 266 CSL 267 RCL 04 268 - 269 27 270 CS/ 271 - 272 515 273 * 274 + 275 RCL 03 276 1.5 277 * 278 35 279 + 280 3 281 CS* 282 + 283 RCL 03 284 RCL 05 285 + 286 49 287 - 288 8 289 CS* 290 + 291 RCL 03 292 RCL 05 293 - |
294 STO 00 295 64 296 + 297 CSL 298 RCL 04 299 - 300 27 301 CS/ 302 - 303 121 304 * 305 - 306 RCL 00 307 RCL 05 308 - 309 35 310 - 311 15 312 CS* 313 - 314 RCL 03 315 RCL 06 316 - 317 STO 03 318 5 319 + 320 17 321 CS* 322 - 323 RCL 03 324 RCL 05 325 + 326 90 327 - 328 CSL 329 RCL 04 330 - 331 27 332 CS/ 333 - 334 23 335 * 336 + 337 861 338 + 339 E3 340 / 341 END |
( 508 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Y | YYYY.MNDD | / |
X | HH.MNSS (UT) | water level (m) |
Example: Water level in Los Angeles on
2015/07/16 at 21h41m UT ( YMD format )
2015.0716 ENTER^
---Execution time = 27s---
21.41
XEQ "WLLA" >>>> h = 0.708 m
Note:
-We have saved 12 seconds
3°) Miami Beach FL 8723170
Data Registers: R00 to R07: temp
Flags: /
Subroutine: "J2" ( or "J0" or "J1" cf "Julian & Gregorian Calendars for the HP41" )
01 LBL "WLM" 02 HR 03 24 04 / 05 X<>Y 06 XEQ "J2" 07 + 08 STO 00 09 .985647 10 * 11 STO 01 12 81 13 + 14 88 15 CS* 16 RCL 00 17 360 18 * 19 STO 02 20 RCL 01 21 - 22 STO 03 23 78 24 - 25 13 26 CS* 27 - 28 RCL 02 29 RCL 03 |
30 + 31 41 32 - 33 4 34 CS* 35 + 36 RCL 01 37 ST+ 01 38 RCL 02 39 ST+ 02 40 + 41 STO 03 42 55 43 - 44 STO 07 45 CS 46 RCL 00 47 .052954 48 * 49 235 50 + 51 STO 04 52 RCL 07 53 + 54 7.4 55 CS/ 56 + 57 42 58 * |
59 - 60 RCL 03 61 RCL 00 62 26.352793 63 * 64 STO 06 65 - 66 STO 03 67 38 68 + 69 CSL 70 RCL 04 71 - 72 5.3 73 CS/ 74 + 75 34 76 * 77 - 78 RCL 03 79 RCL 00 80 13.064993 81 * 82 STO 05 83 - 84 STO 00 85 78 86 + 87 CSL |
88 RCL 04 89 - 90 5 91 CS/ 92 + 93 6 94 * 95 + 96 RCL 01 97 49 98 - 99 62 100 CS* 101 - 102 RCL 02 103 44 104 - 105 75 106 CS* 107 + 108 RCL 01 109 ST- 06 110 RCL 02 111 + 112 STO 00 113 36 114 - 115 CSL 116 RCL 04 |
117 + 118 .3 119 CS* 120 + 121 20 122 * 123 - 124 RCL 00 125 RCL 05 126 - 127 48 128 + 129 CSL 130 RCL 04 131 + 132 .4 133 CS* 134 + 135 ST+ X 136 + 137 RCL 02 138 RCL 06 139 - 140 STO 03 141 64 142 - 143 CSL 144 RCL 04 145 - |
146 27 147 CS/ 148 - 149 373 150 * 151 - 152 RCL 03 153 RCL 05 154 + 155 62 156 + 157 10 158 CS* 159 + 160 RCL 03 161 RCL 05 162 - 163 STO 00 164 7 165 + 166 CSL 167 RCL 04 168 - 169 27 170 CS/ 171 - 172 85 173 * 174 + |
175 RCL 00 176 RCL 05 177 - 178 78 179 + 180 11 181 CS* 182 - 183 RCL 03 184 RCL 06 185 - 186 STO 03 187 84 188 - 189 11 190 CS* 191 + 192 RCL 03 193 RCL 05 194 + 195 38 196 + 197 16 198 CS* 199 + 200 428 201 + 202 E3 203 / 204 END |
( 314 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Y | YYYY.MNDD | / |
X | HH.MNSS (UT) | water level (m) |
Example: Let's find the water level in
Miami on 2015/08/08 at 7h41m UT
7.41 XEQ "WLS" >>>> h = 0.772 m ---Execution time = 16s---
Note:
-We have saved 8 seconds
4°) Seattle WA 9447130
Flags: /
Subroutine: "J2" ( or "J0" or "J1" cf "Julian & Gregorian Calendars for the HP41" )
01 LBL "WLS" 02 HR 03 24 04 / 05 X<>Y 06 XEQ "J2" 07 + 08 STO 00 09 .985647 10 * 11 STO 01 12 13 13 - 14 77 15 CS* 16 RCL 00 17 360 18 * 19 STO 02 20 44 21 - 22 16 23 CS* 24 - 25 RCL 02 26 RCL 01 27 - 28 STO 03 29 73 30 + 31 STO 07 32 RCL 00 33 .052954 34 * 35 235 36 + 37 STO 04 38 - 39 89 40 CS/ 41 RCL 07 42 CS 43 - 44 258 45 * 46 - 47 RCL 02 48 RCL 03 49 + 50 34 51 - 52 16 53 CS* 54 + 55 RCL 01 56 ST+ 01 57 RCL 02 58 + 59 STO 03 60 87 61 - 62 STO 07 63 CLS 64 RCL 04 65 ST+ 07 66 - 67 50 68 CS/ 69 - 70 RCL 07 71 7.4 72 CS/ |
73 + 74 834 75 * 76 - 77 RCL 02 78 ST+ 02 79 RCL 03 80 + 81 41 82 - 83 2 84 CS* 85 - 86 RCL 00 87 13.064993 88 * 89 STO 05 90 RCL 03 91 + 92 3 93 + 94 STO 06 95 CLS 96 RCL 04 97 ST+ 06 98 - 99 34 100 CS/ 101 - 102 RCL 06 103 5 104 CS/ 105 + 106 40 107 * 108 - 109 RCL 03 110 RCL 05 111 - 112 78 113 - 114 CLS 115 RCL 04 116 + 117 5 118 CS/ 119 + 120 27 121 * 122 + 123 RCL 03 124 RCL 00 125 13.176396 126 * 127 STO 06 128 ST+ 06 129 - 130 72 131 - 132 5 133 CS* 134 - 135 RCL 06 136 77 137 - 138 CLS 139 RCL 04 140 + 141 2.4 142 CS/ 143 + 144 22 |
145 * 146 + 147 RCL 03 148 3 149 * 150 RCL 06 151 - 152 68 153 + 154 STO 07 155 CLS 156 RCL 04 157 ST+ 07 158 - 159 18 160 CS/ 161 - 162 RCL 07 163 7.4 164 CS/ 165 + 166 34 167 * 168 + 169 RCL 03 170 RCL 06 171 ST- 03 172 + 173 75 174 - 175 CLS 176 RCL 04 177 + 178 STO 07 179 .64 180 CS* 181 + 182 RCL 04 183 RCL 07 184 + 185 7.5 186 CS/ 187 + 188 32 189 * 190 - 191 RCL 03 192 51.9 193 + 194 CLS 195 RCL 04 196 - 197 STO 07 198 5.3 199 CS/ 200 + 201 RCL 07 202 RCL 04 203 - 204 166 205 CS/ 206 - 207 461 208 * 209 - 210 RCL 03 211 RCL 05 212 + 213 65 214 - 215 CLS 216 RCL 04 |
217 - 218 5.4 219 CS/ 220 + 221 10 222 * 223 - 224 RCL 03 225 RCL 05 226 - 227 STO 00 228 72 229 - 230 CLS 231 RCL 04 232 - 233 5.3 234 CS/ 235 + 236 75 237 * 238 - 239 RCL 00 240 RCL 05 241 - 242 22 243 - 244 CLS 245 RCL 04 246 - 247 5.3 248 CS/ 249 + 250 8 251 * 252 + 253 RCL 01 254 31 255 - 256 33 257 CS* 258 + 259 RCL 02 260 37 261 - 262 268 263 CS* 264 + 265 RCL 02 266 RCL 05 267 - 268 3 269 + 270 20 271 CS* 272 + 273 RCL 01 274 ST- 06 275 RCL 02 276 + 277 STO 00 278 18 279 - 280 STO 07 281 CLS 282 RCL 04 283 ST+ 07 284 - 285 77 286 CS/ 287 - 288 RCL 07 |
289 .3 290 CS* 291 + 292 RCL 07 293 RCL 04 294 + 295 31 296 CS/ 297 + 298 79 299 * 300 - 301 RCL 00 302 RCL 05 303 - 304 15 305 + 306 CLS 307 RCL 04 308 + 309 .44 310 CS* 311 + 312 11 313 * 314 + 315 RCL 03 316 RCL 06 317 - 318 STO 03 319 RCL 05 320 + 321 35 322 - 323 CLS 324 RCL 04 325 - 326 5.3 327 CS/ 328 + 329 15 330 * 331 - 332 RCL 02 333 RCL 03 334 + 335 36 336 + 337 STO 07 338 CLS 339 RCL 04 340 ST+ 07 341 - 342 16 343 CS/ 344 + 345 RCL 07 346 50 347 CS/ 348 - 349 34 350 * 351 - 352 RCL 02 353 RCL 06 354 - 355 STO 03 356 54.1 357 - 358 CLS 359 RCL 04 360 - |
361 27 362 CS/ 363 - 364 1072 365 * 366 - 367 RCL 02 368 RCL 06 369 + 370 59 371 - 372 8 373 CS* 374 + 375 RCL 03 376 3 377 * 378 STO 00 379 84 380 - 381 CLS 382 RCL 04 383 - 384 9 385 CS/ 386 - 387 9 388 * 389 - 390 RCL 00 391 2 392 / 393 42 394 + 395 5 396 CS* 397 + 398 RCL 03 399 RCL 05 400 + 401 29 402 + 403 CLS 404 RCL 04 405 - 406 27 407 CS/ 408 - 409 45 410 * 411 + 412 RCL 03 413 RCL 05 414 - 415 STO 00 416 27 417 + 418 CLS 419 RCL 04 420 - 421 27 422 CS/ 423 - 424 216 425 * 426 + 427 RCL 00 428 RCL 05 429 - 430 69 431 - 432 24 |
433 CS* 434 + 435 RCL 03 436 RCL 06 437 - 438 STO 03 439 36 440 + 441 CLS 442 RCL 04 443 - 444 27 445 CS/ 446 - 447 34 448 * 449 + 450 RCL 03 451 RCL 05 452 + 453 46 454 + 455 CLS 456 RCL 04 457 - 458 27 459 CS/ 460 - 461 45 462 * 463 + 464 RCL 02 465 RCL 03 466 + 467 STO 03 468 73 469 + 470 CLS 471 RCL 04 472 - 473 13 474 CS/ 475 - 476 21 477 * 478 + 479 RCL 03 480 ST+ 06 481 RCL 05 482 - 483 29 484 - 485 9 486 CS* 487 + 488 RCL 06 489 87 490 + 491 CLS 492 RCL 04 493 - 494 28 495 CS/ 496 - 497 12 498 * 499 - 500 2024 501 + 502 E3 503 / 504 END |
( 741 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Y | YYYY.MNDD | / |
X | HH.MNSS (UT) | water level (m) |
Example: Let's find the water level in
Seattle on 2015/07/16 at 12h34m56s UT
2015.0716 ENTER^
12.3456
XEQ "WLS" >>>> h = 3.070
m
---Execution time = 38s---
Note:
5°) Washington D.C. 8594900
Data Registers: R00 to R07: temp
Flags: /
Subroutine: "J2" ( or "J0" or "J1" cf "Julian & Gregorian Calendars for the HP41" )
01 LBL "WLW" 02 HR 03 24 04 / 05 X<>Y 06 XEQ "J2" 07 + 08 STO 00 09 .985647 10 * 11 STO 01 12 169 13 + 14 77 15 CS* 16 RCL 00 17 360 18 * 19 STO 02 20 36 21 + 22 12 23 CS* 24 - 25 RCL 02 26 RCL 01 27 - 28 STO 03 29 14 30 - 31 STO 07 32 RCL 00 33 .052954 34 * 35 235 36 + 37 STO 04 38 - 39 89 40 CS/ 41 RCL 07 42 CS 43 - 44 13 45 * 46 - 47 RCL 02 48 RCL 03 49 + 50 79 51 + 52 5 |
53 CS* 54 - 55 RCL 01 56 ST+ 01 57 RCL 02 58 + 59 STO 03 60 13 61 + 62 CSL 63 RCL 04 64 + 65 7.4 66 CS/ 67 + 68 46 69 * 70 + 71 RCL 02 72 ST+ 02 73 RCL 03 74 + 75 90 76 + 77 4 78 CS* 79 + 80 RCL 00 81 13.064993 82 * 83 STO 05 84 RCL 03 85 + 86 26 87 - 88 3 89 CS* 90 - 91 RCL 03 92 RCL 05 93 - 94 52 95 + 96 2 97 CS* 98 - 99 RCL 00 100 26.352793 101 * 102 STO 06 103 RCL 03 104 3 |
105 * 106 X<>Y 107 - 108 71 109 + 110 CSL 111 RCL 04 112 + 113 7.4 114 CS/ 115 + 116 12 117 * 118 - 119 RCL 03 120 RCL 06 121 ST- 03 122 + 123 16 124 + 125 CSL 126 RCL 04 127 + 128 .64 129 CS* 130 + 131 3 132 * 133 + 134 RCL 03 135 76 136 - 137 CSL 138 RCL 04 139 - 140 5.3 141 CS/ 142 + 143 35 144 * 145 - 146 RCL 03 147 RCL 05 148 - 149 STO 00 150 12 151 + 152 CSL 153 RCL 04 154 - 155 5.3 156 CS/ |
157 + 158 7 159 * 160 + 161 RCL 00 162 RCL 05 163 - 164 CS 165 - 166 RCL 01 167 20 168 - 169 38 170 CS* 171 - 172 RCL 02 173 64 174 - 175 52 176 CS* 177 + 178 RCL 02 179 RCL 05 180 - 181 6 182 + 183 13 184 CS* 185 + 186 RCL 01 187 ST- 06 188 RCL 02 189 + 190 STO 00 191 42 192 - 193 STO 07 194 CSL 195 RCL 04 196 + 197 .3 198 CS* 199 + 200 18 201 * 202 - 203 RCL 00 204 RCL 05 205 - 206 38 207 + 208 CSL |
209 RCL 04 210 + 211 .44 212 CS* 213 + 214 7 215 * 216 + 217 RCL 03 218 RCL 06 219 - 220 STO 03 221 RCL 05 222 + 223 CS 224 + 225 RCL 02 226 RCL 03 227 + 228 4 229 - 230 11 231 CS* 232 + 233 RCL 02 234 RCL 06 235 - 236 STO 03 237 63.9 238 - 239 CSL 240 RCL 04 241 - 242 27 243 CS/ 244 - 245 407 246 * 247 - 248 RCL 03 249 3 250 * 251 STO 00 252 38 253 + 254 CSL 255 RCL 04 256 - 257 9 258 CS/ 259 - 260 12 |
261 * 262 - 263 RCL 03 264 RCL 05 265 + 266 62 267 + 268 CSL 269 RCL 04 270 - 271 27 272 CS/ 273 - 274 27 275 * 276 + 277 RCL 03 278 RCL 05 279 - 280 STO 00 281 12 282 + 283 CSL 284 RCL 04 285 - 286 27 287 CS/ 288 - 289 75 290 * 291 + 292 RCL 00 293 RCL 05 294 - 295 84 296 - 297 7 298 CS* 299 + 300 RCL 03 301 RCL 06 302 - 303 STO 03 304 25 305 - 306 8 307 CS* 308 - 309 RCL 03 310 RCL 05 311 + 312 40 |
313 + 314 17 315 CS* 316 + 317 RCL 02 318 RCL 03 319 + 320 STO 03 321 48 322 - 323 CSL 324 RCL 04 325 - 326 13 327 CS/ 328 - 329 42 330 * 331 + 332 RCL 03 333 RCL 05 334 - 335 27 336 + 337 CSL 338 RCL 04 339 - 340 13 341 CS/ 342 - 343 16 344 * 345 - 346 RCL 03 347 ST+ X 348 80 349 + 350 4 351 CS* 352 + 353 RCL 03 354 RCL 06 355 + 356 53 357 - 358 11 359 CS* 360 - 361 472 362 + 363 E3 364 / 365 END |
( 531 bytes / SIZE 008 )
STACK | INPUTS | OUTPUTS |
Y | YYYY.MNDD | / |
X | HH.MNSS (UT) | water level (m) |
Example: Water level in Washington on
2015/06/22 at 17h06 UT
2015.0622 ENTER^
17.06
XEQ "WLW" >>>> h = 0.899 m
---Execution
time = 28s---
Notes:
-In this example, we have saved 13 seconds.
-All the other programs listed in "Tides(2) for the HP41" paragraph 2°) may be transformed in the same way.
-Use Sin x = Cos ( x - 90° ) or Sin x = - Cos ( x + 90° ) ....
-It doesn't change a lot the number of bytes.