Post Reply 
The a b/c key
03-08-2017, 01:21 AM (This post was last modified: 03-08-2017 01:23 AM by math7.)
Post: #1
The a b/c key
Hi, I have seen in my physical calculator that when I use the ab / c key in the CAS MODE when I press it to get the approximate answer or in fraction format it only gives me the improper or proper fraction of a value but it does not give me the mixed fraction, but When you use this key in the HOMR MODE, it swaps between the approximate value, the proper fraction or improper fraction. Why does not the mixed fraction work in CAS mode?
Note that in CAS MODE the expressions are when you press the a b / c key several times, just as in the HOME MODE. See screenshots.


Attached File(s) Thumbnail(s)
       
Find all posts by this user
Quote this message in a reply
03-08-2017, 07:09 AM (This post was last modified: 03-08-2017 07:16 AM by Joe Horn.)
Post: #2
RE: The a b/c key
The fraction key actually works very differently in Home and in CAS.

In Home, pressing [a b/c] when a real number is the current result toggles an internal FRACTION DISPLAY MODE setting, without actually changing the number itself. And its accuracy is controlled by the current Home Setting Number Format and Decimal Places. For example, press PI Enter, then set in Home Settings "Fixed" format with 3 digits. Pressing [a b/c] will change the DISPLAY ONLY from 3.142 to 201/64, then to 3+9/64, then back to 3.142 without actually changing the real number that's there (namely, exactly 3.14159265359). So please note two things unique to Home: [a b/c] toggles the display only, without changing the number, AND the accuracy is controlled by the display settings in Home Settings.

In CAS, pressing [a b/c] when a real number is the current result simply executes the EXACT function on it (returning a fraction approximation), thereby placing a new command and its result on the stack. The EXACT function's accuracy is controlled by the current value of "epsilon" (see CAS Settings, page 2), not by the display setting. Unfortunately, epsilon is only allowed to have values between 1E-6 and 1E-15. And pressing [a b/c] when an algebraic expression is the current result (e.g. a fraction) simply executes the APPROX function on it, thereby placing yet another new command and its result on the stack.

Due to a fortuitous bug, there is a way to trick CAS's [a b/c] into using a value of epsilon larger than 1E-6. For example, in CAS, put pi on the stack and press [a b/c] to obtain its approximate value. Now press CAS Settings, page down, and set epsilon to 1E-3. Press CAS and then press [a b/c]. You will obtain 355/113, and epsilon will maintain its value of 1E-3. This only happens if the [a b/c] key is pressed; typing "exact(approx(pi))" in CAS will result in epsilon being reset to 1E-6. Also, any epsilon smaller than 1E-15 will silently be treated as 1E-15.

Notice that Home returns 201/64 for a display setting of Fixed 3, while CAS returns 355/113 for an epsilon of 1E-3. This is because Home uses the PDQ Algorithm for fraction approximations, while CAS uses the simple continued fraction algorithm. Therefore CAS's EXACT function will often miss simpler solutions that Home's [a b/c] key returns.

If you obtain an improper fraction in CAS via the EXACT function, you can turn it into a mixed number with the PROPFRAC function, e.g. propfrac(355/113) --> 3+16/113.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-08-2017, 08:14 PM
Post: #3
RE: The a b/c key
Thanks Joe, Oh I understand now, this is interesting. How do you know all that the CAS uses continuous fractions and the START MODE uses the PDQ algorithm (I do not know what it means)? Those things I have not seen in the manual !!!
Find all posts by this user
Quote this message in a reply
03-08-2017, 09:34 PM
Post: #4
RE: The a b/c key
(03-08-2017 08:14 PM)math7 Wrote:  Thanks Joe, Oh I understand now, this is interesting. How do you know all that the CAS uses continuous fractions and the START MODE uses the PDQ algorithm (I do not know what it means)? Those things I have not seen in the manual !!!

You can read about it here: https://en.wikipedia.org/wiki/Continued_fraction (as for the name PDQ, that is likely "p divided by q").

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-09-2017, 03:50 AM
Post: #5
RE: The a b/c key
(03-08-2017 08:14 PM)math7 Wrote:  Thanks Joe, Oh I understand now, this is interesting. How do you know all that the CAS uses continuous fractions and the START MODE uses the PDQ algorithm (I do not know what it means)? Those things I have not seen in the manual !!!

You are correct that the information I posted above is not in the Prime documentation. The algorithms used by the [a b/c] button in Home and CAS can be deduced by the outputs. CAS only returns principle convergents of the continued fraction expansion of the input, whereas Home returns the best fraction which is sometimes an intermediate convergent. Therefore CAS must use the simple continued fraction algorithm (which misses all intermediate convergents), and Home must use PDQ (which never misses any intermediate convergents).

(03-08-2017 09:34 PM)Han Wrote:  You can read about it here: https://en.wikipedia.org/wiki/Continued_fraction (as for the name PDQ, that is likely "p divided by q").

That's right. "PDQ" was chosen not only because the literature about continued fractions often uses "p/q" but also because PDQ in English means Pretty Darn Quick, which the PDQ Algorithm is. For its complete history, search comp.sys.hp48 for "PDQ".

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-09-2017, 06:16 AM
Post: #6
RE: The a b/c key
Hello,

Please do note that the algo used in home was created by no other than our Joe Horn!

Praise to Joe!!!!

Cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
03-09-2017, 11:04 PM (This post was last modified: 03-09-2017 11:04 PM by math7.)
Post: #7
RE: The a b/c key
Hello everyone!!! And I was thinking about what Joe and Han said but analyzing the subject a bit more, as far as the a / b / c key that does not work the same in the CAS as in the HOME MODE, I think it has nothing to do The mathematical algorithm used in each mode. I meant at the beginning that in CAS mode the key a b / c does not deliver the result as a mixed fraction of any result. This does not have to do with the algorithm, but simply to move from an improper fraction to a mixed one is simply that the HP Prime does the conversion as done for example by hand, or the same as does the propfrac command that indicated me Joe and who does deliver the mixed fraction for example 89/77 = 1 + 12/77.

This result does not have to do with the algorithm that is used in the CAS, but the calculator after obtaining the result 89/77 expresses it as 1 +12/77 either by calling internally the propfrac command or another method, but Screen is displayed by pressing the ab / c key as in HOME mode.
Find all posts by this user
Quote this message in a reply
03-10-2017, 03:06 AM
Post: #8
RE: The a b/c key
That's correct: The fact that Home toggles between improper fraction display and mixed number display, and CAS only returns improper fractions, does not depend on the decimal-to-fraction algorithms they use. The only reason I even brought all that up was to underscore the most important differences between the way that the [a b/c] key acts in Home and in CAS, one of which is the actual results obtained.

The reason that the [a b/c] key in CAS never returns mixed numbers is simply due to the way it always and only calls the EXACT or APPROX functions, neither of which ever returns mixed numbers. Are you requesting that it call the PROPFRAC function whenever the current result is an improper fraction in CAS? If so, I find that idea compelling. That would make it "feel" more like the way the [a b/c] key behaves in Home.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-10-2017, 06:01 AM (This post was last modified: 03-10-2017 06:07 AM by math7.)
Post: #9
RE: The a b/c key
Yes that's right Joe, that's what I liked, that I called the purpose function internally and the a b/c key switch between mixed and improper fraction just like it does in HOME mode, it's somewhat trivial because the propfrac command exists , But I liked it too, but thanks for all the explanation of the algorithms, it is very enriching !!!

By the way Joe, I would like you to give your opinion as in others about what I put in another post to make a library or application for the Prime similar to Longfloat that exists for the HP 50g, with real extended, since you handle well The subject of algorithms like others in this web.
Find all posts by this user
Quote this message in a reply
03-10-2017, 11:55 PM
Post: #10
RE: The a b/c key
(03-10-2017 06:01 AM)math7 Wrote:  By the way Joe, I would like you to give your opinion as in others about what I put in another post to make a library or application for the Prime similar to Longfloat that exists for the HP 50g, with real extended, since you handle well The subject of algorithms like others in this web.

Ok, I'll post a reply in that thread.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-11-2017, 04:11 AM
Post: #11
RE: The a b/c key
(03-10-2017 11:55 PM)Joe Horn Wrote:  Ok, I'll post a reply in that thread.

Thanks, I'll be waiting to read it.
Find all posts by this user
Quote this message in a reply
Post Reply 




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