Post Reply 
The new dfc and dfc2f functions in action
01-10-2018, 01:37 AM (This post was last modified: 01-10-2018 01:48 AM by Joe Horn.)
Post: #1
The new dfc and dfc2f functions in action
A whole class of difficult-to-solve problems has been rendered easy to solve due to the addition of two new functions to the HP Prime (dfc and dfc2f) in a recent firmware upgrade. Here's one simple example of such a problem, and how to solve it using dfc and dfc2f.

PROBLEM: What is the simplest fraction which evaluates to 0.797 when rounded to 3 decimal places? In other words, what's the simplest fraction in the half-open interval [0.7965, 0.7975)?

The answer can be found in these 3 easy steps:

[Image: dfc-in-action.png]

Here's a step-by-step explanation of what happened above. The first two lines are both ends of the desired interval being fed into the dfc() function. Take careful note of where the two outputs begin to differ. In this case, the first 4 elements are the same (0,1,3,1), but after that they begin to differ (one is 10 and the other is 15). All you need to do is take the smaller one (10), add one to it (11), and drop all the remaining elements, and feed that new list (0,1,3,1,11) into the dfc2f function to obtain the final answer (47/59). Easy peasy.

Warning: Since the interval is half open, make sure your answer is not the right endpoint. If it is, adjust the last number in the dfc2f list by 1. If that yields the left endpoint, then that's the best possible answer. (This probably only happens in pathological cases which are invented to make algorithms choke, but that's what I do for fun, so that's how to handle it.)

Writing a program which automates this process is left as an exercise for the student. Smile

EDIT: Warning: If you use the dfc2f function in Home, and it returns a real, not a fraction, then press Shift CAS (Settings) and turn on the "Change apparent integers into exact integers" setting, which is the checkbox at the end of the 3rd row. Then it'll return a fraction in Home, as it always does in CAS.

EDIT 2: Homework: What's the simplest fraction between the constant \(e\) and \(\sqrt { 7.389 } \) ?

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
The new dfc and dfc2f functions in action - Joe Horn - 01-10-2018 01:37 AM



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