Bobbi Towers / May 14 2019

Quadratics

1. Zero product property

Find the zeros of the function.

For any two expressions and :

If then either or .

This is called the zero product property.

In our case, . So either or :

In SymPy, we can do this:

pip install sympy
import sympy as sp
x = sp.Symbol('x')
sp.solveset((x - 3)*(2*x - 8))
$\displaystyle \left\{3, 4\right\}$

For our Clojure function, we will take an equation as input represented by a vector [b c] , which we will assume to be the values of a polynomial in standard form, that is, .

(defn root [[b c]]
  (- (/ c b)))

(defn roots [eq1 eq2]
  [(root eq1) (root eq2)])
(roots [1 -3] [2 -8])
Vector(2) [3, 4]

Solve for .

(roots [1 -7] [-4 -2])
Vector(2) [7, Vector(2)]

Find the zeros of the function.

(roots [-5 -1] [2 8])
Vector(2) [Vector(2), -4]
(roots [1 6] [-1 1])
Vector(2) [-6, 1]

2. Graphing quadratics in factored form

What is the vertex of the parabola?

(defn vertex [f1 f2]
  (let [x (/ (+ (root f1) (root f2)) 2)
        y (* (+ (* (first f1) x)
                (last f1))
             (+ (* (first f2) x)
                (last f2)))]
    [x y]))

(vertex [1 -5] [1 1])
Vector(2) [2, -9]

((juxt roots vertex) [1 -2] [1 -6])
Vector(2) [Vector(2), Vector(2)]
((juxt roots vertex) [1 3] [1 7])
Vector(2) [Vector(2), Vector(2)]

Graph the function.

Finding the roots will be the same, as well as finding the vertex's -coordinate, but now must write a new vertex function that will take another factor :

(defn vertex [n f1 f2]
  (let [x (/ (+ (root f1) (root f2)) 2)
        y (* n
             (+ (* (first f1) x)
                (last f1))
             (+ (* (first f2) x)
                (last f2)))]
    [x y]))

{:vertex (vertex 5/9 [1 9] [1 3])
 :roots (roots [1 9] [1 3])}
Map {:vertex: Vector(2), :roots: Vector(2)}

Graph the equation.

{:vertex (vertex2 1/8 [1 -6] [1 2])
 :roots (roots [1 -6] [1 2])}
Map {:vertex: Vector(2), :roots: Vector(2)}