Examples of plotting the graphs of functions for
 Math 1011 (Peh Ng)

We can define a function f(x) in the following way:

f[x_]:=x^2 -2

We then sketch the graph by using the command, Plot[ f[x], {x, xmin, xmax}]:

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

We can also superimpose multiple plots of different functions on the same coordinate system. In this example, we plot f(x)=x, g(x)=x^2, h(x)=x^3:

Plot[{x,x^2,x^3},{x,-1.5,1.5},PlotRange->{-2,1.6},
 PlotStyle->{{Dashing[{.02}]},{},{Thickness[.007],GrayLevel[.7]}}]

Another example:

Plot[{ 8^x, 5^x},{x,-1,0.5},PlotStyle->{Red,{Blue,Thick}}]

Other examples:

Needs["PlotLegends`"]

Plot[{ 8^x, 5^x},{x,-1,0.5},PlotStyle->{Red,{Blue,Thick}},PlotLegend->{"8^x", "5^x"}]

Plot[{ 8^x, 5^x},{x,-2,1},PlotRange->{-1,5},
 PlotStyle->{{Dashing[{.02}]},{Thickness[.007],GrayLevel[.7]}}]

Plot[{Exp[x], Exp[-x],4^x, 4^(-x)},{x,-3,3},PlotRange->{-2,10},
 PlotStyle->{{Dashing[{.02}]},{},{AbsoluteThickness[2],GrayLevel[0.7]},
{AbsoluteThickness[3]} }]

Plot[Evaluate[Table[2x+n, {n,5}]],{x,0,10}]

Plot[ {Sin[x], x-(x^3)/6,x-(x^3)/6+(x^5)/120, x-(x^3)/6+(x^5)/120 - (x^7)/7! },{x,-10,10},PlotRange->{-2,10},
 PlotStyle->{{Dashing[{.02}]},{Dashing[{.005}]},{},{AbsoluteThickness[2],GrayLevel[0.7]},
{AbsoluteThickness[3]} }]

Plot[ {Sin[x], {Sum[ ((-1)^n) (x^(2n+1))/Factorial[(2n+1)] , {n,1,100}] } },{x,-4,4},PlotRange->{-2,2},
 PlotStyle->{{Dashing[{.02}]},{AbsoluteThickness[2],GrayLevel[0.7]},
{AbsoluteThickness[3]} }]

Plot[ {2^x,1+(Log[2])*x, 1+(Log[2])*x + ((Log[2])^2)*(x^2)/2}, {x,-3,3}]