# How can I choose the coeffcients so that the givent system of equations has four integer solutions?

Consider the system of equations with unknown are $(x,y)$. $$\begin{cases} a_1x^2+b_1y^2 + c_1xy+d_1x + e_1y+f_1=0,\\ a_2x^2+b_2y^2 + c_2xy+d_2x + e_2y+f_2=0. \end{cases}$$ I want to find the coeffcients $a_1$, $b_1$, $\ldots$, $f_1$ and $a_2$, $b_2$, $\ldots$, $f_2$ with these numbers belong, e.g, $[-5,5]$ so that the givent has four solutions and all solutions are integer.

It is difficult for me to find. And then, I tried the coefficient $a_1$, $b_1$, $\ldots$, $f_1$ and $a_2$, $b_2$, $\ldots$, $f_2$ knowing that the system of equations has three integer solution, for example $$(x=-4\land y=-2)\lor (x=-3\land y=-1)\lor (x=1\land y=-2).$$ I tried

Clear[f]
f[x_, y_] := a*x^2 + b*y^2 + c*x*y + d x + e y + 4
l = {a, b, c, d, e} /.
Solve[{f[-3, -1] == 0, f[-4, -2] == 0, f[1, -2] == 0,
1 <= a <= 10, -10 <= b <= 10, -10 <= c <= 20, -10 <= d <= 20,
a b c d e != 0}, {a, b, c, d, e}, Integers]
Length[l]
Binomial[Length[l], 2]


I got

{{1, -9, 3, 9, -14}, {1, -6, 2, 7, -8}, {1, -3, 1, 5, -2}, {1, 3, -1, 1, 10}, {1, 6, -2, -1, 16}, {1, 9, -3, -3, 22}, {2, -8, 2, 10, -10}, {2, -5, 1, 8, -4}, {2, 1, -1, 4, 8}, {2, 4, -2, 2, 14}, {2, 10, -4, -2, 26}, {3, -10, 2, 13, -12}, {3, -7, 1, 11, -6}, {3, -1, -1, 7, 6}, {3, 2, -2, 5, 12}, {3, 5, -3, 3, 18}, {3, 8, -4, 1, 24}, {4, -9, 1, 14, -8}, {4, -3, -1, 10, 4}, {4, 3, -3, 6, 16}, {4, 6, -4, 4, 22}, {4, 9, -5, 2, 28}, {5, -5, -1, 13, 2}, {5, -2, -2, 11, 8}, {5, 1, -3, 9, 14}, {5, 4, -4, 7, 20}, {5, 7, -5, 5, 26}, {5, 10, -6, 3, 32}, {6, -4, -2, 14, 6}, {6, -1, -3, 12, 12}, {6, 2, -4, 10, 18}, {6, 5, -5, 8, 24}, {6, 8, -6, 6, 30}, {7, -9, -1, 19, -2}, {7, -6, -2, 17, 4}, {7, -3, -3, 15, 10}, {7, 3, -5, 11, 22}, {7, 6, -6, 9, 28}, {7, 9, -7, 7, 34}, {8, -8, -2, 20, 2}, {8, -5, -3, 18, 8}, {8, -2, -4, 16, 14}, {8, 1, -5, 14, 20}, {8, 4, -6, 12, 26}, {8, 7, -7, 10, 32}, {8, 10, -8, 8, 38}, {9, -4, -4, 19, 12}, {9, -1, -5, 17, 18}, {9, 2, -6, 15, 24}, {9, 5, -7, 13, 30}, {9, 8, -8, 11, 36}, {10, -3, -5, 20, 16}, {10, 3, -7, 16, 28}, {10, 6, -8, 14, 34}, {10, 9, -9, 12, 40}}

However, in $C^2_{55}=1485$ systems, some systems have not four interger solutions If I don't choose given three solutions, how can I choose the coefficient. E,g.

u = l[[5]];
v = l[[6]];
w = {x^2, y^2, x y, x, y};
Reduce[{u.w + 4 == 0, v.w + 4 == 0}, {x, y}, Reals]
Factor[u.w + 4]
Factor[v.w + 4]


My question is how can I choose the coefficient $a_1$, $b_1$, $\ldots$, $f_1$ and $a_2$, $b_2$, $\ldots$, $f_2$ so that the givent system of equations has four integer solutions?

I post this as a way to generate integer solutions. The desired result could be extracted. I appreciate letting Mathematica do it with constraints already does this. I am not clear what is being asked. Perhaps this will lead to clarification:

func[p_] :=
Module[{v = {a, b, c, d, e, f}, m},
m = {#1^2, #2^2, #1 #2, #1, #2, 1} & @@@ p;
v /. First@Solve[v.# == 0 & /@ m, v, Integers]]
q[a_, b_, c_, d_, e_, f_, x_,
y_] := {a, b, c, d, e, f}.{x^2, y^2, x y, x, y, 1}
sol[s_, t_, p_] := func[p] /. {C[1] -> s, C[2] -> t}
testsol[u_, a_, b_] := q[##, Sequence @@ u] & @@ sol[a, b];


func provides solution given p (in this case 4 points). q is just the quadric. sol provides a specific solution after providing for values of constants. testsol can be used to test specific solution (u is test point).

Example:

test2 = RandomInteger[{-5, 5}, {4, 2}];
t2 = sol[##, test2] & @@@ Tuples[Range[-5, 5], 2];
tab = Module[{k = q[##, x, y] & @@@ t2},
Column[{test2,
ContourPlot[# == 0, {x, -5, 5}, {y, -5, 5}, Evaluated -> True,
PlotLabel -> (Style[# == 0, 6]),
Epilog -> {Red, PointSize[0.02], Point[test2]}]}] & /@ k];


I have not tidied, particularly removing repeated solutions (eg scaled versions of same solutions including -). I apologize I am time poor. I apologize if this is completely off the mark.

• In the line t2 = sol[##, test2] & @@@ Tuples[Range[1, 5], 2] , how can I get GCD[a,b,c,d,e,f]==1 ? May 4, 2016 at 10:23
• @toandhsp once the solutions are generated you can use Select or Pick (see documentation). Please try these. I have found the best way to develop is to play. I am not near a computer at present. Good luck:) May 4, 2016 at 10:27