# [Maxima] finding minimum of ugly and parameterised function

Ivana Cace I.Cace at ati-a.nl
Thu Jun 21 03:01:14 CDT 2012

```Hi,
I'm looking for  a function that describes the shortest distance from a point (in 2D) to the graph of a sigmoid function.
To achieve this i take the function that describes the distance (squared), which is conveniently parabolic-shaped around the area of interest, and try to find the x for which f'(x)=0.
However, this derivative is pretty ugly and Maxima does not seem to be able to solve f'(x)=0.

I can find the x for the minimum distance (and so the minimim distance) for any *given* point with lbfgs. But not the general, parameterised function for *every* point.

It may help if i could add constraints, such as all x, p, q are > 0, and the additional constraint that the minimum distance is found where x is between min(p, inv_g(x))) and max(p,inv_g(q)), where inv_g(q) is the inverse of my sigmoid function and p,q are the x,y coordinates of a point.

The function describing the distance^2 looks like this:
f(x) = (p-x)^2 + (q-1.4-(5.6/(1+exp(44*(x-1.28)))))^2
with p, q the parameters for the x,y coordinates of a point

Does anyone have any tips?
Cheers,

Ivana

P.S i posted earlier but it seems i had not confirmed my list membership yet, so the previous post is awaiting moderation.

```