Where to find algorithms for standard math functions?

Posted by dsimcha on Stack Overflow See other posts from Stack Overflow or by dsimcha
Published on 2010-01-30T22:09:24Z Indexed on 2010/03/20 22:21 UTC
Read the original article Hit count: 387

Filed under:
|
|
|
|

I'm looking to submit a patch to the D programming language standard library that will allow much of std.math to be evaluated at compile time using the compile-time function evaluation facilities of the language. Compile-time function evaluation has several limitations, the most important ones being:

  1. You can't use assembly language.
  2. You can't call C code or code for which the source is otherwise unavailable.

Several std.math functions violate these and compile-time versions need to be written. Where can I get information on good algorithms for computing things such as logarithms, exponents, powers, and trig functions? I prefer just high level descriptions of algorithms to actual code, for two reasons:

  1. To avoid legal ambiguity and the need to make my code look "different enough" from the source to make sure I own the copyright.

  2. I want simple, portable algorithms. I don't care about micro-optimization as long as they're at least asymptotically efficient.

Edit: D's compile time function evaluation model allows floating point results computed at compile time to differ from those computed at runtime anyhow, so I don't care if my compile-time algorithms don't give exactly the same result as the runtime version as long as they aren't less accurate to a practically significant extent.

© Stack Overflow or respective owner

Related posts about math

Related posts about d