# Find minimum in a constrained three-variable equation

After my last question I have worked through the math quite a bit and now I'm stuck again. This time my question is less wordy.

I have two equations for $t$, one with respect to each $a_{x}$ and $a_{y}$: \begin{align*} t&=\frac{-2(u_{x}^{A}-v_{x}^{B})\pm\sqrt{4(u_{x}^{A}-v_{x}^{B})^{2}-8a_{x}(c_{x}^{A}-c_{x}^{B})}}{2a_{x}}\\ t&=\frac{-2(u_{y}^{A}-v_{y}^{B})\pm\sqrt{4(u_{y}^{A}-v_{y}^{B})^{2}-8a_{y}(c_{y}^{A}-c_{y}^{B})}}{2a_{y}} \end{align*}

Additionally $a_{x}$ can be specified as an inequality in terms of $a_{y}$: $a_{x}\leq\sqrt{a_{max}^{2}-a_{y}^{2}}$

All the variables except $t$, $a_{x}$ and $a_{y}$ are constants. How can I find a function to yield the values for $a_{x}$ and $a_{y}$ that give the lowest value for $t$?

EDIT: and this is how I arrived there:

$s_{x}^{A}, s_{y}^{A}, s_{x}^{B}, s_{y}^{B}$ : Functions for position of particles A and B on the x and y axis

$t$ : Time elapsed

$a_{x}^{A}, a_{y}^{A}$ : Acceleration of A on each axis

$a_{max}$ : Maximum magnitude of acceleration of A

$c_{x}^{A}, c_{y}^{A}, c_{x}^{B}, c_{y}^{B}$: Starting positions of A and B (constant)

$u_{x}^{A}, u_{y}^{A}$ - Starting velocity of A (constant)

$v_{x}^{B}, v_{y}^{B}$ - Velocity of B (constant)

$s^{A}=u^{A}t + \frac{a^{A}t^{2}}{2} + c^{A}$ : Function for position of A in terms of time and acceleration on one axis

$s^{B}=v^{B}t + c^{B}$ : Formula for position of B in terms of time on one axis

$a_{y}^{A}\le \sqrt{a_{max}^{2} - {a_{x}^{A}}^{2}}$ : Inequality yielding maximum acceleration on one axis in terms of acceleration on another

Optimize for t where $s^{A}=s^{B}$ on both axis: \begin{align*} s^{A}&=s^{B}\\ u^{A}t + a^{A}t2/2 + c^{A} &= v^{B}t + c^{B}\\ u^{A}t + a^{A}t2/2 - v^{B}t &= c^{B} - c^{A}\\ 2u^{A}t + a^{A}t2 - 2v^{B}t &= 2c^{B} - 2c^{A}\\ a^{A}t2 + 2t(u^{A}-v^{B}) + (2c^{A}-2c^{B}) &= 0 \end{align*} \begin{align*} t&=\frac{-2(u^{A}-v^{B})\pm\sqrt{4(u^{A}-v^{B})^{2}-8a(c^{A}-c^{B})}}{2a}&&\mbox{(quadratic formula)}\\ t&=\frac{-2(u_{x}^{A}-v_{x}^{B})\pm\sqrt{4(u_{x}^{A}-v_{x}^{B})^{2}-8a_{x}(c_{x}^{A}-c_{x}^{B})}}{2a_{x}} &&\mbox{For X}\\ t&=\frac{-2(u_{y}^{A}-v_{y}^{B})\pm\sqrt{4(u_{y}^{A}-v_{y}^{B})^{2}-8a_{y}(c_{y}^{A}-c_{y}^{B})}}{2a_{y}}&&\mbox{For Y} \end{align*}

By my questionable reasoning these functions for $t$ should give how long it will take to reach the target for a given acceleration. The two values for acceleration could be plotted on the X and Z axis in a 3D space, with $t$ on the Y axis. The constraints to maximum acceleration would reduce the function to a circular disc. The points where the acceleration would never reach the target will be undefined or infinite or something. The lowest positive point on the 'disc' on the Y axis is a point where there is a valid combination of accelerations in each direction to reach the target, and should be the fastest.

Have I gone wrong somewhere?

EDIT 2: It would be really super great if someone could point me in the right direction to learn about optimisation in 3D. Even if you think I'm approaching the problem presented in my other question wrong, I'd still like to know how to do it, which is why I phrased this question the way I did.

-
If I choose the $+$ branch on the first equation, do I also have to chose the $+$ branch in the second one? –  Fabian Mar 10 '11 at 9:27
And what is $a_\text{max}$? And how you make sure that $t$ does not become a complex number (if the term inside the sqrt becomes negative)? –  Fabian Mar 10 '11 at 9:29
In the context of the original problem $a_{max}$ is the maximum acceleration of $A$. Consider it a constant. I don't know the answer to your other questions, I'm really just stumbling through here trying to learn as I go. I guess where $t$ yields a complex number it is not a valid solution. I suspect this happens when the acceleration is in the wrong direction. –  ucclaw Mar 10 '11 at 9:51
I read through the old post. I think it would be helpful, if you would add some sentences about the problem you are solving and what the different parameters in your equations mean in terms of this problem. I guess $a$ are acceleration, $v$ velocity, $t$ time. But what is $c$? –  Fabian Mar 10 '11 at 10:00
Also not knowing what sign of the branch you chose, tells that you already don't understand something in the equations. So it would be good to sketch the approach how you obtain the equations (with which equations do you start?). –  Fabian Mar 10 '11 at 10:01

It is very simple to convince yourself (at least intuitively, but also a proof can be given if necessary) that in order to have the time $t$ as small as possible, it is best to have the largest acceleration possible. Thereby, $a_x^2+a_y^2=a_\text{max}^2$. The equations which should be fulfilled are given by $$\frac{a_x t^2}{2} + v^A_x t+ c^A_x = v^B_x t+ c^B_x \qquad \frac{a_y t^2}{2} + v^A_y t+ c^A_y = t v^B_y + c^B_y.$$ Replacing $a_y$ by $a_y = \sqrt{a_\text{max}^2 - a_x^2}$, we obtain $$\frac{\sqrt{a_\text{max}^2 - a_x^2} t^2}{2} + v^A_y t+ c^A_y = t v^B_y + c^B_y.$$ Solving the first equation for $a_x$, and plugging everything the result into the second equation yields $$\frac{\sqrt{a_\text{max}^2 - \left[\frac{2 (c^A_x- c^B_x +t (v^A_x -v^B_x)}{t} \right]^2} t^2}{2} + v^A_y t+ c^A_y = v^B_y t + c^B_y.$$
After some manipulations the last equation can be brought into the form $$\begin{multline} \frac{a_\text{max}^2}{4} t^4 + [(v^A_y- v^B_y)^2 - (v^A_x- v^B_x)^2] t^2 - 2[(c^A_x - c^B_x)(v^A_x - v^B_x)+ (c^A_y - c^B_y)(v^A_y - v^B_y)] t\\ -(c^A_x -c^B_x)^2 - (c^A_y -c^B_y)^2 =0. \end{multline}$$ Solving this equation for $t$ gives the optimal (minimal) time required. Note however that this is a quartic equation such that the solution becomes quite messy and that is why I will not write it down here.
There should be a $t^{2}$ on the denominator of your rearrangement of the first equation. I imagine this will change your final formula significantly. Your substitutions don't seem right to me - imagine for some impossible value of $t$, $a_{x}$ is calculated from your first equation to be above the limit, such that the proportionate $a_{y}$ you calculate from it in your first substitution is imaginary. The next thing you do is square it, so now you can get real answers coming from impossible values of t! I don't know what the values of t this equation produces would mean at all. –  ucclaw Mar 11 '11 at 3:41