ec: Optimize acos() function |
||
Issue descriptionMoved from b/35530726: math_util.c arc_cos() is inefficient. We should consider using a Taylor Series approximation in place of the existing algorithm. It will save RAM (we can dump the existing 36-entry LUT) and be faster + more accurate. See http://www.coranac.com/documents/arctangent/ - "2.6 atanTonc : homegrown Taylor expansion" for an atan() example.
,
Jun 26 2017
Here is what I found: 1) acos(x) = pi/2 - asin(x). So we can approximate asin to get acos. 2) The error from Taylor series approximation for asin(x) increases up to 0.3 rad when x is close to 1. I tried another approximation called Chebyshev - it can keep the error within 0.036. But it's kind of computation intensive (there is a division). You can check my formulas and calculation results here: https://docs.google.com/a/google.com/spreadsheets/d/1bdyBJIiXumXCG4m0oeYz2_HATEWrFZoR8yRcFfFMqaE/edit?usp=sharing 3) Weighing up pros and cons, I think current LUT method is not bad as long as we use binary search to replace linear search.
,
Dec 20 2017
As described in #2, it's probably not worth fixing. |
||
►
Sign in to add a comment |
||
Comment 1 by philipchen@chromium.org
, Jun 19 2017