Is Matlab generally faster at computing polynomials or trigonometric functions?
Afficher commentaires plus anciens
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?
1 commentaire
Réponses (1)
Rik
le 7 Fév 2023
0 votes
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.
Catégories
En savoir plus sur Polynomials dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!