Name:  Don Anglen

Title:  Slope Intercept

Description:  This lesson solves and graphs linear equations, explains the slope-intercept form of a line, and explains some Mathematica  language.

Slope Intercept

The slope-intercept equation of a line is y = mx + b.
The "m" is the slope of the line, and the "b" is the ordinate of the point where the line crosses the "y" axis.  We will use the line y = 2x + 3, where m=2 and b=3 as the line we will use most frequently until we change the parameters "m" and "b" to work similar problems.  This is text style:  no operations will perform.

This is input style:  operations will occur.

The ] on the right side are called "cells".  Each cell is used for different parts of the output or problem.

Clear[b,m,x,f]
f[x_] = m x + b
m=2;
b=3;
Solve[f[x]==0,x]

When "m" is multiplied by "x" in Mathematica, a space implies the multiplication.  The "==" symbol is the Mathematica operation for "=".

Add this step to graph the linear function; "Plot[f[x],{x,-5,5}]"

Plot[f[x],{x,-5,5}]

Notice the solution of the function when f[x] = 0: -(3/2), is where the line crosses the x-axis.

The width of the units on the "x" and "y" axes should be the same. To do that, add this step: "AspectRatio->Automatic".

Plot[f[x],{x,-5,5},
AspectRatio->Automatic]

To label the axes, add this step: AxesLabel->{"x","y"}.

Plot[f[x],{x,-5,5},
AspectRatio->Automatic,
AxesLabel->{"x","y"}]

The "m", coefficient of "x", is the "slope" of the line.  The slope is the steepness of the line.  The steeper the line, the larger the absolute value of m.  Conversely, the larger the absolute value of m, the steeper the line.

Plot[f[x],{x,-5,5},
AspectRatio->Automatic,
AxesLabel->{"x","y"}]

With all the commands together, the program also works by pressing the enter key.
Since the slope "m" is a positive number, the line will go up and to the right.

Now let's graph a line with m = -2.

Clear[b,m,x,f]
f[x_] = m x + b
m=-2;
b=3;
Plot[f[x],{x,-5,5},
AspectRatio->Automatic,
AxesLabel->{"x","y"}]

Notice the line rises up and to the left with a negative slope.

To find the ordinate of a point on the line, choose a value for          the independent variable x.  x=4.

2 4 + 3

Substitute 2 in for m, 4 in for x, and 3 in for b in the linear line y = mx + b.  The point (4,11) is on the line.  In Mathematica the space between the 2 and the 4 tells the computer to multiply.  In Mathematica, after the 3, press the enter key and the operation is performed.

2 4 + 3

N[%]

The symbol (%) repeats the previous operation.  The symbol (N) gives the ty the answer as a decimal. The symbol (N) works the problem out to a numerical number in scientific notation, if the answer is > one million.

If x = 4000000, find y in y = mx + b.

N[2 4000000 + b]

The answer (8. 10ﬂ) means the number (8) times the number 1000000.  10ﬂ = 1000000.  The exponent 6 tells you the number of zeros, or move the decimal point 6 places to the right of the (1).  8 times 1000000 = 8000000.

Place different values in for "m" and "b" to work other problems now and some more difficult problems later.

Find the ordinate of a point whose abscissa is (c + d).  Substitute in for (x) in the original linear function                (y = mx + b):  y = 2(c + d) + 3.

Expand[2 ( c +  d) + 3]

The point ({c + d},{3 + 2c + 2d}) is on the line 
"y = 2x + 3".  The Mathematica command (Expand) 
multiplies polynomials.

To list 11 points on the line use the command (Table).

Clear[m]
m=2
Table[{x,N[f[x]]},{x,-5,5}]

This is sloppy programming, even though it showed the correct answers.  A less sloppy program would clear all the variables, and write the function again something like this.

Clear[b,f,m,x,y]
f[x_] = m x + b
m=2;
b=3;
Table[{x,N[f[x]]},{x,-5,5}]

The last time I used the slope "m", I used -2.  I cleared "m" to use my original equation y = mx + b, where m = 2 and b = 3.  Remember to press the enter key to perform the program.

Now let's find an approximation of the ordinate when the abscissa is an irrational number.  The command "N" will do this for us.  If x is 2`, what is y?  In other words, if a point on the line y = 2x + 3 has an abscissa of 2`, what is the ordinate?

N[2 Pi + 3,6]

N[2 Pi]

The point (6.28319,9.28319) is on the line.

Substitute in the function f(x)= mx + b or in the equation y = mx + b, m=2, x=2`, b=3 and calculate y.  In Mathematica the "6" tells the computer to give the anwser in 6 digits and ` is Pi.  Remember to capitalize Pi.

Now let's plot some points.  To write the program again, you don't have to type it all in, you can use the copy and paste buttons.  With the mouse, highlight the cell by pushing the mouse button and then push the copy button.  Move the cursor to the position you want and push the paste button.  Delete the Plot command and add the ListPlot command.

Clear[b,m,x,f]
f[x_] = m x + b
m=2;
b=3;
points = Table[N[f[x]],{x,-5,5}];
ListPlot[points,AspectRatio->Automatic,
AxesLabel->{"x","y"}]

The points are a little small, so we will use the Plotstyle and PointSize commands to make them visible.

Clear[b,m,x,f]
f[x_] = m x + b
m=2;
b=3;
points=Table[N[f[x]],{x,-5,5}]
ListPlot[points, PlotStyle->PointSize[.2],AspectRatio->Automatic,
AxesLabel->{"x","y"}]

Nice points!  Of course, these are a little large, but I thought you might like to see them.  We will change the pointsize from .2 to .02.

Clear[b,m,x,f]
f[x_] = m x + b
m=2;
b=3;
points=Table[N[f[x]],{x,-5,5}]
ListPlot[points, PlotStyle->PointSize[.02],AspectRatio->Automatic,
AxesLabel->{"x","y"}]

Better.

Mathematica will help explain mistakes in the formatting of your program.  After pushing enter, if there is a beep, move the mouse to the open apple at the top.  
With the mouse, darken in the "Why the beep", and an explaination appears; something like this.

Clear[b,m,x,f]
f[x} = m x + b
m=2;
b=3;
Solve[f[x] == 0,x]

The mistake is the "}" in the second step.  The beep will say Mathematica could not understand the expression you tried to evaluate.  It left the insertion bar where it got confused.  The insertion bar will be before the "=" in the second command.  Sometimes the computer will be even more presice in its explaination; something like this.

8/0

Mathematica printed that you can't divide by 0!!

Let's use two points to find the equation of a line in the slope-intercept form.  Select  (4,11),(5,13).  The slope m is the change in y divided by the change in x:  (13-11)/(5-4).

(13-11)/(5-4)

The slope-intercept form of the line: y = mx + b.  We found the slope 2.  Either given point is on the line, so it will satisfy the equation of the line.  To find b, the y-intercept, we can substitute either point in for x and y and solve for b.  11 = 2(4) + b.

11-2(4)

Now we have the equation y = mx + b:  y = 2x + 3

Clear[b,m,x,f]
f[x_] = InterpolatingPolynomial [{{4,11},{5,13}},x]

Mathematica used the command "InterpolatingPolynomial" to find what y equals.  y = 2x + 3.

Another important concept in slopes is lines with slopes whose product is -1.  Graph the lines 
y = 2x + 3 and y = -(1/2)x + 3.

Clear[f,g,x]
f[x_]=2 x + 3;
g[x_]=(-1/2) x + 3;
Plot[{f[x],g[x]},{x,-5,5}, AspectRatio->Automatic];

These lines are perpendicular.  Try some more examples.

This project explains slopes of lines, Macintosh procedures, and Mathematica commands.