Log and Log-Log Graphing

This notebook is a modification of Paul Wellin's EngineeringDemo.nb

Log Plotting is one of many advanced functions that reside in one of the many external packages that come with Mathematica. These packages may be loaded into Mathematica as their functionality is needed. Also provided is a style guide to use as you begin to write your own packages.

Setup

Load the Graphics package.  This is done using the Get comand, <<, in Mathematica.

<< Graphics`

Define the function to be graphed.  This is done in a similar format to the popular standards and traditional written formula criteria.  The name of the function in on the left-hand side of the equation. The variables of the function are represented with an underscore attached.  Everything to the right of the := defines the function.  For instance, defined below is a function f(x).

f[x_] := x^2  +  3

f is a function of x.  In order that Mathematica knows the definitions of f you evaluate the cell.  Now, if you evaluate this function at some value its value will be returned by Mathematica.

f[2]

You can define a function as a combination of Mathematica functions.  For instance,

eqn[x_] := Abs[(100/((((I x))^2) + 2 I x + 100))];

You can evaluate this function eqn[x_] across a collection of values and save it in a data variable using Mathematica's Table function.

data = Table[eqn[x], {x,  .1, 20,  .4}];

Log plot of a function

Take the data you collected and produce a visualization of this data using LogPlot.

?LogPlot

You also can add options to many Mathematica functions.  The current option settings for a particular function can be viewed by using the Options command.

Options[LogPlot]

Now create a log plot of this function, setting a few options for the graphic output.  Notice you assign the plot a name plot1 in order to refer to it later.

plot1 = 
        LogPlot[eqn[x], {x, 1, 20}, GridLines -> LogGridMinor, 
          PlotStyle -> Thickness[0.01]];

Log-log plot of a function

You can create a log-log plot of a function using LogLogPLot.

?LogLogPlot

plot2 = 
        LogLogPlot[eqn[x], {x, 1, 20}, 
          GridLines -> {Automatic, Automatic}, 
          PlotStyle -> Thickness[0.01]];

Log list plot of data

Mathematica also has a function LogListPlot that will produce a log list plot of the data.

?LogListPlot

plot3 = 
      LogListPlot[data, GridLines -> {Automatic, Automatic}, 
        PlotStyle -> PointSize[0.015]]

Log-log list plot of data

Log-log list plots of data can be produced using LogLogListPlot.

?LogLogListPlot

plot4 = 
      LogLogListPlot[data, GridLines -> {Automatic, Automatic}, 
        PlotStyle -> PointSize[0.015]]

Combining plots

You can combine all four plots into one graph using GraphicsArray and then applying the Show command.

?GraphicsArray

?Show

Show[GraphicsArray[{{plot1, plot2}, {plot3, plot4}}]]