Search code examples
mathcomputational-geometrysymbolic-mathcomputation

check in a given math function how many zeros exist in a given interval


Recently I've been asking myself this question. I know a way to solve it consisting in having a certain x step, and then testing the value of f(x). If f(x).f(x before) < 0, then i know that alteast one zero is there. However, i don't know how to configure the step to include all zeros. This because functions can change how much zeros they have in a given interval greatly. For example, sin(100*x)(blue graph) compared to sin(x)(red graph).

I appreciate you could help me on this one.

Thanks!

enter image description here


Solution

  • There isn't a general solution that would work for all mathematical functions. In the case of polynomials, you can use Sturm's Theorem. In the case of sin(x*k) it is x * pi / k.

    You will have to detect the specific type of function you are working with and then count the roots depending on that.