Solving an equation involving the sum of square roots of a quadratic

477 Views Asked by At

So I am building a computer program.

In the program I need to build a function that takes this arguments {a, b, c, d, e, f, s, u}, and returns back the value of x in this equation:

$$ \sqrt{\left(x-a\right)^2+\left(\left(u\left(x-e\right)+f\right)-b\right)^2}+\sqrt{\left(x-c\right)^2+\left(\left(u\left(x-e\right)+f\right)-d\right)^2}=s $$

So basically I just need to simplify and solve the equation to get this form: $$ x=\mathrm{everythingElse}$$ And then I can code it.

The problem is that I cant solve this equation, first of all I trying to do it by hand and there is to many arguments I just couldn't solve it, than I tried to use wolfram alpha but it failed as well due to "execution time exceeded".

3

There are 3 best solutions below

3
On BEST ANSWER

Let $$A = u^2+1 \\ B = -2a+2u(f-b-ue) \\ C = a^2+(f-b-ue)^2 \\ D = -2c+2u(f-d-ue) \\ E = c^2+(f-d-ue)^2$$ Now, equation is $\sqrt{Ax^2+Bx+C}+\sqrt{Ax^2+Dx+E}=s$. After squaring twice, we get: $$[(B-D)^2-4As^2]x^2-2[BE-BC+Bs^2+CD-DE+Ds^2]x+[C^2-2CE+E^2-2Cs^2-2Es^2+s^4]=0$$ This is quadratic (or maybe linear) equation which can be solved easily. Note that due to squaring we could get extra solutions. Simplest way to remove them is to put found $x$ into initial equality and check if it holds.

3
On

The equation has the form

$$\sqrt{P(x)}+\sqrt{Q(x)}=s$$ where $P, Q$ are two quadratic polynomials in $x$. [As the coefficients of $x^2$ are the same under both radicals, you can normalize them to be $1$, dividing both members by $\sqrt{u^2+1}$.]

Squaring,

$$P(x)+Q(x)+2\sqrt{P(x)\cdot Q(x)}=s^2,$$ then squaring again

$$4P(x)\cdot Q(x)=(s^2-P(x)-Q(x))^2=s^4-2s^2(P(x)+Q(x))+(P(x)+Q(x))^2$$

or

$$0=s^4-2s^2(P(x)+Q(x))+(P(x)-Q(x))^2.$$

As $P-Q$ simplifies to the first degree, the last expression is quadratic.

0
On

Just to show that this equation is linear precisely when $s$ is at most the distance between $(a,b)$ and $(c,d)$, and hence we are talking about a degenerate ellipsis (the line segment between $(a,b)$ and $(c,d)$ or an "empty" ellipsis, with no points.

Write $(x,y)=(e,f)+t(1,u)$. Then you want $(x,y)$ to be on the ellipse with foci $(a,b), (c,d)$ and major axis $s$.

Writing $\mathbf u=(a,b)-(e,f), \mathbf v=(c,d)-(e,f)$, and $\mathbf x = (x,y)-(e,f)=t\mathbf m$, where $\mathbf m=(1,u)$ we are seeing a solution to:

$$|\mathbf u-t\mathbf m|+|\mathbf v-t\mathbf m|=s$$

Squaring, re-arranging, and squaring again gives us:

$$\begin{align} 0&=\left(s^2-|\mathbf u-t\mathbf m|^2-|\mathbf v-t\mathbf m|^2\right)^2- 4|\mathbf u-t\mathbf m|^2|\mathbf v-t\mathbf m|^2\\ &=s^4-2s^2\left(|\mathbf u-t\mathbf m|^2+|\mathbf v-t\mathbf m|^2\right)+\left(|\mathbf u-t\mathbf m|^2-|\mathbf v-t\mathbf m|^2\right)^2\\ &=s^4-2s^2\left(|\mathbf u|^2+|\mathbf v|^2 -2t(\mathbf u + \mathbf v)\cdot \mathbf m+2t^2|\mathbf m|^2\right)+\left(|\mathbf u|^2-|\mathbf v|^2+2t(\mathbf u-\mathbf v)\cdot\mathbf m)\right)^2 \end{align}$$

So this equation is linear in $t$ precisely when $$\left|(\mathbf u-\mathbf v)\cdot \mathbf m\right|=s|\mathbf m|$$

But:

$$1\geq |\cos \theta |= \frac{|(\mathbf u-\mathbf v)\cdot \mathbf m|}{|\mathbf u-\mathbf v||\mathbf m|}=\frac{s}{|\mathbf u-\mathbf v|}$$

If $s> |\mathbf u-\mathbf v|$, we reach a contradiction.

(You can deal with the case $\mathbf u=\mathbf v$ separately.)