Post Reply 
HP Prime Miscalculating
11-01-2015, 02:05 PM (This post was last modified: 11-01-2015 11:33 PM by Vtile.)
Post: #21
RE: HP Prime Miscalculating
(11-01-2015 02:12 AM)Joe Horn Wrote:  
(10-31-2015 10:50 AM)Vtile Wrote:  ... HP 50g calculates it correctly both in aprox and exact with or without XQ command used...

So does Prime, in Home, which uses BCD, like the HP 50g. The 50g does not have a non-BCD binary floating-point mode like the Prime's CAS. If you want 50g floating-point accuracy on the Prime, use Prime's Home view. That's what it's for.
I'm sure 95% of the Prime users do not care how the CAS-mode handles numbers internally. Only thing they care is that it doesn't give right values. I assume when everyone is speaking about CAS-mode and internal handling of number (BCD vs. Floatingpoint) they mean CAS-engine, right? If so why the UI is not designed to solve the issues related to engine, like that it can not solve the most simplistic elementary school level calculus correctly, makes me wonder.

(11-01-2015 01:16 PM)Wes Loewer Wrote:  Here's one I like to show my students each year. In Excel, enter the following:

=(4/3-1)*3-1

You should get zero. (On the Prime you get −1.42108547152e−14.) Now put an extra set of parentheses around the whole thing in Excel:

=((4/3-1)*3-1)

You now get -2.22045E-16.

To see the significance of these two values, try

=((4/3-1)*3-1)*2^52 in Excel and ((4/3-1)*3-1)*2^46 on the Prime.
Hmm.. Nice, hope my own teachers would have at some point shown that, I might have changed the hobby.
Interesting enough, I did found another "oddity" at my 50g to take account when creating programs. I also just learned that the industry standard is miscalculus [Edit. Meant that the algorithms lack of pre-analysis and CA before doing actual calculus). Eye opening, indeed.

PS EDIT. Finally with my Win PC and Excel, I have been running few days my HP mini laptop with linux.
Anyhow, that Excel thing is really interesting and works just as Wes Loewer says it would. If you want more error replace the given equation with =((4/3-1)*3-1)/SIN(PI()/2)
SIN(Pi/2) should be precisely 0 and the answer for the equation something like not declared, I'm not mathematician though and to be honest can't recall if there were given exception for case 0/0.
(*NOTE: PI() is language dependant in MS Excel and so might be SIN(), also the Radian/Degrees angle format might be.)

HP35S gives ((4/3-1)*3-1)/SIN(PI()/2) a value of -10,00E-12 in ALG,RAD,ENG3 mode. (Not too familiar with this calc though so I'm not avare if there is some "Use precision" mode somewhere hidden.)
HP35S gives ((4/3-1)*3-1)/SIN(PI()/2) a value of DIVIDE BY 0 in ALG,DEG,ENG3 mode. (I don't like radians anyways)
HP50g gives ((4/3-1)*3-1)/SIN(PI()/2) a value of -10,00E-12 with ->NUM and 0 with EVAL. (Random flags, in aprox mode ->NUM does nothing and EVAL gives aproximation, in exact mode values are as given)
CASIO ClassPad2 aka FX-CP400 gives ((4/3-1)*3-1)/SIN(PI()/2) value of 0 (In both exact and aprox modes)
Canon Card F-54 (1980) gives ((4/3-1)*3-1)/SIN(PI()/2) value of 2.8566(E)-08 in RAD mode. (Pretty obvious for such archaic "midrange" pocket calculator even more so with Pi aproximation.)
Canon Card F-54 (1980) gives ((4/3-1)*3-1)/SIN(180deg) a value of e as error.

Definedly adding the original and 0/0 variation to my notebook to try out things in future. - Sydämelliset kiitokset!
Find all posts by this user
Quote this message in a reply
11-04-2015, 05:57 PM
Post: #22
RE: HP Prime Miscalculating
(11-01-2015 02:05 PM)Vtile Wrote:  If so why the UI is not designed to solve the issues related to engine, like that it can not solve the most simplistic elementary school level calculus correctly, makes me wonder.

Well, that's the nature of any numeric calculation which uses finite precision. Since the values are not stored exactly, you cannot expect to get exact results. The fact that ((4.0/3.0-1.0)*3.0-1.0) does not result in zero does not mean that the software is faulty. The "incorrect" result is simply an artifact of the way numbers are stored.

Here are a few different results:
Binary Storage:
Prime-CAS: -1.42108547152e-14 = -(2^-46)
MS Excel: -2.22045E-16 = -(2^-52)
Maxima (50 decimals): -2.67276...e-51 = -(2^-168)

Decimal Storage:
Prime-Home: -1.0e-11
HP-50g: : -1.0e-11
TI-Npsire: -1.0e-13

(11-01-2015 02:05 PM)Vtile Wrote:  SIN(Pi/2) should be precisely 0 and the answer...

You probably meant COS(Pi/2)=0 or SIN(Pi) = 0. (SIN(Pi/2) = 1) This is a good example how how some calculators "lie" when they give you what you expect, not what the calculated result really is.

On the ti calculators, the numeric value of pi is 3.1415926535898. The actual result of sin(3.1415926535898) is about -6.76e-15, but when the calculator sees this special value, it returns the value 0 because that's what students expect/want to see.

In other words, sometimes calculators attempt to hide the artifacts of finite precision. That's probably good for students, but it does drive numerical purists crazy.

A simpler example is 1.0/3.0*3.0 . The exact result is 1 of course, but a finite precision calculation will result in something like 0.999999999 .
Find all posts by this user
Quote this message in a reply
11-04-2015, 08:36 PM (This post was last modified: 11-04-2015 09:48 PM by Vtile.)
Post: #23
RE: HP Prime Miscalculating
Yep, copypaste error from wrong Excel cell on that Sin(Pi/2), it propably were COS(Pi/2)

... I'm too tired ... need to get to sleep sry, making silly mistakes on my math. Edit2. Classic cross eyed and dooms correct as an incorrect. (+.+)
Find all posts by this user
Quote this message in a reply
11-06-2015, 07:55 AM
Post: #24
RE: HP Prime Miscalculating
(10-31-2015 10:50 AM)Vtile Wrote:  If the calculator is in exact mode set by user the CAS should behave according to that, while it is mathematically unorthodox solving answers like if user were using exact representation of given value instead of decimal value. In other words calculators CAS should expand (with silence or noting that "Unorthodox numerical format detected correcting user careless behaviour") the floating points to (36/10)²−4×(324/100) even if the user were typing the numbers in decimal format.
You misunderstand what the exact setting means. In CAS, you can perform exact *and* approx computations. If exact mode is set, the kind of computation is determined by the input (exact input, exact computation, approx input, approx computation). If approx mode is set, it means that all entries are considered as approx, even if they look like exact (in other words an evalf is done on the arguments).
Find all posts by this user
Quote this message in a reply
09-02-2018, 04:32 PM
Post: #25
RE: HP Prime Miscalculating
Off-topic
(11-01-2015 02:05 PM)Vtile Wrote:  Definedly adding the original and 0/0 variation to my notebook to try out things in future. - Sydämelliset kiitokset!
From Finland / Suomesta???
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 8 Guest(s)