[Open-graphics] Other interesting bits of math to do in FPGAs
Philipp Klaus Krause
pkk at spth.de
Fri Sep 28 10:34:02 EDT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Timothy Normand Miller schrieb:
> For the MIP maps? In that case, not much. Otherwise, I'm just
> talking about general stuff, so the precision requirement depends on
> the problem.
I've looked at implementing logarithms on computers a bit in the last
few days (I'm interested in how to efficiently compute them in shaders).
Since we need log2 for the mantissa the approximation has to be good in
the interval [1,2[ only.
While there are much better algorithms for computing log than the
following solution these more better algorithms are more efficient at
high precisions only.
I suggest a power series approximation based on the aretangens hyperbolicus:
Let c(k) := 2/(ln(2) * (2k + 1)), p(x,k) := ((x-1)/(x+1))^(2k + 1)
Then log2(x) = c(0)p(x,0) + c(1)p(x,1) + c(2)p(x,2) + ...
If you don't need a lot of precision just take the first few summands only:
Just c(0)p(x,0) will approximate log2 with a maximum error of 0.04.
c(0)p(x,0)+c(1)p(x,1) will approximate log2 with a maximum error of 0.0025
c(0)p(x,0)+c(1)p(x,1)+c(2)p(x,2) gives maximum error of 0.0002
c(0)p(x,0)+c(1)p(x,1)+c(2)p(x,2)+c(3)p(x,3) gives maximum error of 0.000018
I've attached the subsection on log2 of something I'm currently writing
for university. While it might be useful, this is just a small piece of
a mostly unfinished document and might contain errors.
Philipp
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG/RDabtUV+xsoLpoRAvAlAKDZP4O1fz1dOfxPnCb+PA0J5rJiJACfSEZu
soYiGKArOuIupq0KRjizMN4=
=NCg7
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: log2.pdf
Type: application/pdf
Size: 61059 bytes
Desc: not available
Url : http://lists.duskglow.com/open-graphics/attachments/20070928/62dfc681/log2-0001.pdf
More information about the Open-graphics
mailing list