Go Down

Topic: mathematic libraries (Read 3881 times) previous topic - next topic


I don't understand what you have against interpolating between close data points? High precision cutting tools have been doing it for decades.

Who's "you"?
The art of getting good answers lies in asking good questions.


Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts


pi is not a function. It is a value. You can determine the value of pi from atan(1.0), or you can hardcode it to more decimal places than the Arduino can handle.

Or you can just spell it "PI" (Arduino.h) or "M_PI" (math.h).
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


Discussions like this have been going on since at least 2010. Replies from the Arduino experts have been, to say the least, unsatisfactory, and the subject is well worth a rant. Arduino is for scientists as well.

In my own case I need to calculate small differences between high audio frequencies, which are in turn calculated from  values proportional to pitch (MIDI note numbers, cents). Similar situations arise in elementary statistics and, as several contributors have mentioned, several other areas where the Arduino is a perfectly appropriate platform. The key points are that evaluating the numerical stability of (for example) exponentiations is likely to be too difficult for most Arduinio users (including amateur and some professional scientists), as is interpolating between items in lookup tables. That's why spreadsheets such as Excel and Open Office Calc were suitably modified more than a decade ago so that ordinary users don't have to worry about numerical stability; 7-digit precision isn't even enough to calculate the mass of a fairly small molecule.

Since the early days of computing, and particularly during the period when home computers were 8-bit, it has been perfectly normal to write and use libraries of high-precision algorithms. Major scientific applications are still being written in old languages such as Fortran 77. C++ is supposed to be a major modern language, so there ought to exist a maths library that works with arbitrary levels of precision.

Arduinos such as the Mega have more than enough memory; several contributors have pointed out that computing time is not an issue here, and it's a pity that expert replies to this forum seem to be dominated by people who don't seem to understand that some of us need to combine real-time functionality with accurate calculations which are not time-critical.

So, I repeat the question that has been asked many times here: does there exist a multiple-precision C or C++ math library that could be used with Arduino?


does there exist a multiple-precision C or C++ math library that could be used with Arduino?

Floating point?  I don't think so.  Most of the generic C/C++ "advanced math" packages will assume that you're starting with a real 64bit double, I think.  Which avr-gcc doesn't have.
(depending on your definition of "could be used with", I guess.  I found a couple of references to people trying to compile mpfr and/or gmp on AVR.  Although they tend to be dwarfed by the hits about needing those to compile gcc itself.)
Do you actually need multiple-precision, or would 64bits be enough?

For fixed point, Nick Gammon ported a bignum (gnu "bc") project: http://www.gammon.com.au/forum/?id=11519

Go Up