In Chapter 2 of his book "Astronomical Algorithms" Jean Meeus looks at
computer accuracy.
A quick test of trig functions is to use 4*ATAN(1) which should return PI.
To look at rounding errors he starts with 1/3 or 0.33333... recurring.
Using the equation
X = ( 9 * X + 1) * X - 1
and starting with X = 1 / 3 and then repeatedly calculating the rounding
errors accumulate and X diverges from a perfect 1 / 3
On an ESP32 (in C using framework 5.3.1) in double precision floats you see
1. Rounding Errors X = 1/3 then X = (9 * X + 1) * X - 1
1 0.333333333333
2 0.333333333333
3 0.333333333333
4 0.333333333333
5 0.333333333333
6 0.333333333332
7 0.333333333325
8 0.333333333272
9 0.333333332907
10 0.333333330347
11 0.333333312426
12 0.333333186982
13 0.333332308873
14 0.333326162117
15 0.333283135282
16 0.332981969654
17 0.330874898687
18 0.316178685916
19 0.215899338763
20 -0.364587940932
Another test he tries is to take 1.0000001 and square it 27 times. This
should give 674530.4707 to 10 sig figs. The ESP32 (double precision
floats) gives 674530.4755. (My desk TI-60 pocket calculator gives
674530.318).
For your amusement, in ESP32 single precision for these two tests you get
1 0.333333
2 0.333334
3 0.333337
4 0.333357
5 0.333500
6 0.334502
7 0.341528
8 0.391304
9 0.769372
10 5.096765
11 237.889893
12 509561.312500
13 2336875085824.
14 49148868497321186346139648.
15 inf
And 8850397.000
Jean Meeus then looks at some other tests showing how the order that
calculations are made can effect the result and other demonstrations of
rounding errors leading to completely erroneous results. Ok the book is
dated from 1998 and last printed in 2015 and he using, inter alia, an
HP85 and QuickBASIC 4.5 to demonstrate, but I find it is still
interesting to try his examples.
Grahame
On 18/03/2025 00:06, newxito wrote:
Sorry, no kit but I will upload all the files to github. I'm
currrently working on other projects, so I will need some time.
I also want to rewrite the calc engine because today, after making
some code changes in Microsoft's ratpak, I was able to compile the lib
for an ESP32.. The (excellent) Windows 11 calculator is based on
ratpak. It's code from the 1990s licensed under the MIT license.
Initial tests are very promising.
You may think that this is overkill but small inaccuracies in the
calculations drive me crazy.
For example: 1.0000000000001 ^ 999
Using the C/C++ pow function or Excel you will get 1.00000000009982
WolframAlpha and the Windows calculator both return 1.00000000009990
liam bartosiewicz schrieb am Montag, 17. März 2025 um 20:51:52 UTC+1:
That looks awesome! Any possibility of making it a kit? Would be
great to have on a desk at work.
On Mar 17, 2025, at 3:09 AM, newxito <[email protected]> wrote:
It still has the same number of nixies as the non-RPN version
but an additional horizontal neon for the exponent sign. By
keeping the 14 nixies, it was possible to maintain all the clock
modes and implement a dynamic exponent range. The keyboard has
now 5 additional keys and the functionality was extended from 15
to 33 operations.
Switching to arbitrary-precision arithmetic was a failure. It
worked but was too slow for a few special cases of pow and
non-integer factorials (gamma approximation). I will give it
another try, but for now I’m back to 64-bit floating-point.
--
You received this message because you are subscribed to the
Google Groups "neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To view this discussion, visit
https://groups.google.com/d/msgid/neonixie-l/1290e008-6759-485a-8b7d-0cf74a8787bdn%40googlegroups.com
<https://groups.google.com/d/msgid/neonixie-l/1290e008-6759-485a-8b7d-0cf74a8787bdn%40googlegroups.com?utm_medium=email&utm_source=footer>.
<rpn.jpg>
--
You received this message because you are subscribed to the Google
Groups "neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To view this discussion, visit
https://groups.google.com/d/msgid/neonixie-l/f2670f05-34e2-4789-8ae8-ed5fec66b3ffn%40googlegroups.com
<https://groups.google.com/d/msgid/neonixie-l/f2670f05-34e2-4789-8ae8-ed5fec66b3ffn%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups
"neonixie-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion, visit
https://groups.google.com/d/msgid/neonixie-l/631402bb-8c28-4555-abbf-04fb3cd1a8db%40googlemail.com.