I'm trying to get a formula for $x_2$ coordinate of right trapezoid ABCD, which surface area equals $s$, given $(x_0, y_o)$ and $(x_1, y_1)$.
I arrived to this equation: $$\frac a2x_2^2 + (y_0-ax_0)x_2 - y_0x_0 + \frac a2x_0^2 - s = 0$$ where $a = (y_1-y_0)/(x_1-x_0)$.
When I try to solve it with some test values, I'm getting a negative determinant, which indicates that my equation is incorrect. Where is the error?
I derived my equation from: $$s = (x_2-x_0)(y_2+y_0)/2$$ and $$y_2 = y_0 + a(x_2-x_0)$$
by substituting $y_2$ in the first one.
The test values I'm using are: $(x_0, y_0) = (1, 1); (x_1, y_1) = (2, 0.1); s = 0.4$, which result in $-0.45x_2^2 + 1.9x_2 - 2.05 = 0$ equation with $-0.08$ determinant.