So far, we have looked at plotting data using a scatter plot and using a line-of-best-fit to examine the general trend of the data; however, theres one major problem with plotting data like this: plotting points one-at-a-time can a long time if you have a lot of data! To fix this, we can define equations which specify each data point. The standard form of the equation for linear data (we'll look at what "linear" means soon) is:
\(y = mx + b\)
This equation is an example of a polynomial.
-
A polynomial is an expression with constants or variables that are combined with addition, subtraction, multiplication, or division.
There are certain rules associated with polynomials:
-
A variable cannot be in a denominator (i.e. if the variable has an exponent, it must be a natural number, which may also be 0).
-
The expression cannot have an infinite number of terms.
The equation we looked at above is an example of a polynomial.
But what does this equation actually do? Well, it's actually really simple: given an x-value, it will spit out a corresponding y-value. Let's take a look at an example equation:
\(y = 2x + 3\)
Here's a chart of some sample x-values and their corresponding y-values.
\(x\) |
\(y\) |
0 |
3 |
1 |
5 |
2 |
7 |
3 |
9 |
4 |
11 |
In this chart, ( \(x\) ) defines values from the x-axis of our graph, and ( \(y\) ) defines values from the y-axis of our graph. The ( \(b\) ) value defines where our line will intersect the y-axis. Finally, the ( \(m\) ) value defines the slope of our line.
The "slope" of a line is defined by the rise divided by the run and can be defined by the following equation:
\(m = (y_2 - y_1)/(x_2 - x_1)\)
In the above equation, the "rise" of the line is seen as:
\(rise = y_2 - y_1\)
The "run" of the line is seen as:
\(run = x_2 - x_1\)
The data points ( \(x_1,y_1\) ) and ( \(x_2,y_2\) ) are two arbitrarily chosen data points that can be found on the line. Let's see what the following equation would look like when plotted (again, for simplicity, only the first quadrant is shown):
\(y = 2x + 3\)
Now let's see what the ( \(b\) ) value of this line is by looking at the plot. As the plot intersects the y-axis at \(y=3\), \(b=3\). This can be clearly seen in the above chart as well. When \(x=0\), the corresponding y-value is our b-value. The ( \(m\) ) value of the plot can be calculated by choosing two arbitrary points, let's pick (1,5) and (3,9).
Now let's plug the values ( \(x_1 = 1\), \(y_1 = 5\), \(x_2 = 3\), \(y_2 = 9\) ) that into our equation:
\(m = (y_2 - y_1)/(x_2 - x_1)\)
\(m = (9 - 5)/(3 - 1)\)
\(m = 4/2\)
\(m = 2\)
And that's it! We can now plot any straight line on a cartesian grid.