This lesson covers the numerical method of root finding for equations with **one **variable. The main focus of this lesson is not the analytical method of root finding, but the numerical method as it can be applied to any function type. As such, it is more so an approximation of the root value rather than solving for it directly.

The first topic, **Functions, Graphs, and Roots**, is more of a refresher topic that covers basic high school math. You may skip it should you wish to.

The term “polynomial” is a general representation of mathematical expressions consisting of variables and coefficients. It involves operations of addition, subtraction, multiplication, and non-negative integer exponentiation of variables.

Some example of valid polynomials include:

A polynomial has three distinct parts. They are:

- Variables
- Coefficients
- Exponents

**Variable**

- Value unknown
- Usually denoted by

**Coefficient**

- A constant that scales the value of each term.
- Usually denoted by if unknown

**Exponent**

- A constant that exponentiates the variable instead of multiplying it.
- Usually denoted by if unknown

**Univariable polynomials**

**one**variable.

Let’s take a look at a simple polynomial:

Variable(s): x

Coefficient(s): [3 1 -1]

Exponent(s): [2 1 0]

**Degrees**

Polynomial | Degree |

In NM Dev, a polynomial is represented by the class Polynomial. For example, to

represent this polynomial: , we construct

a Polynomial instance, supplying the constructor with the coefficients starting from

the highest order term.

` ````
```%use s2
// a polynomial P(x) = (x-1)(x-2)(x-3)(x-4) = x^4 - 10x^3 + 35x^2 - 50x + 24
val myPoly: Polynomial = Polynomial(1.0, -10.0, 35.0, -50.0, 24.0)
// myPoly is a polynomial of degree 4
println(myPoly)

Output: 1.00(x^4)-10.00(x^3)+35.00(x^2)-50.00(x^1)+24.00

Functions can be thought of as a converter which receives ** at least one** input value and returns

*output value.*

**o****nly one**The general form of a function can be written as:

where … are the inputs and is the output.

Since we’re only dealing with **one** variable, , our function can be simplified to .

**Inner workings of a function**

The output of a function is computed using a series of operations on the given input(s).

Some functions could be:

(linear)

(quadratic)

(exponential* not covered in this lesson)

**Domains and Ranges**

Every function has a domain and a range over which the function is valid.

**Domain**

Some functions like have a domain that extends throughout the whole real line, meaning the domain . Alternatively, it can be said that is valid

While most functions have domains , some functions have domains that do not encompass all real numbers.

Function | Domain | Domain (Set Notation) |

**Range**

The range of a function is the region over which a valid output can be obtained given the specified domain.

Here are the ranges for some functions:

Function | Range | Range (Set Notation) |

In NM Dev, a function is represented by the interface UnivariateRealFunction.

Typically, we use the class AbstractUnivariateRealFunction to simplify

implementation.. For example, to represent this function: , we

construct an instance of AbstractUnivariateRealFunction

` ````
```%use s2
UnivariateRealFunction f = new AbstractUnivariateRealFunction() {
@Override
public double evaluate(double x) {
return Math.sin(x) * x - 3;
}};
System.out.println("f(1) = " + f.evaluate(1.));

Any function can be plotted on a graph with the x-axis being the input and the y-axis being the output. In doing so, graphs serve as a visual representation for functions and mathematical equations.

**Roots**

By definition, the point at which a graph intersects the x-axis is considered a root. As , the x-value at that point is a **solution** to the equation .

Finding roots also allow for the factorization of polynomial functions.