0

I am dynamically creating worksheets and I need to come up with some a, b and c values for a quadratic equation that will yield an integer x. How can I do this?

Shamoon
  • 119
  • ${a,b,c}={1,0,-n^2}$? or ${a,b,c}={1,-2n,n^2}$ – lulu Aug 18 '16 at 13:52
  • In the second case a will always be 1. Can I somehow make that not the same always? – Shamoon Aug 18 '16 at 13:54
  • You can just multiply through by a constant. ${m,-2mn,mn^2}$ – lulu Aug 18 '16 at 13:56
  • First, pick $a$, $b$ and $x$. Now, $ax^2+bx+c=0$, so $c=-ax^2-bx$. – Mastrem Aug 18 '16 at 13:56
  • 4
    You could always expand the product $$ (a_1x - b_1)(a_2x - b_2) = \ (a_1a_2) x^2 - (a_1b_2 + b_1a_2)x + b_1b_2 $$ it suffices to select integers $a_1,a_2,b_1,b_2$ (with $a_1,a_2$ non-zero). The solutions are $x = b_1/a_1, x = b_2/a_2$. – Ben Grossmann Aug 18 '16 at 13:59

1 Answers1

5

The easiest way is to simply choose roots $r_1$, $r_2$ and second degree coefficient $\alpha\neq 0$ as integers, then expand the expression $$p(x) = \alpha (x-r_1)(x-r_2). $$

Example. Let $\alpha = 2$, $r_1 = -1$ and $r_2 = 3$, then we get

$$p(x) = 2(x-(-1))(x-3) = 2x^2 - 4x -6, $$ which has the requested integer roots $-1$ and $3$.

Coefficients. By expanding $p(x)$ in general you get that $$p(x) = Ax^2 + Bx + C$$ with \begin{align} A &= \alpha\\ B &= -\alpha(r_1 + r_2)\\ C &= \alpha r_1 r_2. \end{align}

Eff
  • 12,989