Thursday, August 30, 2012

Obtaining More Digits with the HP 50g


Intro:

I was reading the Fun With Num3ers blog by Ben Vitalis. The August 18, 2012 entry talked about certain fractions produced various patters.

Link to Ben's 10/81 post here. (8/18/12)

Examples include:

10. / 81 = 0.123456790123456790...

10 / 81 - ((3340 / 3267 * 10^-9)) = 0.12345678910111213141516... (and the number continues a counting fashion)

It was the latter fraction that inspired me to attempt to extract a larger number of decimal points. On most calculators, the most decimal points you can get is 12 in any numeric calculations. However with a calculator with CAS capabilities, we may be are able to extract more decimal places. (HP 50g, HP 49g+, TI-89, TI nSpire CAS are three models with CAS capabilities)


Steps for Fractions and Expressions - HP 50g:
1. Set the HP 50g to the Exact Mode.
2. Enter the expression. Remember, do not include a decimal point, use fractions.
4. Press EVAL.
5. Enter an integer that represents the number of decimal places. This number must be an integer!
6. Press [left shift], [EEX] (10^x) (ALOG function). Multiply.
7. Find PROPFRAC (soft key label PROPF) in the Arithmetic menu. Execute it twice. The result you want is an integer plus a fraction. The integer part represents number * 10^n. Ignore the "remainder".

Examples:

22 / 7 to 24 decimal places

n = 24

Note that 22 / 7 ≈ 3.14285714286

Keystrokes:
22 ENTER 7 / 24 10^x * PROPFRAC PROPFRAC

Press the up key and then F2 to view the answer. The result is:

3141285714285714285714285714 + 1 / 7

Hence 22 / 7 to 24 places is 3.141285714285714285714285714.

10 / 81 - ((3340 / 3267 * 10^-9)) to 24 decimal places

n = 24
10 / 81 - ((3340 / 3267 * 10^-9)) ≈ 0.12345689101

Keystrokes:
10 ENTER 81 / 3340 ENTER 3267 / 9 +/- 10^x * - 24 10^x * PROPFRAC PROPFRAC

Result:

123456789101112131415161 + (7039 / 9801)

So to 24 places, 10 / 81 - ((3340 / 3267 * 10^-9)) is 0.1234567890101112131415161.

This method can be extended to include sums and series. Finite series and sums work well. Infinite sums and series, that's another story. Sometimes a program will work better.

Steps for a program is used:
1. Set the HP 50g to the Exact Mode.
2. Enter 0. (or an appropriate starting sum)
3. Enter a program that represents a loop. The format is like this: << start end FOR var required expression + EVAL (we want exact answers) NEXT (or increment STEP >>.
4. Press EVAL twice.
5. Enter an integer that represents the number of decimal places. This number must be an integer!
6. Press [left shift], [EEX] (10^x) (ALOG function). Multiply.
7. Find PROPFRAC (soft key label PROPF) in the Arithmetic Menu. You may have to execute it twice. The result you want is an integer plus a fraction. The integer is the number * 10^n. Ignore the "remainder".

Notes:
* This method works best fast converging series. Series for π may not converge as desired (please see the example below).
* The loop can take a long time if the ending value is high.
* You have to make a mental point of where the decimal point should be. It is best to get an approximate value of the number you want to try to get more decimal points for before beginning.
* This method is not perfect! Remember, we get the result of the calculation, which may not be the desired number.


Σ (X^-1, X, 1, 20) to 24 places

Σ (X^-1, X, 1, 20) ≈ 3.5773965714

RPN syntax for Σ : variable lower_limit upper_limit expression Σ

Keystrokes, with X cleared (purged):
X ENTER 1 ENTER 20 ENTER X 1/X Σ 24 10^x * PROPFRAC PROPFRAC

Result: 10^24 * Psi(21) - 10^24 * Psi(1). Clearly, this is not what we want. Let's try a program.

1. Enter 0, then press ENTER.
2. Enter << 1 20 FOR X X INV + EVAL NEXT>>. Press ENTER, then EVAL. INV is the same as 1/X.
3. Key 24 ENTER 10^x * PROPFRAC PROPFRAC

Result:

3597739657143681911483769 + (66839 / 969969)

To 24 decimal places, Σ (X^-1, X, 1, 20) = 3.597739657143681911483769.

The difficulty for π

There are many infinite series for π. The very slow converging Gregory-Leibiniz series is the classic example:

π / 4 = 1 - 1 / 3 + 1 / 5 - 1 / 7 + 1 / 9 + ...

And the series from Nilakantha:


Let's use the series from Nilakantha. Remember the integer part divided by 10^24 is our "real" answer.

Key (I combine all the steps in a single program)
<< 3
2 50 FOR K
4
K
DUP 1 +
DUP 1 +
* * INV *
-1 K 2 / 1 + ^
* + EVAL 2 STEP
24 ALOG * PROPFRAC PROPFRAC >>

Result:
3141606851347550068996630 + 1606620270334125710 / 373805630307495883

Matches π * 10^24 for the first four digits.

Changing the upper limit garners these results (ignoring the fraction):
Limit of 100: 314160685134755006899630
Limit of 250: 3141590769849795180512794
Limit of 500 (after about 20 minutes): 3141592637780581078269478

int(π *10^24) = 31415926535897932384626433


This blog entry is a technique to "trick" the calculator into giving more decimal places beyond 12

Eddie


This blog is property of Edward Shore. © 2012.