Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have the following expression (used in a computer program): $$f(x)=b^{{k}^{ax}}$$

where $k$ is a constant and $a$ and $b$ are given. I need to calculate the distance from this curve to a point $P: (c,d)$. The simple procedure would be to take the derivative of the equation

$$\frac{\partial(distance)}{\partial x}=\sqrt{(c-x)^2+(d-f(x))^2} = 0$$

That will get me the x of the curve that is closest to the point. The problem here is solving for x. The expression is quite complex (and out of my mathematical capacities) to be solved by me. I tried using Mathematica, but I didn't get the result using Solve's. Am I left with using iterations? I'd rather avoid that option, since I require some speed in the processing.

Note: Not sure of which tags to use.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Yes, this is the right approach.

A common trick when minimizing distance is to minimize distance squared instead, which has the same optimum but a much cleaner derivative.

You will get the equation

$$(x-c) + (b^{k^{ax}} - d)b^{k^{ax}}k^{ax} a\log b\log k = 0$$

and there is little hope of solving this equation for $x$ in closed form. Your best bet is to find a numerical solution iteratively using Newton's method. If you have to repeat the calculation many times, with $a,b,c,d$ changing only slightly each time, you will want to use the previous $x$ as your initial guess for computing the next $x$, and Newton's method will likely converge in very few iterations.

share|improve this answer
add comment

Depending on the values of $a,b,k$, this is likely to be a very rapidly growing function. If so, it is (almost) vertical, so the perpendicular is (almost) horizontal. In this approximation, the shortest distance will be when $f(x)=d$, so you can just say

$d=b^{k^{ax}}\\ \log d=k^{ax} \log b \\ \log \log d=ax \log k + \log \log b \\ x=\frac{\log \log d - \log \log b}{a \log k}$

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.