# Nonlinear Models, Quadratic Functions

A **quadratic function** is given by

\[f(x) = ax^2 + bx + c\]

where \(a \neq 0\). The graph of a quadratic function is called a **parabola** such that:

- it always has a cup-shaped curve
- it opens upward if \(a > 0\) or opens downwards if \(a < 0\)
- it has a turning point, or
**vertex**, whose coordinate is \(x = - \frac{b}{2a}\) - the vertical line \(x = \frac{-b}{2a}\) (which is not part of the graph) is the line of symmetry

You could think of the vertex as the first \(y\)-value. The \(x\)-intercept(s) are the \(y\)-value(s) where \(x = 0\).

The solutions of any quadratic equation \(ax^2 + bx + c = 0\), with \(a \neq 0\), are given by the quadratic formula

\[x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\]

When \(\sqrt{b^2 - 4ac} < 0\) there are no \(x\)-intercepts (not real-valued solutions). There are solutions in the *complex plane*. The standard form of quadratic equations hints at the fact that *solving* them means finding what are called their “roots”, that’s where their value is equal to zero. Being the graph of a quadratic equation a parabola, it’s then clear why we might have one, two, or no solutions (which would correspond to the \(x\)-intercepts, depending on the position of the parabola).

Let’s explore the function \(f(x) = x^2 - 2x - 3\).

```
import matplotlib.pyplot as plt
import numpy as np
def quadratic(x):
return x ** 2 - 2 * x - 3
yvalues = [quadratic(x) for x in np.linspace(-8, 10)]
xvertex = - (-2 / 2 * 1)
xvertex # which is also the vertical line of symmetry
```

`## 1.0`

```
yvertex = quadratic(xvertex)
yvertex
```

`## -4.0`

`plt.plot(range(-25, 25), yvalues)`