Repeating Decimals / Recurring Decimals
|
01-21-2018, 11:00 AM
(This post was last modified: 01-21-2018 04:34 PM by StephenG1CMZ.)
Post: #1
|
|||
|
|||
Repeating Decimals / Recurring Decimals
Given an integer reciprocal, analyzes the decimal representation to identify the transient and repeating/recurring parts of the decimal.
Eg 1/3 has no transient and 3 repeats. 1/4 has transient 0.25 and no repetition. 1/7 has no transient and 0.142857 recurring. 1/14 has transient 0 and 6 recurring digits. See http://www.hpmuseum.org/forum/thread-9919.html For a description of the algorithms and more examples. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
01-21-2018, 11:01 AM
(This post was last modified: 01-21-2018 11:34 PM by StephenG1CMZ.)
Post: #2
|
|||
|
|||
RE: Repeating Decimals
(PPL) Version 0.2 follows the sequence of steps in Joe Horn's algorithm using MultiplicateOrder, which can be found here: http://www.hpmuseum.org/forum/thread-3212.html
Output is currently a list: 1: {Length of transient, transient} 2: {Length of recurring part, both parts but omitting the 0. Or 1.} 3: Just as a check, the real value. The formatting could be improved. Note that if the length of the recurring part exceeds 12 the recurring part returned is unreliable and should probably be replaced by NaN (the indicated length is OK, but not the digits...and sometimes they are not digits). Code:
Note: A comparable CAS implementation could improve ranges handled. Update: 99989 crashes the Android emulator. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
01-24-2018, 07:21 PM
Post: #3
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.3 includes an optimised MultiplicativeOrder (base 10) and outputs a string with the recurring part annotated with an underscore (selectable).
Code:
Note there is a bug with the string formatting...Sometimes it includes the integer part, sometimes not. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
01-26-2018, 11:02 PM
(This post was last modified: 01-27-2018 07:27 PM by StephenG1CMZ.)
Post: #4
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.4 has cosmetic improvements and help. It adds a CAS variable which show more digits, but I have yet to find out how use that in PPL - Whenever I try to turn it into a string, it turns into a real instead.
(Update: I have found the required syntax to do that now, so expect another release soon.) Code:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
01-31-2018, 09:10 AM
Post: #5
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.5 is a much improved PPL program for showing transient parts and repetends of reciprocals. It has been rewritten to use CAS, enabling Transients and Repetends >12 digits to be handled, and is faster.
Code:
In Show, a warning is given if screen size is exceeded, but such values can still be printed. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-01-2018, 05:53 PM
(This post was last modified: 02-01-2018 07:14 PM by StephenG1CMZ.)
Post: #6
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.6
Show optimised. Note that the transient display assumes USCORE (underscore) is not empty. Implementation Limits added (Some large values eg NN=1E14 exceed the limits of euler). Code:
Hope this is useful, although it is only implemented for reciprocals. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-04-2018, 06:46 PM
(This post was last modified: 02-05-2018 10:11 PM by StephenG1CMZ.)
Post: #7
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.7 implements handling of fractions as well as reciprocals.
Code:
Update: use with care. On the Android, this implementation can be problematic with larger values such as 2/16384. Sometimes it seems to work and can return useful results, but after a Bad Argument error is reported, problems persist in the running of other programs until the calculator (not the mobile) is switched off. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-06-2018, 11:24 PM
(This post was last modified: 02-07-2018 07:47 PM by StephenG1CMZ.)
Post: #8
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
I have noticed an issue with the step 0 fraction reduction as I have implemented it in V0.7.
In V0.6, 1/1E14 would be processed by the algorithm (no reduction being implemented). An error message would issue from Multiplicateorder10 as implementation limits are exceeded. In V0.7, 1/1E14 is reduced to 1E-14/1 and non-integer numerator is processed, resulting in a NaN with no error message from MultiplicativeOrder10 seen. Potentially, there might be other values which MultiplicateOrder10 might have handled, but which are not being processed because the reduction step is introducing unexpected non-integer values. Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-07-2018, 08:02 PM
Post: #9
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Note that some long repetends incorrectly return all zeros instead of the correct digits (the reported length is correct). If you see a value with just zeros assume it is incorrect.
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-08-2018, 09:03 PM
(This post was last modified: 02-08-2018 10:10 PM by StephenG1CMZ.)
Post: #10
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.8
Improved handling of implementation limitations. Improved user interface shows more digits on-screen and allows long strings not to be generated. Code:
Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
02-10-2018, 11:15 PM
(This post was last modified: 02-11-2018 11:38 PM by StephenG1CMZ.)
Post: #11
|
|||
|
|||
RE: Repeating Decimals / Recurring Decimals
Version 0.9 fixes a bug caused by "exact", introduced in V0.8. Thanks for spotting that.
Error MSGBOX is improved (using an AFile to save/restore the screen). Code:
Some long repetends continue to incorrectly show all zeros. Negative fractions may now cause a MultiplicativeOrder10 error message Update: Some values are incorrect... Stephen Lewkowicz (G1CMZ) https://my.numworks.com/python/steveg1cmz |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)