# What are good strategies for stable numerical approximations of special functions? [closed]

I am trying to write a scientific calculator for a very small microcontroller with no floating point unit. If the standard c math libraries were included the compiled code would be too large to fit on the device. Float arithmetic is small, but special functions ($$\sin,\cos,\tan,\arctan,\exp,\ln,a^b$$) are not. This is due to the library's use of lookup tables for correct floating point rounding and to speed things up.

To reduce code size at the expense of runtime speed, one could instead characterize the functions in terms of their series expansions or as differential equations, then approximate a solution using primitive manipulations (say, basic arithmetic).

Taylor series are not great:

• Terms might shrink slowly enough that too much error accumulates before the series tail becomes negligible. For example if the terms of $$\exp$$ are computed naively: $$x^n/n!=(x\cdot x \cdot \dots \cdot x)/(1\cdot 2 \cdot \dots \cdot n),$$ then when $$x>0$$ and $$n$$ is large each term will incur a lot of precision error. But many such terms must be evaluated to yield a precise result.

Differential equations might be better but I am unfamiliar with numerical methods for evaluating them.

Scientific calculators have been around for a long time on devices with even worse functionality than a modern cheap micrcontroller. What were they doing (what can be done) to get around this?

## closed as too broad by Don Thousand, user10354138, Brahadeesh, José Carlos Santos, max_zornOct 15 '18 at 17:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Suggestion: Consult one of the "Numerical Recipes" books, such as "Numerical Recipes in C". – awkward Oct 14 '18 at 13:26