Quadratics#

A quadratic (with the variable \(x\)) is any expression of the form:

\[ ax^2 + bx + c \]

where \(a\), \(b\), and \(c\) are constants. It is called a quadratic because it contains terms of \(x\) up to and including \(x^2\).

A quadratic function has the form:

\[ y = ax^2 + bx + c \]

again, \(a\), \(b\), and \(c\) are constants. There are a number of examples of such functions illustrated in the sections that follow.

Expanding Brackets to Produce a Quadratic#

Quadratic expressions can also be factorised and written in the form:

\[ (x+A)(x+B) \]

where \(A\) and \(B\) are constants. We have a method called FOIL for expanding quadratic equations in the above form, so that they appear in the form \(ax^2+bx+c\).

FOIL stands for First, Outer, Inner, and Last and tells us which terms to take the product of. In the general case \((x+A)(x+B)\) FOIL works as follows:

  1. The First terms will be the \(x\)s since they are both first in their brackets.

  2. The Outer terms will be \(x\) and \(B\) because they are on the outer side (nearest to the edges).

  3. The Inner terms are \(A\) and the other \(x\) as they are on the inner.

  4. The Last terms are \(A\) and \(B\) because these are last in their brackets.

We then expand our quadratic \((x+A)(x+B)\) as shown below.

\[ (x+A)(x+B) = x\times x + x \times B + A \times x + A \times B = x^2 + (A+B)x + AB \]

Example

Expand the brackets of the following:

  1. \((x+5)(x+7)\)

  2. \((x-3)(x+2)\)

  3. \((x+1)^2\)

Solution:

  1. We use FOIL to get:

    \[ (x+5)(x+7) = x\times x + x\times 7 + 5 \times x + 5 \times 7 \]

    Multiplying these out gives:

    \[ x^2 + 7x + 5x + 35 = x^2 + 12x + 35 \]
  2. There are some negative numbers here so be careful when using FOIL

\[\begin{split} \begin{aligned} (x-3)(x+2) & = x\times x + x\times 2 + (-3 \times x) + (-3 \times 2) \\ & = x^2 + 2x - 3x - 6 = x^2 - x - 6 \end{aligned} \end{split}\]
  1. We can write \((x+1)^2\) as \((x+1)(x+1)\), which we can then apply FOIL to

\[\begin{split} \begin{aligned} (x+1)(x+1) & = x\times x + x\times 1 + 1 \times x + 1 \times 1 \\ & = x^2 + x + x + 1 = x^2 + 2x + 1 \end{aligned} \end{split}\]

As you would expect, sympy can work with expanding these.

from sympy import symbols, expand

x = symbols('x')

expand((x + 5) * (x + 7))
\[\displaystyle x^{2} + 12 x + 35\]
expand((x - 3) * (x + 2))
\[\displaystyle x^{2} - x - 6\]
expand((x + 1) ** 2)
\[\displaystyle x^{2} + 2 x + 1\]