The Museum of HP Calculators

# Tides for the HP-41

This program is Copyright © 2003 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

## Overview

-Three programs are listed hereafter:

1°)    "WL"    calculates the water level using the harmonic method.
2°) "TIDE1"  gives the high tides or low tides using 5 tabular values.
3°) "TIDE2"  yields these results more directly.

1°)  Water Level

-The water level may be computed by a trigonometric series:       wl(t) = A0 + A1 cos ( V1 - G1 ) + ............ + Ai cos ( Vi - Gi ) + ..........
where  A0 = the mean sea level ;  Ai and Gi = the harmonic constituents of a port = constants.
Vi  are linear combinations of astronomical arguments.
-The following program uses a few terms ( Sa ; Q1 ; O1 ; K1 ; N2 ; M2 ; S2 ; MN4 ; M4 ; MS4 )
-Under simplifying assumptions , 11 other terms are calculated ( namely: P1 ; o1 ; k1 ; 2N2 ; µ2 ; nu2 ; L2 ; K2 ; T2 ; m2 ; k2 )
-The results are good but not very accurate: errors can reach about 20cm.
-More than 100 sinusoidal functions would be needed to achieve full accuracy

-You can find other harmonic constituents at   http://co-ops.nos.noaa.gov/data_retrieve.shtml?input_code=100201001har
-For accurate tide predictions , cf also  www.shom.fr

Data Registers:             R00 = d = the number of days since 01/01/2000      R01 thru R06:  temp
•   R07 thru R27 = the harmonic constituents of a port. These 21 registers are to be initialized before executing "WL"

Flags: /
Subroutine:  none if you have a Time-Module
"J0" otherwise  ( cf "Phases of the Moon for the HP-41" )

-The harmonic constituents of a few ports are listed below:  Ai  are given in millimeters and  Gi  in degrees.

 Port  Latitude Longitude A0=R07 A1=R08 A2=R09 A3=R10 A4=R11 A5=R12 A6=R13 A7=R14 A8=R15 A9=R16 A10=R17 Time Scale / G1=R18 G2=R19 G3=R20 G4=R21 G5=R22 G6=R23 G7=R24 G8=R25 G9=R26 G10=R27

 Bombay    18°55'N    72°50'E 2520 43 41 201 425 287 1227 479 7 35 32 Time Scale = UT+5h30mn / 33 58 52 56 327 345 25 296 332 43
-
 Boston  42°21'N    71°02'W 1490 32 20 111 140 301 1345 219 0 20 9 Time Scale = UT-5h / 131 110 119 132 300 326 356 0 98 118
-
 Brest    48°23'N    04°30'W 4020 47 20 67 65 415 2040 746 19 54 34 Time Scale = UT+1h / 243 294 342 89 119 138 178 117 164 239
-
 Colombo    6°57'N    79°51'E 380 95 10 29 73 22 176 119 7 5 3 Time Scale = UT+5h30mn / 308 82 59 36 31 50 100 269 169 258
-
 Dakar   14°40'N     17°25'W 1010 87 12 38 63 91 461 166 0 10 6 Time Scale = UT / 153 194 251 350 235 257 293 0 282 0
-
 Dar Es-Salaam   6°49'S  39°19'E 1530 35 22 106 171 191 1074 536 4 11 7 Time Scale = UT+3h / 311 30 43 42 86 111 156 250 316 31
-
 Djibouti  11°35'N     43°09'E 1870 107 38 192 386 126 463 205 0 0 0 Time Scale = UT+3h / 6 41 39 39 222 229 250 0 0 0
-
 Hong-Kong  22°17'N   114°11'E 1380 100 54 289 359 85 404 162 8 25 17 Time Scale = UT+8h / 215 225 249 299 250 268 299 268 333 19
-
 Libreville     0°23'N      9°26'E 1290 90 6 17 95 120 595 193 9 28 17 Time Scale = UT+1h / 282 126 328 8 140 146 176 34 82 148
-
 Lisbon   38°42'N     09°08'W 2200 20 15 61 68 238 1150 401 0 77 48 Time Scale = UT+1h / 33 277 334 73 89 106 136 0 303 342
-
 Los Angeles  33°43'N   118°16'W 850 65 39 216 339 119 515 203 0 0 0 Time Scale = UT-8h / 186 77 81 88 257 275 261 0 0 0
-
 Madras    13°06'N    80°18'E 650 102 1 28 90 72 332 137 1 2 2 Time Scale = UT+5h30mn / 221 86 313 341 235 243 279 77 102 179
-
 Melbourne  37°52'S   144°55'E 560 0 10 70 90 40 240 60 0 10 0 Time Scale = UT+10h / 0 88 96 135 14 64 198 0 95 0
-
 Miami    25°46'N    80°08'W 380 88 6 33 41 84 365 73 0 0 0 Time Scale = UT-5h / 199 214 199 170 219 236 255 0 0 0
-
 Montevideo  34°55'S    56°13'W 640 53 31 78 23 55 136 38 19 39 13 Time Scale = UT-3h / 314 104 139 315 352 30 106 147 181 268
-
 Nassau  25°05'N     77°21'W 850 95 12 65 87 92 379 64 0 5 0 Time Scale = UT-5h / 144 128 132 122 204 223 242 0 85 0
-
 New-York  40°42'N    74°01'W 700 83 13 52 98 143 641 133 0 14 16 Time Scale = UT-5h / 134 123 111 107 222 237 258 0 335 308
-
 Oslo     59°55'N     10°44'E 150 137 8 21 3 32 112 36 0 19 12 Time Scale = UT+1h / 185 223 287 222 99 136 97 0 21 117
-
 Plymouth (GB) 50°22'N  4°11'W 3350 121 16 59 74 316 1691 603 51 144 95 Time Scale = UT / 219 312 341 109 137 154 207 107 135 188
-
 Port-au-Prince 18°33'N  72°21'W 180 74 0 41 70 33 145 42 0 0 0 Time Scale = UT-5h / 164 0 145 154 242 249 260 0 0 0
-
 Rio de Janeiro  22°53'S  43°10'W 690 27 26 92 62 26 318 179 20 48 31 Time Scale = UT-3h / 21 110 104 144 174 93 88 224 96 186
-
 Rotterdam  51°55'N     4°30'E 940 90 40 80 60 90 660 140 0 110 70 Time Scale = UT+1h / 315 170 221 32 137 153 213 0 245 301
-
 San Francisco 37°48'N  122°27'W 910 30 40 230 369 116 543 123 0 23 9 Time Scale = UT-8h / 199 97 99 108 320 343 339 0 50 47
-
 Singapore    1°16'N   103°51'E 1600 131 61 283 294 143 796 326 6 15 19 Time Scale = UT+8h / 281 25 64 117 306 326 21 333 298 348
-
 Seattle      47°36'N  122°20'W 2010 74 75 458 831 212 1060 258 0 21 10 Time Scale = UT-8h / 289 143 144 157 113 140 158 0 92 120
-
 Sydney (Aus)  33°51'S   151°14'E 910 33 25 96 147 111 518 131 1 4 3 Time Scale = UT+10h / 61 54 82 121 222 239 264 132 149 149
-
 Ushuaia    54°49'S    68°13'W 1100 45 34 155 199 148 560 64 6 16 8 Time Scale = UT-3h / 66 349 13 59 114 154 163 299 346 67
-
 Valparaiso  33°02'S    71°38'W 910 36 20 102 159 96 441 146 0 0 0 Time Scale = UT-4h / 4 268 301 341 275 305 323 0 0 0
-
 Vancouver  49°17'N   123°07'W 3060 0 89 470 860 179 940 230 0 0 0 Time Scale = UT-8h / 0 134 154 169 144 164 186 0 0 0
-
 Vera Cruz  19°11'N    96°07'W 310 53 37 153 155 23 88 27 0 0 0 Time Scale = UT-6h / 184 281 289 289 57 69 71 0 0 0
-
 Washington  38°52'N    77°01'W 460 89 0 32 48 81 423 62 0 34 0 Time Scale = UT-5h / 120 0 307 278 218 237 273 0 27 0

001  LBL "WL"
002  HR
003  24
004  /
005  X<>Y
006  1.012                If you don't have a Time Module, replace the 3 lines 06-07-08 by the 2 lines:     XEQ "J0"    +
007  DDAYS
008  -
009  LBL "T"
010  STO 00
011  DEG
012  .985647
013  *
014  STO 01
015  10
016  +
017  RCL 18
018  -
019  SIN
020  RCL 08
021  *
022  RCL 07
023  +
024  RCL 00
025  360
026  *
027  STO 02
028  RCL 01
029  +
030  STO 04
031  10
032  +
033  RCL 21
034  -
035  COS
036  RCL 11
037  *
038  +
039  RCL 04
040  .052954
041  RCL 00
042  *
043  STO 06
044  +
045  65
046  +
047  RCL 21
048  -
049  COS
050  RCL 11
051  *
052  7.4
053  /
054  -
055  RCL 02
056  ST+ 02
057  RCL 01
058  -
059  10
060  -
061  RCL 21
062  -
063  COS
064  RCL 11
065  *
066  3
067  /
068  +
069  RCL 04
070  ST+ 04
071  26.352793
072  RCL 00
073  *
074  STO 03
075  -
076  STO 05
077  53
078  -
079  RCL 20
080  -
081  COS
082  RCL 10
083  *
084  -
085  RCL 05
086  RCL 06
087  -
088  72
089  +
090  RCL 20
091  -
092  COS
093  RCL 10
094  *
095  5.3
096  /
097  -
098  RCL 05
099  13.064993
100  RCL 00
101  *
102  STO 05
103  -
104  2
105  -
106  RCL 19
107  -
108  COS
109  RCL 09
110  *
111  +
112  RCL 02
113  RCL 24
114  -
115  COS
116  RCL 14
117  *
118  +
119  RCL 04
120  20
121  +
122  RCL 24
123  -
124  COS
125  RCL 14
126  *
127  3.7
128  /
129  -
130  RCL 04
131  RCL 06
132  +
133  75
134  +
135  RCL 24
136  -
137  COS
138  RCL 14
139  *
140  12
141  /
142  +
143  RCL 04
144  RCL 03
145  -
146  STO 04
147  43.5
148  -
149  RCL 23
150  -
151  COS
152  RCL 13
153  *
154  -
155  RCL 04
156  RCL 06
157  -
158  8
159  -
160  RCL 23
161  -
162  SIN
163  RCL 13
164  *
165  27
166  /
167  -
168  RCL 04
169  RCL 05
170  +
171  5
172  -
173  RCL 23
174  -
175  SIN
176  RCL 13
177  *
178  35
179  /
180  -
181  RCL 02
182  RCL 01
183  -
184  3
185  +
186  RCL 24
187  -
188  COS
189  RCL 14
190  *
191  17
192  /
193  +
194  RCL 04
195  RCL 05
196  -
197  8
198  +
199  RCL 22
200  -
201  COS
202  RCL 12
203  *
204  +
205  RCL 04
206  RCL 05
207  ST+ X
208  -
209  60
210  +
211  RCL 22
212  -
213  COS
214  RCL 12
215  *
216  7.6
217  /
218  -
219  RCL 02
220  RCL 04
221  +
222  44
223  -
224  RCL 27
225  -
226  COS
227  RCL 17
228  *
229  -
230  RCL 04
231  ST+ X
232  STO 01
233  3
234  +
235  RCL 26
236  -
237  SIN
238  RCL 16
239  *
240  +
241  RCL 01
242  RCL 02
243  -
244  STO 06
245  3
246  +
247  RCL 22
248  -
249  SIN
250  RCL 12
251  *
252  6.3
253  /
254  +
255  RCL 05
256  RCL 06
257  +
258  41
259  +
260  RCL 22
261  -
262  COS
263  RCL 12
264  *
265  5.3
266  /
267  +
268  RCL 01
269  RCL 05
270  -
271  35
272  -
273  RCL 25
274  -
275  COS
276  RCL 15
277  *
278  -
279   E3
280  /
281  END

( 387 bytes / SIZE 028 )

 STACK INPUTS OUTPUTS Y Date / X hh.mnss water level (m)

Example:     Calculate the water level in Seattle on   11/11/2003  at 14h45mn  ( local time = UT-8h )

-First, we initialize registers R07 to R27   ( 2010 STO 07   74 STO 08   75 STO 09 ...................  92  STO 26  120  STO 27 )

-Then,  11.112003 ENTER^
14.45         XEQ "WL"   yields   2.75m    ( in 24 seconds )

( Key in  2003.1111 instead of  11.112003  if you are using "J0" )

-Similar computations produce the following results:

 time 0h 1h 2h 3h 4h 5h 6h 7h 8h 9h 10h 11h 12h 13h 14h 15h 16h 17h 18h 19h 20h 21h 22h 23h 24h wl -0.35 -0.06 0.56 1.35 2.15 2.82 3.28 3.48 3.43 3.18 2.82 2.49 2.31 2.34 2.54 2.82 3.03 3.08 2.91 2.52 1.93 1.23 0.52 -0.05 -0.34

Water Level - SEATTLE - 11/11/2003
|
|                      -   -
|               -               -                                           -
|          -                          -                        -                      -
|       -                                      -     -                                    -
|     -                                                                                       -
|   -                                                                                            -
|  -                                                                                               -
----|----------------------------------|----------------------------------|------ ( local time = UT-8h )
0h                                              12h                                               24h

2°) Tides  ( with 5 tabular values )

-   "TIDE1"  uses 5 tabular water levels  wl(t1)  wl(t2)  wl(t3)  wl(t4)  wl(t5)  where    t5 - t4  =  t4 - t3  =  t3 - t2  =  t2 - t1  =  h   ( equally spaced abcissas )
-The extremum of a polynomial of degree 4 is found by an iterative method.

Data Registers:             R00 and  R28 thru R32:  temp  ;   R07 thru R27 are undisturbed.

•   R01 =  wl(t1)
•   R02 =  wl(t2)
•   R03 =  wl(t3)      these 5 registers are to be initialized before executing "TIDE1"
•   R04 =  wl(t4)
•   R05 =  wl(t5)

Flags: /
Subroutine:  /

01  LBL "TIDE1"
02  STO 28
03  X<>Y
04  STO 00
05  CLX
06  STO 06
07  RCL 05
08  RCL 01
09  -
10  RCL 02
11  RCL 04
12  -
13  ST+ X
14  +
15  STO 29
16  CHS
17  LASTX
18  3
19  *
20  -
21  STO 30
22  RCL 01
23  RCL 05
24  +
25  RCL 02
26  RCL 04
27  +
28  16
29  *
30  -
31  RCL 03
32  30
33  *
34  +
35  STO 31
36  RCL 03
37  24
38  *
39  -
40  RCL 02
41  RCL 04
42  +
43  12
44  *
45  +
46  STO 32
47  LBL 01
48  RCL 32
49  ST+ X
50  RCL 06
51  *
52  RCL 29
53  3
54  *
55  +
56  RCL 06
57  X^2
58  *
59  RCL 30
60  +
61  RCL 31
62  /
63  ENTER^
64  X<> 06
65  -
66  ABS
67   E-4
68  X<Y?
69  GTO 01
70  RCL 06
71  RCL 06
72  RCL 06
73  RCL 32
74  *
75  RCL 29
76  ST+ X
77  +
78  *
79  RCL 31
80  -
81  *
82  RCL 30
83  ST+ X
84  +
85  *
86  24
87  /
88  RCL 03
89  +
90  RCL 00
91  RCL 06
92  2
93  +
94  *
95  HMS
96  RCL 28
97  HMS+
98  END

( 135 bytes / SIZE 033 )

 STACK INPUTS OUTPUTS Y h water level X t1 ( hh.mnss ) hh.mnss

Example:    With    wl(5) = 2.82  STO 01
wl(6) = 3.28  STO 02
wl(7) = 3.48  STO 03
wl(8) = 3.43  STO 04
wl(9) = 3.18  STO 05

1  ENTER^
5  XEQ "TIDE1"  yields    7.1654   ( in 6 seconds )
X<>Y   3.4898

-Thus, there is a high tide at 7h17mn and the corresponding water level = 3.49m  ( error = 15 minutes )

3°) Tides ( without tabular values )

-The following program calculates 3 water levels.
-Then, it finds the extremum of the parabola thus defined and its abscissa replaces one of the 3 first abscissas.
-The process is repeated until the difference between 2 abscissas is smaller than E-4 day ( line 65 )

Data Registers:             R28 thru R33:  temp  (  R07 thru R27 are undisturbed  )

Flags: /
Subroutine:  "T" ( line 9 of the program "WL")
(  and "J0" & "DT" if you don't have a Time Module - cf "Phases of the Moon for the HP-41" )

01  LBL "TIDE2"
02  HR
03  24
04  /
05  X<>Y
06  1.012
07  DDAYS                If you don't have a Time Module, replace the 3 lines 06-07-08 by the 2 lines:     XEQ "J0"    +
08  -
09  STO 29
10  XEQ "T"
11  STO 31
12  RCL 00
13  .01
14  -
15  STO 28
16  XEQ "T"
17  STO 30
18  .02
19  ST+ 00
20  LBL 01
21  RCL 00
22  VIEW X
23  XEQ "T"
24  STO 32
25  RCL 31
26  -
27  RCL 00
28  RCL 29
29  -
30  /
31  RCL 31
32  RCL 30
33  -
34  RCL 29
35  RCL 28
36  -
37  /
38  -
39  RCL 28
40  RCL 00
41  -
42  /
43  STO 33
44  RCL 29
45  RCL 00
46  -
47  *
48  +
49  RCL 33
50  ST+ X
51  X#0?
52  /
53  RCL 00
54  +
55  X<> 00
56  X<> 29
57  STO 28
58  RCL 32
59  X<> 31
60  STO 30
61  RCL 00
62  RCL 29
63  -
64  ABS
65   E-4
66  X<Y?
67  GTO 01
68  RCL 00
69  XEQ "T"
70  RCL 00
71  ENTER^
72  INT
73  X>Y?
74  DSE X
75  LBL 02
76  ST- Y
77  1.012
78  X<>Y
79  DATE+                If you don't have a Time Module, replace the 4 lines 77-78-79-80 by  XEQ "DT"  RCL 01  X<> Z  and add  STO 01 after line 69
80  X<>Y
81  24
82  *
83  HMS
84  RCL 33
85  X#0?
86  SIGN
87  RDN
88  CLD
89  END

( 154 bytes / SIZE 034 )

 STACK INPUTS OUTPUTS T / +1  or  -1 * Z / water level Y Date Date X approximate time hh.mnss

*  +1  means "High Tide"
-1  ------ "Low Tide"

Example:    Once again , in Seattle , on 11/11/2003  near 7 AM

11.112003    ENTER^
7                 XEQ "TIDE2"  produces  7.1718    ( in 2mn26s )    ( the successive d-approximations are displayed )
RDN                         11.112003
RDN                           3.4915
RDN                            1

-Thus, there is a high tide at 7h17mn and the corresponding water level = 3.49m  ( exact time = 7h02mn according to the "Shom" )

( Key in  2003.1111 instead of  11.112003  if you are using "J0" & "DT" )