Post Reply 
New Casio fx-9860 GIII model
10-05-2020, 06:02 PM
Post: #48
RE: New Casio fx-9860 GIII model
(10-04-2020 07:26 PM)John Keith Wrote:  
(10-04-2020 04:53 PM)grsbanks Wrote:  Using a python program it does it in only 2 seconds for \(n=10^3\), 18 seconds for \(n=10^4\) or 184 seconds for \(n=10^5\). That's 10× faster than using Casio Basic, BUT with what appears to be greatly reduced precision.

Does the Python program use single-precision floats, and if so does the Casio implementation of Python have doubles?

I would be surprised if Casio picked single-precision float for its Python implementation.
With only 7 digits precision (and greatly reduced exponent range), that is just asking for user complaints.

More likely, what appeared to be reduced precision is just default display format of numbers.

To get a good reference of what is expected, I simplified the formula:

Σ (e^sin(atan(x)))^(1/3) = Σ e^(x/(sqrt(9*x*x+9))

All terms about the same size, approaching e^(1/3) ≈ 1.39561 when x is big
To reduce errors, break up the sum to its integer and fractional parts.

Code:
expm1 = require'mathx'.expm1

function sum(n) -- sum of e^sin(atan(x)))^(1/3), x = 1 to n
    local s = 0
    for x=1, n do
       s = s + expm1(x/(sqrt(9*x*x+9)))
       if s >= 0.5 then n=n+1; s=s-1 end
    end
    if s < 0 then n=n-1; s=s+1 end
    return n, s
end

lua> sum(1e3)
1395       0.34628774342325536
lua> sum(1e4)
13955      0.8579042915289953
lua> sum(1e5)
139560     0.9761411065516028

Binary math tends to be more accurate, because of smaller accumulated rounding errors.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New Casio fx-9860 GIII model - Coco - 01-09-2020, 04:34 PM
RE: New Casio fx-9860 GIII model - Hlib - 01-09-2020, 08:02 PM
RE: New Casio fx-9860 GIII model - Coco - 02-02-2020, 04:15 PM
RE: New Casio fx-9860 GIII model - lrdheat - 03-06-2020, 03:22 PM
RE: New Casio fx-9860 GIII model - Dands - 03-08-2020, 04:07 AM
RE: New Casio fx-9860 GIII model - klesl - 03-08-2020, 12:25 PM
RE: New Casio fx-9860 GIII model - lrdheat - 03-10-2020, 05:51 PM
RE: New Casio fx-9860 GIII model - klesl - 05-14-2020, 04:30 PM
RE: New Casio fx-9860 GIII model - Albert Chan - 10-05-2020 06:02 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-04-2020, 11:34 PM
RE: New Casio fx-9860 GIII model - pier4r - 10-06-2020, 08:26 PM
RE: New Casio fx-9860 GIII model - vaklaff - 10-11-2020, 06:29 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-15-2020, 03:43 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-18-2020, 11:26 PM
RE: New Casio fx-9860 GIII model - Druzyek - 10-21-2020, 12:47 AM
RE: New Casio fx-9860 GIII model - DiTBho - 01-01-2021, 01:25 PM
RE: New Casio fx-9860 GIII model - critor - 01-01-2021, 08:37 PM
RE: New Casio fx-9860 GIII model - robve - 01-16-2022, 03:30 PM
RE: New Casio fx-9860 GIII model - critor - 01-19-2022, 08:36 PM
RE: New Casio fx-9860 GIII model - robve - 01-21-2022, 03:28 PM



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