I have an equation in the following form that needs to be solved for $x$, with $x > 0$ and constants $a,b,c,d \geq 0$.
$\left(\frac{x - a}{b}\right)^2 + \left(\frac{x - c}{d}\right)^2 = 1$
From the following paper, which i am trying to implement: https://grail.cs.washington.edu/projects/crowd-flows/78-treuille.pdf
Wolfram Alpha gives the following solution:
$x = \frac{\sqrt{b^2 d^2 (-a^2 + 2 a c + b^2 - c^2 + d^2} + a d^2 + b^2 c}{b^2 + d^2}$
However this can result in the root of a negative number, and resulting in a complex number, which is not what the paper seems to want. I am unsure on how to solve this (in code) to get a real value for x.
So my question is, how do i solve this equation as desired by the paper?
PS. Limiting to real x still has the same problem
Consider the equation $\left(\frac{x-a}{b}\right)^2 + \left(\frac{y-c}{d}\right)^2 = 1$. It is an ellipsis centered at $(a,c)$ with axes parallel to origin of lengths $b$ and $d$ respectively. The solution of your task are the points where this ellipsis intersects with the line $y=x$. There may be no intersection - and that is exactly the case of complex roots.