3
$\begingroup$

So I have a regular parabola to start:

$$ f(x)=a x^2+b x+c $$

I know one point $(x_1, y_1)$ on the curve, and I have a distance $L$. What I need to do is find the point $(x_2, y_2)$ on my curve that is at exactly $L$ distance along the curve away from the first point.

I know that I can get the length of a curve between two points like

$$ \int_{x_1}^{x_2}\sqrt{1+(f'(x))^2} $$

where

$$ f'(x) = 2ax + b $$

So doing the integration gives:

$$ \frac{\sqrt{4 a^2 x_2^2+4 a b x_2+b^2+1} \left(2 a x_2+b\right)+\sinh ^{-1}\left(2 a x_2+b\right)}{4 a}-\frac{\sqrt{4 a^2 x_1^2+4 a b x_1+b^2+1} \left(2 a x_1+b\right)+\sinh ^{-1}\left(2 a x_1+b\right)}{4 a}=L $$

...This is about as far as I'm able to get. If I needed to calculate $L$ between two known points, I would be done. But what I instead need to do is solve for $x_2$ in terms of $L$, $a$, $b$ and $x_1$.

That way I could plug in all the known numerical values ($a$, $b$, $x_1$, and $L$) and get the only unknown, $x_2$. Then I could plug $x_2$ into the original equation to get $y_2$ and I would have my second point that is exactly $L$ distance away from the first one.

What am I missing here? Probably there's a better way to do this?

Update

I followed @Claude Leibovici's advice and ended up with the following Mathematica Notebook (.nb), which contains a very detailed step-by-step derivation of Claude's answer.

My goal in all this was to find a solution that I could translate into traditional computer-language code for a dynamic quadratic equation defined by the coefficients ${a, b, c}$, a dynamic length $L$, and an x-coordinate for a known point which I call $u$. So here is that code, in Javascript:

https://gist.github.com/sikanrong/bd7b05b800a5086c1502e2c7033127ed

You just pass in all the knowns, and it will run newton until it converges, and returns your answer, which is the x-coordinate for the unknown point which is a distance L along the curve away from the point at x-coordinate $u$.

$\endgroup$
  • $\begingroup$ Only numerical methods (such as Newton) will solve the problem. $\endgroup$ – Claude Leibovici Jun 7 '17 at 5:19
2
$\begingroup$

As I wrote in comments, only numerical methods will solve the problem.

For illustration purposes, let us use $a=1$, $b=2$ , $x_1=3$, $L=100$. This makes the equation to be $$\frac{1}{4} \left(2 \sqrt{4 x^2+8 x+5} (x+1)+\sinh ^{-1}(2 (x+1))\right)+\frac{1}{4} \left(-8 \sqrt{65}-\sinh ^{-1}(8)\right)=100$$ where $x$ stands for $x_2$.

Let us start Newton at $x_0=3$ (I am very lazy). The iterates will then be $$\left( \begin{array}{cc} n & x_n \\ 0 & 3.00000 \\ 1 & 15.4035 \\ 2 & 10.7290 \\ 3 & 9.79891 \\ 4 & 9.75893 \\ 5 & 9.75886 \end{array} \right)$$ which is the solution for six significant figures.

Edit

We can generate a better estimate expanding the expression as a first order Taylor series around $x_1$. This would give $$ \sqrt{(2 a {x_1}+b)^2+1}({x_2}-{x_1})+O\left(({x_2}-{x_1})^2\right)=L$$ giving $$x_2^{est}=x_1+\frac{L}{\sqrt{(2 a {x_1}+b)^2+1}}$$ This gives a rather good estimate from which Newton method will converge very fast.

Using the previous numbers, this would give $x_2^{est}=15.4035$ which is, for sure, the first iterate of Newton method.

This approach leads to an overestimate of the solution. An underestimate can be obtained using the simplest Pade approximant built around $x_2=x_1$. This would give $$x_2^{est}=x_1+\frac{1}{\frac{\sqrt{(2 a {x_1}+b)^2+1}}{L}+\frac{a (2 a {x_1}+b)}{(2 a {x_1}+b)^2+1}}$$ For the test case, the first estimate would be $x_2^{est}=7.90919$.

May be, an idea could be to use the arithmetic mean of the two estimates.

$\endgroup$
  • 1
    $\begingroup$ I made a very detailed mathematica notebook (.nb), based on your suggestions. Thanks so much Claude, I hope this can help a lot of people in the same situation. With this notebook file they should be able to easily apply the same idea(s) to any curve function: drive.google.com/open?id=0B9YYph2TpOvrTVJ4aGFmMGxwVkU $\endgroup$ – Alex Pilafian Jun 8 '17 at 9:26
  • $\begingroup$ @AlexPilafian. Great to see that ! By the way, do not forget that there are two solutions to the problem. When one is obtained, the guess to the second one could be simple (I suppose). For the example I used, $x_2=9.75886$ and $x_2=-10.0641$. For sure, you wrote away. Cheers. $\endgroup$ – Claude Leibovici Jun 8 '17 at 9:36
  • $\begingroup$ @AlexPilafian. I added another estimate of the solution from the simplest Padé approximant (see my edit). I would be interested if you could test my idea (on a few examples of your choice) to use as a starting value the arithmetic mean of the two estimates. $\endgroup$ – Claude Leibovici Jun 8 '17 at 10:09
0
$\begingroup$

You can simplify this a little by translating to turn the curve into $y=ax^2$.

But the integral will look the same. Still a pain in the head.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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