HP Forums
Why are the solutions different? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Why are the solutions different? (/thread-14588.html)



Why are the solutions different? - tom234 - 02-29-2020 07:51 PM

I am comparing the answers of the same equation between HP Prime G2 and HP27S.
I am entering a formula for distance between points using:
"
//MATH
//COS A = SIN LT1 SIN LT2 + COS LT1 COS LT2 COS(LG1-LG2)
//DISTANCE=C*ACOS(SIN(HRS(LT1))*SIN(HRS(LT2))+
// COS(HRS(LT1))*COS(HRS(LT2)) *(HRS(LG1)-HRS(LG2)))

// 1 DEGREE OF ARC = 60 NAUTICAL MILES = PI X D/360 STATUTE MILES
// WHERE D IS THE DIAMETER OF THE EARTH, 7917.59
//DEGREES.MINUTESSECOND FORMAT(D.MM.SSss)
//EAST LONGITURDE ARE NEGATIVE NUMBERS. THE CALCULATOR MUST BE IN DEGREE MODE.

// WHERE C IS CONSTANT:
// C= 60 TO COMPUTE NATICAL MILES.
// C=69.0940 TO COMPUTE STATUTE MILES.

"N.B.
When I enter the equation below into the Solver I get the answer:2,434.2929Statute Miles. The same answer if I ented the for PPL program.
HMS-> entry goes to decimal form.
D=69.094*ACOS(SIN(HMS→(40.35))*SIN(HMS→(44.35))+COS(HMS→(40.35))*COS(HMS→(44.35)​)*COS((HMS→(75.1)-HMS→(123.16))))"

However, when I use My HP27s I get 2,426.9794 Statute Miles. This is correct for the formula backed up by my HP27s text.
This discrepancy or difference in the answer is quite distressing.

"wish PPL was QB/QuickC which one could program in a language of their choice...just trying to learn this program It's me I have to adapt.
If anyone can figure this out please help is required....could it be the calculator...
PS I am in degree mode.
Thank You for your help, your attention to this matter would be greatly appreciated.


RE: Why are the solutions different? - Albert Chan - 02-29-2020 09:37 PM

(02-29-2020 07:51 PM)tom234 Wrote:  When I enter the equation below into the Solver I get the answer:2,434.2929Statute Miles.
The same answer if I ented the for PPL program.
HMS-> entry goes to decimal form.
D=69.094*ACOS(SIN(HMS→(40.35))*SIN(HMS→(44.35))+COS(HMS→(40.35))*COS(HMS→(44.35)​)*COS((HMS→(75.1)-HMS→(123.16))))"

However, when I use My HP27s I get 2,426.9794 Statute Miles. This is correct for the formula backed up by my HP27s text.
This discrepancy or difference in the answer is quite distressing.

D seems to be calculated with latitudes 40.35°, 44.35°, longitudes 75.10°, 123.16°


RE: Why are the solutions different? - ijabbott - 02-29-2020 10:10 PM

(02-29-2020 09:37 PM)Albert Chan Wrote:  
(02-29-2020 07:51 PM)tom234 Wrote:  When I enter the equation below into the Solver I get the answer:2,434.2929Statute Miles.
The same answer if I ented the for PPL program.
HMS-> entry goes to decimal form.
D=69.094*ACOS(SIN(HMS→(40.35))*SIN(HMS→(44.35))+COS(HMS→(40.35))*COS(HMS→(44.35)​)*COS((HMS→(75.1)-HMS→(123.16))))"

However, when I use My HP27s I get 2,426.9794 Statute Miles. This is correct for the formula backed up by my HP27s text.
This discrepancy or difference in the answer is quite distressing.

D seems to be calculated with latitudes 40.35°, 44.35°, longitudes 75.10°, 123.16°

Indeed, they need to be entered as 40°35, 44°35, 75°10, and 123°16 on the Prime.

Also, there is a COS missing in the HP-27S version shown by tom234, although he must have typed it into the calculator correctly.


RE: Why are the solutions different? - ijabbott - 02-29-2020 10:21 PM

I always thought the old HP and TI way of doing HMS (or DMS) conversions was a bit of a kludge, TBH. I much prefer the Casio way of doing them.


RE: Why are the solutions different? - tom234 - 02-29-2020 11:24 PM

Is anyone having problems with HMS NOT going from decimal to degree

or otherwise?


RE: Why are the solutions different? - Jacob Wall - 03-01-2020 12:51 AM

Something like HMS→(40.35) doesn't do anything, the HMS format on the Prime is for display only, internally the value is a decimal. If the argument to that command is not in H°M'S" format, there is no change, not even visually.

If you want to convert a packed-format DMS number to decimal, then you will need your own conversion routine, something like this:

Code:
// convert a real number in DMS format to decimal degrees real number
HMS2DD(a)
BEGIN
  LOCAL d, m, s;
  d:=IP(a);
  m:=IP((a-d)*100);
  s:=(((a-d)*100)-m)*100;
  RETURN d+(m/60)+(s/3600);
END;



RE: Why are the solutions different? - tom234 - 03-01-2020 02:30 AM

I was going to think that was what I had to do make it...you saved me the though but yes that will work...
It is simple but how many times is this going to be the case making a function that was included in HP27s and previous HP calculators...it seems like three steps forward and two steps back.

Thank You
appreciated.


RE: Why are the solutions different? - ijabbott - 03-01-2020 10:47 AM

On the Prime, you just need to enter HMS/DMS values in sexagesimal format instead of the decimal format that you're used to. It's no big deal as there is a Math Template to enter sexagesimal numbers. Admittedly, it's not as convenient as entering sexagesimal numbers on Casio calculators.

You also don't need to use the HMS→ function inside the SIN function to convert the sexagesimal number to decimal. The SIN function can work on the sexagesimal number directly, treating it as DMS. For example, SIN(40°35’00”) ≈ 0.650553326665.


RE: Why are the solutions different? - Albert Chan - 03-01-2020 12:59 PM

(03-01-2020 12:51 AM)Jacob Wall Wrote:  Something like HMS→(40.35) doesn't do anything, the HMS format on the Prime is for display only, internally the value is a decimal.
(03-01-2020 10:47 AM)ijabbott Wrote:  SIN function can work on the sexagesimal number directly, treating it as DMS. For example, SIN(40°35’00”) ≈ 0.650553326665.

It may be better to think sexagesimal number as shorthand, D°M’S” ≡ (S/60+M)/60+D
There is no need for adding code for any functions to understand sexagesimal format.

SIN(40°35’00”) = SIN(40+35/60)

This is an improvement to packed 40.35, since that may be interpreted either way, decimal or DD.MMSS
Also, packed format might introduce conversion errors, see H->HMS conversion HP-15C vs. HP42S vs HP67


RE: Why are the solutions different? - ijabbott - 03-01-2020 01:55 PM

DISTANCE=C*ACOS(SIN(LT1)*SIN(LT2)+COS(LT1)*COS(LT2)*COS(LG1-LG2))

[Image: mxzwkxz.png]


RE: Why are the solutions different? - tom234 - 03-01-2020 01:57 PM

HP had enough room to add the function HMS(x) Converts x in decimal hours(degrees)
to H.MMSS(D.MMSS) format.

or

HRS(x) Converts x in H.MMSS(D.MMSS) format to decimal.

just like the old days!
TY


RE: Why are the solutions different? - tom234 - 03-01-2020 01:59 PM

(03-01-2020 01:55 PM)ijabbott Wrote:  DISTANCE=C*ACOS(SIN(LT1)*SIN(LT2)+COS(LT1)*COS(LT2)*COS(LG1-LG2))

[Image: mxzwkxz.png]

yes, I had to enter it with all the degree minutes second marks for it to understand
Code:
 it. So time-consuming
.


RE: Why are the solutions different? - ijabbott - 03-01-2020 02:26 PM

(03-01-2020 01:59 PM)tom234 Wrote:  yes, I had to enter it with all the degree minutes second marks for it to understand
Code:
 it. So time-consuming
.

You don't necessarily need all the marks. These all input the same value:

40°35
40°35’
40°35’”
40°35’0
40°35’0”
40°35’00
40°35’00”

The calculator will expand the input on entry to the full form.


RE: Why are the solutions different? - Joe Horn - 03-01-2020 08:31 PM

(03-01-2020 10:47 AM)ijabbott Wrote:  On the Prime, you just need to enter HMS/DMS values in sexagesimal format instead of the decimal format that you're used to. It's no big deal as there is a Math Template to enter sexagesimal numbers. Admittedly, it's not as convenient as entering sexagesimal numbers on Casio calculators.

A faster and easier method than using the math template key is to use the [ ° ' " ] key, which is [Shift] [a b/c]. It works just like the Casio [ ° ' " ] key.

Example: 1 [ ° ' " ] 2 [ ° ' " ] 3 --> 1°2'3''


RE: Why are the solutions different? - ijabbott - 03-01-2020 08:59 PM

(03-01-2020 08:31 PM)Joe Horn Wrote:  
(03-01-2020 10:47 AM)ijabbott Wrote:  On the Prime, you just need to enter HMS/DMS values in sexagesimal format instead of the decimal format that you're used to. It's no big deal as there is a Math Template to enter sexagesimal numbers. Admittedly, it's not as convenient as entering sexagesimal numbers on Casio calculators.

A faster and easier method than using the math template key is to use the [ ° ' " ] key, which is [Shift] [a b/c]. It works just like the Casio [ ° ' " ] key.

Example: 1 [ ° ' " ] 2 [ ° ' " ] 3 --> 1°2'3''

Thanks for the tip! TBH, I can't read half the stuff on the Prime keyboard. Smile


RE: Why are the solutions different? - cyrille de brébisson - 03-03-2020 07:50 AM

Hello,

To confirm what was said earlier....
HMS on Prime is a DISPLAY only thing, it does not change the number...
This allows user to enter number in any format they want. Decimal, or HMS without the program having to force things out on you...

Also, as pointed out, a HMS number, when used as an input for a trig function will be treated as being in Degree, EVEN if the current mode is radian...

Cyrille


RE: Why are the solutions different? - tom234 - 08-03-2021 12:06 PM

(03-01-2020 08:31 PM)Joe Horn Wrote:  
(03-01-2020 10:47 AM)ijabbott Wrote:  On the Prime, you just need to enter HMS/DMS values in sexagesimal format instead of the decimal format that you're used to. It's no big deal as there is a Math Template to enter sexagesimal numbers. Admittedly, it's not as convenient as entering sexagesimal numbers on Casio calculators.

A faster and easier method than using the math template key is to use the [ ° ' " ] key, which is [Shift] [a b/c]. It works just like the Casio [ ° ' " ] key.

Example: 1 [ ° ' " ] 2 [ ° ' " ] 3 --> 1°2'3''

TY that printing on the key in blue was so small didn't see it. Nice.