2
$\begingroup$

Let's first discuss what I am trying to solve: I want to solve the diophantine equation stated below for relatively 'large' values of $r$.

$$\frac{a(a + 3)(a(r - 9) + (7 - r))}{12}=\frac{b (3 + b (-5 + r) - r)}{7}\tag1$$

The question I have is: how can I solve this equation, in the positive integers, for large values of $r$?


My try, I wrote the following code:

In[1]:=Solve[{(a*(a + 3)*(a*(r - 9) + (7 - r)))/
    12 == (b*(3 + b*(-5 + r) - r))/7, 10^5 <= r <= 10^5 + 1000}, {r, a, 
  b}, PositiveIntegers]

The only thing I got are ConditionalExpression which I am not looking for, so how can I solve this?

$\endgroup$
2
  • $\begingroup$ This is an equation of degree 4. What makes you think that there is a general solution in the positive Integers without conditions? $\endgroup$ Oct 31 '20 at 16:19
  • $\begingroup$ How large is large enough? $\endgroup$ Oct 31 '20 at 16:34
4
$\begingroup$

For fixed $r$ it works:

With[{r = 9786, abmax = 10^4},
  Solve[1/12 a (3 + a) (7 + a (-9 + r) - r) == 
        1/7 b (3 + b (-5 + r) - r) && a <= abmax && b <= abmax,
        {a, b}, PositiveIntegers]]

(*    {{a -> 117, b -> 975}}    *)

If, instead, you want to solve the equation more generally, you can start by solving for $r$:

Solve[1/12 a (3 + a) (7 + a (-9 + r) - r) == 1/7 b (3 + b (-5 + r) - r), r] // FullSimplify

(*    {{r -> (7a(3+a)(9a-7)+12(3-5b)b)/(7(a-1)a(3+a)-12(b-1)b)}}    *)

We have a solution whenever this rational $r$ is integer, i.e., whenever its numerator is divisible by its denominator:

With[{abmax = 10^4},
  Do[If[Divisible[(7a(3+a)(9a-7)+12(3-5b)b), (7(a-1)a(3+a)-12(b-1)b)] &&
        (7a(3+a)(9a-7)+12(3-5b)b)/(7(a-1)a(3+a)-12(b-1)b) > 0,
     Sow[{a, b, (7a(3+a)(9a-7)+12(3-5b)b)/(7(a-1)a(3+a)-12(b-1)b)}]],
     {a, abmax}, {b, abmax}] // Quiet // Reap // Last // First]

(*    {{3, 5, 100}, {5, 10, 125}, {5, 210, 5}, {8, 770, 5},
       {9, 21, 30}, {9, 1071, 5}, {12, 2415, 5}, {17, 6545, 5},
       {117, 975, 9786}, {122, 915, 23}}                           *)
$\endgroup$
2
$\begingroup$

Alternatively to @Roman's answer use NSolve with contrainted parameter r

NSolve[{(a*(a + 3)*(a*(r - 9) + (7 - r)))/12 == (b*(3 + b*(-5 + r) - r))/7, 1 <= a <= 10000,1 <= b <= 10000, 100 < r}, {r, a, b}, PositiveIntegers]
(*{{r -> 125, a -> 5, b -> 10}, {r -> 9786, a -> 117, b -> 975}}*) 

Without the restrictions 1 <= a <= 10000,1 <= b <= 10000 NSolve gives three conditional expressions.

$\endgroup$

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .