# Graphing lines with Mathematica

There are lots of bells and whistles available in Mathematica, but sometimes I like something really plain. For example, I wanted my students to find slope analytically given two points. On graph paper with a full grid, they could count the rise and run. I wanted them to understand that rise and run can also be found via subtraction. At the same time, I wanted to give them at least the big picture. The script may look complicated, but all you have to do is specify the two points in the first two lines, and the script manages the rest.

```p0 = {4, -3}; p1 = {-1, 2}; xMin = Min[p0[[1]], p1[[1]]]; xMax = Max[p0[[1]], p1[[1]]]; yMin = Min[p0[[2]], p1[[2]]]; yMax = Max[p0[[2]], p1[[2]]]; points = List[p0, p1]; SetOptions[ListPlot, BaseStyle -> {FontFamily -> "Times", FontSize -> 14, FontSlant -> "Italic"}]; pointsPlot = ListPlot[points, PlotRange -> {{xMin - 1, xMax + 1}, {yMin - 1, yMax + 1}}, AspectRatio -> Automatic, Ticks -> None, AxesLabel -> {"x", "y"}, LabelStyle -> Directive[18], PlotStyle -> {Black, PointSize[0.02]}, AxesOrigin -> {0, 0}]; m = (p0[[2]] - p1[[2]])/(p0[[1]] - p1[[1]]); linePlot = Plot[m (x - p0[[1]]) + p0[[2]], {x, xMin - 1, xMax + 1}, PlotStyle -> {Black}]; Show[pointsPlot, linePlot]```