Share
Sign In
1️⃣

Ch1. What is Root Finding?

The Roots of a Function
What is a Root?
What is a Root?
A root is any value of x which makes the function f(x) equal to zero. Graphically, a root can be thought of as where f(x) crosses the x-axis.
Locating a root of a function is called root finding. Root finding is simply another way of solving equations, and therefore appears in many applications. Virtually any time you need to solve an equation to obtain a number for one of the variables, you’re essentially finding a root.
This function has four roots because there are
four values of x where f(x) equals zero.
Finding Roots
Roots of a simple function, like a line or a parabola, can be found using algebra.
For more complicated functions, numerical algorithms can be used to approximate the root's location.
Visualizing Roots
Plotting Functions and Estimation Roots
Estimating Roots Graphically
Looking at a plot is the easiest way to approximate a root's location. In fact, to use most numerical root finding algorithms, you will need to provide a reasonable estimate of the root, so it can be useful to visualize the function and graphically estimate the value of each root.
Estimate the roots of f(x) = x^2-3
Create an array of x values over which to plot the function. xValues is a vector with 100 equally spaced values between −3 and 3.
Calculate the function at each element of xValues. Remember to use element-wise operations.
Plot the function using xValues and yValues, and plot a horizontal line y=0. From the figure, you can identify two roots, one near x=−1.8 and the other near x=1.8.
Show plot img
Task1 - Plot a Function and Count Roots
In this activity, you will visualize the function
f(x)=\sin(2x)+e^{-x}-1 and count the number of roots between x=−2 and x=2.
1.
Use linspace to create a vector x of 100 equally spaced elements from −2 to 2.
2.
You can compute the y values by using the vector x in the expression for f(x).
Calculate f(x)=\sin(2x)+e^{-x}-1 for all values in the vector x. Assign the result to the variable y.
3.
Plot y as a function of x.
4.
Adding grid lines to the plot will include a line at y=0. This can help you identify the roots. Enter the command grid on to add grid lines to the plot.
5.
Count the number of intersections between f(x) and the line y=0. Assign the result to the variable numRoots.
Defining the Root Finding Problem
It's more common to be solving an equation than finding the root of a function. However, you can rearrange an equation to use root finding techniques to solve it. The new form of the equation is called its root finding form.
The Root Finding Form
To find the root finding form of an equation, simply move all terms to one side of the equals sign. Then define a function from the expression created this way.
There are two valid root finding forms for any equation: one created by moving all terms to the right side of the equals sign, and one created by moving terms to the left.
For example, consider the root finding forms for solving the equation x = \cos(x)
Both functions are shown in the figure to the right. Although the plots look different, the root of each function lines up with the intersection point of x and cos(x).
Task1 - Find the Root Finding Form for an Equation
In this activity, you will graphically estimate the solution to 0.5-\sin(x)=x^2 between x=−1 and x=1
1.
Use linspace to create a vector x of 100 equally-spaced elements from −1 to 1.
2.
You can create the root finding form by moving all terms in an equation to one side of the equals sign, then defining a function from the resulting expression. For example, one root finding form for x^2=2 is the function f(x)=2-x.
Rewrite the equation 0.5-\sin(x) = x^2 in root finding form to create a function f(x). Then calculate f(x) for all values of x, and assign the result to the variable y. Use element-wise operators where necessary.
3.
Plot y as a function of x.
4.
Use grid on to add grid lines to the plot.
5.
Count the number of intersections between the function and the line y=0, and assign the result to the variable numRoots.
The Roots of a Function
What is a Root?
What is a Root?
A root is any value of x which makes the function f(x) equal to zero. Graphically, a root can be thought of as where f(x) crosses the x-axis.
Locating a root of a function is called root finding. Root finding is simply another way of solving equations, and therefore appears in many applications. Virtually any time you need to solve an equation to obtain a number for one of the variables, you’re essentially finding a root.
This function has four roots because there are
four values of x where f(x) equals zero.
Finding Roots
Roots of a simple function, like a line or a parabola, can be found using algebra.
For more complicated functions, numerical algorithms can be used to approximate the root's location.
Visualizing Roots
Plotting Functions and Estimation Roots
Estimating Roots Graphically
Looking at a plot is the easiest way to approximate a root's location. In fact, to use most numerical root finding algorithms, you will need to provide a reasonable estimate of the root, so it can be useful to visualize the function and graphically estimate the value of each root.
Estimate the roots of f(x) = x^2-3
Create an array of x values over which to plot the function. xValues is a vector with 100 equally spaced values between −3 and 3.
Calculate the function at each element of xValues. Remember to use element-wise operations.
Plot the function using xValues and yValues, and plot a horizontal line y=0. From the figure, you can identify two roots, one near x=−1.8 and the other near x=1.8.
Show plot img
Task1 - Plot a Function and Count Roots
In this activity, you will visualize the function
f(x)=\sin(2x)+e^{-x}-1 and count the number of roots between x=−2 and x=2.
1.
Use linspace to create a vector x of 100 equally spaced elements from −2 to 2.
2.
You can compute the y values by using the vector x in the expression for f(x).
Calculate f(x)=\sin(2x)+e^{-x}-1 for all values in the vector x. Assign the result to the variable y.
3.
Plot y as a function of x.
4.
Adding grid lines to the plot will include a line at y=0. This can help you identify the roots. Enter the command grid on to add grid lines to the plot.
5.
Count the number of intersections between f(x) and the line y=0. Assign the result to the variable numRoots.
Defining the Root Finding Problem
It's more common to be solving an equation than finding the root of a function. However, you can rearrange an equation to use root finding techniques to solve it. The new form of the equation is called its root finding form.
The Root Finding Form
To find the root finding form of an equation, simply move all terms to one side of the equals sign. Then define a function from the expression created this way.
There are two valid root finding forms for any equation: one created by moving all terms to the right side of the equals sign, and one created by moving terms to the left.
For example, consider the root finding forms for solving the equation x = \cos(x)
Both functions are shown in the figure to the right. Although the plots look different, the root of each function lines up with the intersection point of x and cos(x).
Task1 - Find the Root Finding Form for an Equation
In this activity, you will graphically estimate the solution to 0.5-\sin(x)=x^2 between x=−1 and x=1
1.
Use linspace to create a vector x of 100 equally-spaced elements from −1 to 1.
2.
You can create the root finding form by moving all terms in an equation to one side of the equals sign, then defining a function from the resulting expression. For example, one root finding form for x^2=2 is the function f(x)=2-x.
Rewrite the equation 0.5-\sin(x) = x^2 in root finding form to create a function f(x). Then calculate f(x) for all values of x, and assign the result to the variable y. Use element-wise operators where necessary.
3.
Plot y as a function of x.
4.
Use grid on to add grid lines to the plot.
5.
Count the number of intersections between the function and the line y=0, and assign the result to the variable numRoots.
The Roots of a Function
What is a Root?
What is a Root?
A root is any value of x which makes the function f(x) equal to zero. Graphically, a root can be thought of as where f(x) crosses the x-axis.
Locating a root of a function is called root finding. Root finding is simply another way of solving equations, and therefore appears in many applications. Virtually any time you need to solve an equation to obtain a number for one of the variables, you’re essentially finding a root.
This function has four roots because there are
four values of x where f(x) equals zero.
Finding Roots
Roots of a simple function, like a line or a parabola, can be found using algebra.
For more complicated functions, numerical algorithms can be used to approximate the root's location.
Visualizing Roots
Plotting Functions and Estimation Roots
Estimating Roots Graphically
Looking at a plot is the easiest way to approximate a root's location. In fact, to use most numerical root finding algorithms, you will need to provide a reasonable estimate of the root, so it can be useful to visualize the function and graphically estimate the value of each root.
Estimate the roots of f(x) = x^2-3
Create an array of x values over which to plot the function. xValues is a vector with 100 equally spaced values between −3 and 3.
Calculate the function at each element of xValues. Remember to use element-wise operations.
Plot the function using xValues and yValues, and plot a horizontal line y=0. From the figure, you can identify two roots, one near x=−1.8 and the other near x=1.8.
Show plot img
Task1 - Plot a Function and Count Roots
In this activity, you will visualize the function
f(x)=\sin(2x)+e^{-x}-1 and count the number of roots between x=−2 and x=2.
1.
Use linspace to create a vector x of 100 equally spaced elements from −2 to 2.
2.
You can compute the y values by using the vector x in the expression for f(x).
Calculate f(x)=\sin(2x)+e^{-x}-1 for all values in the vector x. Assign the result to the variable y.
3.
Plot y as a function of x.
4.
Adding grid lines to the plot will include a line at y=0. This can help you identify the roots. Enter the command grid on to add grid lines to the plot.
5.
Count the number of intersections between f(x) and the line y=0. Assign the result to the variable numRoots.
Defining the Root Finding Problem
It's more common to be solving an equation than finding the root of a function. However, you can rearrange an equation to use root finding techniques to solve it. The new form of the equation is called its root finding form.
The Root Finding Form
To find the root finding form of an equation, simply move all terms to one side of the equals sign. Then define a function from the expression created this way.
There are two valid root finding forms for any equation: one created by moving all terms to the right side of the equals sign, and one created by moving terms to the left.
For example, consider the root finding forms for solving the equation x = \cos(x)
Both functions are shown in the figure to the right. Although the plots look different, the root of each function lines up with the intersection point of x and cos(x).
Task1 - Find the Root Finding Form for an Equation
In this activity, you will graphically estimate the solution to 0.5-\sin(x)=x^2 between x=−1 and x=1
1.
Use linspace to create a vector x of 100 equally-spaced elements from −1 to 1.
2.
You can create the root finding form by moving all terms in an equation to one side of the equals sign, then defining a function from the resulting expression. For example, one root finding form for x^2=2 is the function f(x)=2-x.
Rewrite the equation 0.5-\sin(x) = x^2 in root finding form to create a function f(x). Then calculate f(x) for all values of x, and assign the result to the variable y. Use element-wise operators where necessary.
3.
Plot y as a function of x.
4.
Use grid on to add grid lines to the plot.
5.
Count the number of intersections between the function and the line y=0, and assign the result to the variable numRoots.
The Roots of a Function
What is a Root?
What is a Root?
A root is any value of x which makes the function f(x) equal to zero. Graphically, a root can be thought of as where f(x) crosses the x-axis.
Locating a root of a function is called root finding. Root finding is simply another way of solving equations, and therefore appears in many applications. Virtually any time you need to solve an equation to obtain a number for one of the variables, you’re essentially finding a root.
This function has four roots because there are
four values of x where f(x) equals zero.
Finding Roots
Roots of a simple function, like a line or a parabola, can be found using algebra.
For more complicated functions, numerical algorithms can be used to approximate the root's location.
Visualizing Roots
Plotting Functions and Estimation Roots
Estimating Roots Graphically
Looking at a plot is the easiest way to approximate a root's location. In fact, to use most numerical root finding algorithms, you will need to provide a reasonable estimate of the root, so it can be useful to visualize the function and graphically estimate the value of each root.
Estimate the roots of f(x) = x^2-3
Create an array of x values over which to plot the function. xValues is a vector with 100 equally spaced values between −3 and 3.
Calculate the function at each element of xValues. Remember to use element-wise operations.
Plot the function using xValues and yValues, and plot a horizontal line y=0. From the figure, you can identify two roots, one near x=−1.8 and the other near x=1.8.
Show plot img
Task1 - Plot a Function and Count Roots
In this activity, you will visualize the function
f(x)=\sin(2x)+e^{-x}-1 and count the number of roots between x=−2 and x=2.
1.
Use linspace to create a vector x of 100 equally spaced elements from −2 to 2.
2.
You can compute the y values by using the vector x in the expression for f(x).
Calculate f(x)=\sin(2x)+e^{-x}-1 for all values in the vector x. Assign the result to the variable y.
3.
Plot y as a function of x.
4.
Adding grid lines to the plot will include a line at y=0. This can help you identify the roots. Enter the command grid on to add grid lines to the plot.
5.
Count the number of intersections between f(x) and the line y=0. Assign the result to the variable numRoots.
Defining the Root Finding Problem
It's more common to be solving an equation than finding the root of a function. However, you can rearrange an equation to use root finding techniques to solve it. The new form of the equation is called its root finding form.
The Root Finding Form
To find the root finding form of an equation, simply move all terms to one side of the equals sign. Then define a function from the expression created this way.
There are two valid root finding forms for any equation: one created by moving all terms to the right side of the equals sign, and one created by moving terms to the left.
For example, consider the root finding forms for solving the equation x = \cos(x)
Both functions are shown in the figure to the right. Although the plots look different, the root of each function lines up with the intersection point of x and cos(x).