I have a program where I am currently solving for the difference of X₁ and X₂ of a line-segment where the area under the line-segment (A), the slope (s), and the starting point (X₁,Y₁) are known.
Example: For A=65, s=0.5, X₁=8, Y₁=4, X₂=?, Y₂=? Find X₂
The algorithm I am using works by recursively assigning bigger and bigger displacements of X₂ using A=(Y₁+Y₂)/2*(X₂-X₁) to see if see if my target area is between its current iteration and previous iteration, and once it finds an X range that contains the target area, it recursively cuts the X range in half adjusting the range into either the upper or lower half of the previous range until it digs down to a range small enough to get the integer of (X₂-X₁) for the target area.
Much like sorting functions, this works fine on a small scale, but can bog down a computer as you start to need to run this function on a lot of data-sets over a short period of time.
Is there a way to solve for this with either an equation, or a algorithm that does not need so many passes?