jowen6 / CppPractice

0 stars 0 forks source link

Efficient Arctangent Function #11

Open srowe12 opened 6 years ago

srowe12 commented 6 years ago

Priority: Low Difficulty: ?

I would like an arctangent function that is as efficient as possible with minimal loss in precision. It should mimic the API of std::atan2 and hence handle quadrants appropriately

Bonus: if OpenMP is available, it should be able to handle vectorized inputs. I think this can be accomplished simply with a ‘#pragma omp declare simd’

jowen6 commented 5 years ago

I'm not sure I understand how to do this. We know arctan(x) = theta. My first thought was to do a root finding algorithm for something like f(theta) = x-tan(theta) for up to an arbitrary tolerance. Is that what you want or do you want some Taylor series thing?

srowe12 commented 5 years ago

This is more of an exploratory problem on how to approach this. This actually is likely a math problem in disguise. Arctangent computation is extremely slow; assume there is some algorithm that is performance intensive and I need an approximation of Arctangent that is fast and reasonably accurate. Typically, Taylor series are not great for numerical approximations so perhaps something else.