duc has asked for the wisdom of the Perl Monks concerning the following question:

Hi all !

I am programming an application in which I need to find the minimum of a list of x and y. i.e. The minimum of a paraboloid for example or any other polynomial.

I am currently using the module Math::Polynomial and it does return the minimum of the list as well as the equation representing it.

My problem is, I need to know the x value where the minimum was found, not only the minimum value.

Is there a module that would send back the minimum and its associated x or a module with which I could solve an equation of the type y = n*x^n + n1*x^n1 + ...+ a*x^2+b*x+c (y is known, we're looking for x)?

Replies are listed 'Best First'.
Re: polynomial fit module
by swampyankee (Parson) on Aug 22, 2006 at 15:46 UTC

    The best way to find the minimum of a polynomial (or, in general, any differentiable function) is to take the derivative and solve it for 0. This actually gives the extreme; you would then evaluate the 2d derivative at that point to see whether its a maximum or minimum. You could try Math::Symbolic::Derivative or Math::Derivative to get the derivatives. If you're only concerned with a range of x values, and f'(x) doesn't cross zero in this range, the minimum will be at one of the endpoints of the interval.

    Since you're always dealing with polynomials, it should be simple to write a sub to give you the derivative, i.e., you can probably do without Math::Symbolic::Derivative or Math::Derivative.

    emc

    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.

    Albert Einstein
      Thanks to you. It is a really nice reminder about how to find a minimum but unfortunately, I cannot use it directly. I guess I haven't defined my problem well enough. I have a list of x and y, not the equation it represents. So I have to find it. Math::polynomial does the job for me and it also gives me the extremum. Which is exactly what I need. So, I need to resolve the equation y = polynomial to get the x that matchs the y found. But, then againg, I think I have asked too soon, I did finally found a module who looks like it can solve my problem (with that dear google friend of mine) : Math::GSL::Polynomial.
Re: polynomial fit module
by explorer (Chaplain) on Aug 22, 2006 at 16:49 UTC