I am trying to create a list of simultaneous equations showing steps, where I only need to change a, b and the question number, and maybe a couple of minor things about q (where q is the factored quadratic, and a & b are the integer factors). I am currently using:
a = -2; b = 1; q = 2 (a + x) (b + x);
q1 = Expand[q]; sol = x /. Solve[q1 == 0, x];
TraditionalForm[Grid[{{Grid[{{"2. (1) ", y, " = ",
If[Coefficient[q1, x, 2] == 1, "", Coefficient[q1, x, 2]], x,
If[Coefficient[q1, x, 1] > 0, "+", ""], Coefficient[q1, x, 1]},
{" (2) ", x y, " = ", , -Coefficient[q1, x, 0],
" ", " ", " ", " ", " "}}]},{Grid[{{" ", q1, "= 0"}}]},
{Grid[{{" ", Factor[q1], "= 0"}}]},
{Grid[{{"{x,y} pairs: ", {sol[[1]],
Coefficient[q1, x, 2]*sol[[1]] + Coefficient[q1, x, 1]},
",", {sol[[2]],
Coefficient[q1, x, 2]*sol[[2]] + Coefficient[q1, x, 1]}, " ",
" ", " ", " "}}]}}]]
which is a bit messy to say the least, but outputs:

not too far from the desired effect of:
$2.\quad\ \ \ (1)\quad \quad y=2x-2\\ \qquad \ \ (2)\quad \quad xy=4\\ \qquad \qquad\ \quad \ \ 2x^2-2x-4=0\\ \qquad \qquad \quad \ \ 2(x-2)(x+1)=0\\ \{x,y\}\text{ pairs: }\{-1,-4\},\{2,2\}$
though I should probably have used a table in my $\LaTeX$!
I am sure there is a better, more efficient way of doing this though.
Things I would like to improve: better spacing, automatic numbering, randomly chosen integer (or fraction) factors, random x sign changes, etc. (Basically a self-generating work/answersheet.)
Update
OK, I have replaced ubpdqn's top line with
q = RandomChoice[Join[Range[-5, -1],
Range[1, 5]]] (RandomChoice[Join[Range
[-10, -1], Range[1, 10]]] + x)
RandomChoice[Join[Range[-10, -1], Range[1, 10]]]
+ x);
q1 = Expand[q];
sol = x /. Solve[q1 == 0, x];
eqn = {y == Coefficient[q1, x, 2] x -
Coefficient[q1, x, 1],
x y == -Coefficient[q1, x, 0]};
which generates question using random numbers, but have tried putting this into a table with n number of questions & just outputs same question n times :/ I suppose copy & paste will have to do for now...




Solve[q1 == 0, x]. – Kuba Mar 06 '14 at 10:21