(42S, Free42, DM42) Solving for HMS values
|
10-08-2020, 12:44 PM
Post: #1
|
|||
|
|||
(42S, Free42, DM42) Solving for HMS values
Solving for HMS values may introduce wrong values.
An example. Suppose your daily commute counts as working hours, except for the first 20 minutes each way. Say your commute is 1 hour, each way, and you have a lunch break of half an hour. Your daily working time is set to 7:36. If you leave home at 7:15, when would you then be allowed to leave the office, to ensure a full day's work? Given LH: the time you Leave Home in the morning C: the duration of your Commute, one-way LB: Lunch Break WT: your daily Working Time when would you be allowed to leave the office (LO)? The moment you arrive back home is: LH + 20m + WT + LB + 20m so LO = LH + WT + LB + 40m - C if your commute is less than 20 minutes, it is LO = LH + WT + LB + C Try a solver program (for now only for C>20m): Code: LBL "FW" SOLVE "FW", enter WT = 7.36 LH = 7.15 LB = 0.30 C = 1 solve for LO with guesses 0 and 16 and get 14.6060 - which ought to be 15.0100. (the guesses are not really necessary but force the result) This value is equivalent to 15.01, as you can see when you do 0 HMS+. There is however no way to tell the solver to only use valid H.MS values. So we'll have to correct the solved value. Since we may also run into accuracy problems (eg 14.60599999..) we will build a front-end to the solver, and round the value obtained to the nearest minute. This time we include the case where C is less than 20m as well, as follows: If C<20 Then add C Else add (40 - C) End If C<(40-C) Then add C Else add (40 - C) End or add MIN(40-C,C) Let's make the Forfait of 20m a variable as well (FF). Since FF and WT are variables that won't change often, we'll put them on the next page, using a dummy " " variable: Code: 00 { 114-Byte Prgm } Now, you can observe the difference: if you use the SOLVER, with the original example, you get 14.606 If you do XEQ "FW" instead, the interface is the same (apart from inputting the guesses), but you get 15.01 In general, if you have a HMS solver program (FW here), we can do In: A: "FW" X: 0.01 @ round to multiple of (in HH.MMSS style so if you want to round to a quarter, use 0.15) XEQ "HMSLV" (Of course, for the 42S, change the LSTO statements into STO's) Code: 00 { 64-Byte Prgm } Problem: when you EXIT the VARMENU, the local variables R and P still exist. But when the MENU is shown, they should exist. Dilemma. Hope you like it, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
10-08-2020, 10:06 PM
Post: #2
|
|||
|
|||
RE: (42S, Free42, DM42) Solving for HMS values
Interesting real-world issue.
Why not simply use the clever trick you point out at the beginning (0 HMS+ to normalize) applied to the result? Seems like a lot less thrashing, no ? --Bob Prosperi |
|||
10-09-2020, 03:21 AM
Post: #3
|
|||
|
|||
RE: (42S, Free42, DM42) Solving for HMS values
Because I want the program to return the result? And I round it to the nearest minute as well.
Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
10-15-2020, 07:44 AM
Post: #4
|
|||
|
|||
RE: (42S, Free42, DM42) Solving for HMS values
(10-08-2020 10:06 PM)rprosperi Wrote: Seems like a lot less thrashing, no ? I wrote the above routine for my daughter-in-law-to-be who knows nothing about calculators in general or HPs in particular. So it had to be as user-friendly as possible. I thought it might interest people here, because it shows the use of a number of techniques:
Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
10-15-2020, 12:40 PM
Post: #5
|
|||
|
|||
RE: (42S, Free42, DM42) Solving for HMS values
Thanks for explaining. Indeed it's a small who's who of many of the 42's unique and interesting commands, demonstrating them well in a relatively small, focused application. I especially like the statement "SOLVE IND ST L", which combines some of these nicely.
I find there is always something to learn in your posts and programs - keep it up please. --Bob Prosperi |
|||
10-15-2020, 01:13 PM
Post: #6
|
|||
|
|||
RE: (42S, Free42, DM42) Solving for HMS values
(10-08-2020 12:44 PM)Werner Wrote: Solving for HMS values may introduce wrong values... Luckily, this is "only" a display bug For HMS calculations, Casio shines, since it knows sexagesimal. Sharp calculator is even better, with less keystrokes: 7 [DMS] 36 - [DMS] 40 * 2 = 6°16' // work-related time, less commute allowances + 1 [DMS] 30 = 7°46' // + non-work time, commute (1 way) + lunch break + 7 [DMS] 15 = 15°01' // leaving office at 3:01 pm |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)