Is Matlab generally faster at computing polynomials or trigonometric functions?
2 views (last 30 days)
Show older comments
Hi, I’ve got a pretty complicated mathematical function involving a lot of sin, cos, square roots, etc and it is called a large number of times in the program which can lead to decently long runtimes. The exact value isn’t necessarily important, so I can approximate my function with a sufficiently accurate polynomial. Is this worth it in general? I.e. is matlab ‘faster’ at computing powers than it is at computing trigonometric functions?
Answers (1)
Rik
on 7 Feb 2023
You mean you want to approximate your complicated function with many calls by a single polynomial? If that is possible with your data, that would indeed be faster, since a single polynomial calculation will be faster than many calculations put together.
To find a middle ground in terms of accuracy you could even considering determining a few domains of input ranges and compute the polynomial for each domain. That will be a trade-off between determining the polynomial and accuracy (since you obviously shouldn't compute a polynomial for every unique input).
If you need help with implementation, you should post your current function, along with reasonable example inputs.
0 Comments
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!