Can the following quadratic equation be solved for M without iterating over possible values

110 Views Asked by At

I have developed this equation for a piece of software I am writing. Not being very mathematically minded I am stumped at how I can solve for M without iterating over all possible values for M. The problem for me is I have two unknown variables x and M. While in the solution below it is very simple to find M over a few iterations I have many of these to do involving much larger values and the processing time adds up.

A = f(f+M) - n
B = (f-2)(f+M+2) - n

a = 4 (constant)
b = A-B+a
c = -B

ax^2+bx+c=0

One example and solution :-

Input:

f=62253
n=3875204537

Result:

M=96 (integer M > -1 < f/2)
x=1221,-1271 (integers)

What is the fewest number of steps to find M?

Note: Although I have shown the negative result for the quadratic function it is actually irrelevant so is not required in the solution.

Any ideas appreciated DC

Another Note: I don't think there is a solution (outside of factoring, which is too cpu expensive) But I posted this because the last time I thought there wasn't a solution it was solved in minutes by someone with more knowledge in math than me. I am hoping I am once again badly wrong.

Final Note: I have totally reworked my problem to remove the unknowns x and y. the question has been re-asked here. solve for m by rewriting the equation (transposition)