bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Unexpected results for the power function


From: Juergen Sauermann
Subject: Re: [Bug-apl] Unexpected results for the power function
Date: Fri, 25 Jul 2014 16:48:53 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Fred,


thanks for reporting this. I made some improvements in the power
functions, see SVN 393.

/// Jürgen


On 07/23/2014 06:16 PM, Frederick H. Pitts wrote:
Jurgen,

        The last comment in the listing below summarizes the issue.  The input
file for the listing is attached.

Regards

Fred
Retired Chemical Engineer
       ⎕PP ← 16
       ⍝ Compute first 5, 14th, 15th, 70th and 71th Fibonacci numbers
using
       ⍝ Binet's formula
(http://www.math.rutgers.edu/~erowland/fibonacci.html)
       ⍝ Desired results:
       ⍝ 1 1 2 3 5 377 610 190392490709135 308061521170129
R ← 1 2 3 4 5 14 15 70 71
       R5 ← 5 ⋆ .5
       P5 ← 1 + R5
       M5 ← 1 - R5
       ⍝ Using repeated multiplication to compute the powers gives valid
answers
       ⍝ up to the 70th number after rounding. Maybe this result is the
best one
       ⍝ can expect from double precision arithmetic.
       ( ( ( ×/ )¨ R ⍴¨ P5 ) - ( ( ×/ )¨ R ⍴¨ M5 ) ) ÷ R5 × ( ×/ )¨ R ⍴¨
2
1 1 2 3 5 377.0000000000001 610.0000000000003 190392490709135.4
       308061521170129.7
       ⍝ Using the APL ⋆ operator to compute the powers gives valid
answers only
       ⍝ up to the 14th number.  The 15th number is no where near
correct.
       ⍝ Shouldn't the ⋆ operator results match the repeated
multiplication
       ⍝ results more closely?
       ( ( P5 ⋆ R ) - M5 ⋆ R ) ÷ R5 × 2 ⋆ R
1 1 2 3 5 377.0000000000002 0.001639344262295081 5.252307989014705E¯15
       3.246104856593697E¯15





reply via email to

[Prev in Thread] Current Thread [Next in Thread]