1

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)

  • To b clear: are $x,M$ the only unknown variables, and in any specific case the value of $a$ might be different (or is $a$ always 4 ?) Then in each case you start with values for $f,n$ (and maybe also $a$ which I'm asking about here), and the goal is to find $M$ and the two $x$ values? – coffeemath Nov 29 '13 at 02:39
  • Correct. a is a constant. The only unknowns are x and M. – DeveloperChris Nov 29 '13 at 02:47
  • It then seems that for given $f,n$ there might be infinitely many cases where $M$ has some value and also the calculated $a,b,c$ have values that depend on $M$. Another question: are you looking for integers for the unknowns $x,M$? – coffeemath Nov 29 '13 at 02:58
  • Ah yes I should have specified that. M, x and - x are all integers. If x is not an integer M is wrong, there is only one solution for a given f,n – DeveloperChris Nov 29 '13 at 03:07
  • I should also add there is a limit on M > -1 < f/2 – DeveloperChris Nov 29 '13 at 03:42
  • Sorry, does that last restriction (given $M$ is an integer) just mean that $M$ is at least $0$ and less than $f/2$? [writing $M>-1<f/2$ isn't the standard way to write this if that's what you mean.] – coffeemath Nov 29 '13 at 04:04
  • for starters, $c=-B$. $b,c$ are linear in $M$. You should do the algebra to get the equation you want to solve. Now you have one equation in two unknowns. It can make it easy once you find the factorizations of the numbers involved. – Ross Millikan Nov 29 '13 at 04:05
  • One important thing to clear up: As you have it now, the equation for $c$ is $c=(A-B)-A$. That seems peculiar, as why not just say $c=-B$? My guess is it's a typo and it should be $c=(A-B)-a$ instead. Need to clear this up! – coffeemath Nov 29 '13 at 04:16
  • lol this is becoming a comedy of errors. While I was constructing the formula I originally had it as A-B then realised I was wrong and added -A in the actual source its -1B - fixed – DeveloperChris Nov 29 '13 at 05:08
  • Thanks Ross. The idea is to reduce the number of iterations and the resulting calculations. factoring will actually increase it. If it doesn't work as a non linear equation its not worth continuing and I'll have to change tack. – DeveloperChris Nov 29 '13 at 05:21

0 Answers0