Some graph investigations

some programming

Clear[label]
Clear[offset]
offset[x_]   =  {-1.5, 0}
Needs["Graphics`Colors`"];
$TextStyle = {FontFamily -> "Times", 
        FontSize -> 14}
niceGraphtext[points_,  f_,  {x_,  a_,  b_},  options___]  :=  
      Module[{points1,  points2,  text1,  
          graph}, 
points1  =   Point /@  
            points; 

points2  =   Prepend[  points1, Red]; 
points2 =  
          Graphics[
            Prepend[points2,  
              PointSize[ .02]]]; 
text1  =  
          Graphics[ ({Red,  
                    Text[label[#],  #, 
                      offset[#]]})  & /@   points]; 
graph  =   Plot[f,  {x,  a,  b},  
            DisplayFunction ->  Identity, 
            options]; 

Show[points2,  
          graph,  text1,  Axes  ->  True, 
 
          DisplayFunction  ->  $DisplayFunction]


]

niceGraph[points_,  f_,  {x_,  a_,  b_},  options___]  :=  
      Module[{points1,  points2,  text1,  
          graph}, 
points1  =   Point /@  
            points; 

points2  =   Prepend[  points1, Red]; 
points2 =  
          Graphics[
            Prepend[points2,  
              PointSize[ .02]]]; 
text1  =  
          Graphics[ (Text[
                    ToString[#],  #,  {-1, 
                      0}])  & /@   points]; 
graph  =   Plot[f,  {x,  a,  b},  DisplayFunction ->  Identity, 
            options]; 

Show[points2,  
          graph,  Axes  ->  True, 
 
          DisplayFunction  ->  $DisplayFunction]


]

Investigating the graph of 
f[x] = 3 (x^3) - 10 (x^2) + 2 x + 5

\(\(\(
\)\(Clear[
      f]


    f[x_] := \(\(3\ x\^3\)\(-\)\(10\ x\^2\)\(+\)\(2\ x\)\(+\)\(5\)\(
\)\)\)\)\)

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

Let's find the local maximum and minimum points, using the strategy of computing the derivative and finding the solutions to 
f'[x] = 0

f'[x]

Solve for f'[x] = 0.  (Of course, we could use quadratic formula).

soln = Solve[f'[x]  == 0,  
        x]

Give names a and b to the solutions (and get them in decimal form).

{a, b} = N[
        x /. soln ]

Calculate f[a] and f[b].

f[a]
f[b]

Now we know the x - range in which the "interesting" things happen on the graph of y = f[x].  All the interesting things happen in the range from x = -1 to x = 4.  Furthermore the local maximum and minimum are at
x = 0.104957, respectively x = 2.11727.

Plot[f[x],  {x,  -1,  4}]

With some somewhat elaborate programing, we can display the local maxima and minima on the graph.

Clear[offset]
offset[x_]   =  {-1.5, 0};
Clear[label]
p1  =  {a,  f[a]}
label[p1]  =  "p1"
p2  =  {b,  f[b]}
label[p2]  =  "p2"

points  =  {p1,  p2}
TableForm[points]
niceGraphtext[points,  f[x],  {x,  -1,  4}]

Locate the inflection point:

f''[x]
soln2  =  
        Solve[f''[x]  == 0,  x];
{c}  = N[ x /. soln2];
f[c];
p3  =  {c,  f[c]}
label[p3]  =  "p3"

We display the graph again with the inflection point labelled as well.

points  =  {p1,  p2,  p3};
TableForm[points]
niceGraphtext[points,  f[x],  {x,  -1,  4}]

Investigating the graph of f[x] = (x^2) (e^(-x))

Clear[f];
f[x_] := 
      (x^2) (E^(-x))

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

Plot[f[x],  {x,  -2,  10}]

Find the critical points:

f'[x]

    Solve[f'[x]  == 0,  x]

Clear[offset]
offset[x_]   =  {-1.5, 0};
p1  =  {0, 0}
label[p1]  =  "p1"';
p2  = N[ {2, f[2]}]
label[p2]  =  "p2";

Graph with the local maximum and minimum labelled:

Clear[points]
points  =  {p1,  p2};
TableForm[points]
niceGraphtext[points,  f[x],  {x,  -1,  10}]

Let's add second derivative information to our data:

Factor[f''[x]]

    inflect  =  Solve[f''[x]  ==  0,  x]

Name the two inflection points:

{a,  b}  =  x /. inflect

p3  =  N[{a,  f[a]}]
label[p3]  =  "p3";
p4  =  N[{b,  f[b]}]
label[p4]  =  "p4";

Graph with the two inflection points labelled;

points  =  {p1, p2, p3, 
          p4};

    TableForm[
      points]



    niceGraphtext[points,  f[x],  {x,  -1,  10}]

Investigating the graph of f[x] = ((5 (x^2) + 8 x - 3)/(3 (x^2) + 2))

Clear[f]
f[x_] := ((5 (x^2) + 8 x - 3)/(3 (x^2) + 2))

Plot[{f[x], 5/3} ,  {x,  -10,  10}]

Together[f'[x]]

criticalpoints  =  
      Solve[f'[x]  == 0,  x]
criticalpoints  =  N[criticalpoints]
{a,  b}  =  x /. criticalpoints;

Clear[offset]
offset[x_]   =  {-1.5, 0};
p1  =  {a, f[a]}
label[p1]  =  "p1";
p2  = {b,  f[b]}
label[p2]  =  "p2";
offset[p2]  =  {1.2,  0};

Graph with the local maximum labelled:

Clear[points]
points  =  {p1,  p2};
TableForm[points]
niceGraphtext[
      points,  {f[x],  5/3},  {x,  -10,  
        10}]

Let's add second derivative information to our data.  From the information we have so far, we suspect 3 inflection points.

Together[f''[x]]

To find the 3 inflection points, we have to solve the equation
 38 - 144 x - 171 (x^2) + 72 (x^3) = 0.
 We will discuss later how to do this; meanwhile, we let Mathematica do it.

inflect  =  NSolve[f''[x] == 0,  x]

{α,  β,  γ}  =  x/.inflect

p3  =  {α,  f[α]}
label[p3]  =  "p3";
offset[p3]  =  {-1,  1};
p4  =  {β,  f[β]}
label[p4]  =  "p4";
offset[p4]  =  {1.5, 0};
p5  =  {γ,  f[γ]}
label[p5]  =  "p5";

Clear[points]
points  =  {p1,  p2,  p3,  p4,  
          p5};
TableForm[points]
niceGraphtext[points,  {f[x],  5/3},  {x,  -10,  10},  
      PlotRange ->  {-4, 4}]

Investigating the graph of f[x] = (x/((x^2) - 4))

Clear[f]
f[x_]  =  (x/((x^2) - 4))

Analysis of asymptotes alone, together with the "oddness"  of the function, allow us to guiess the following graph.  You can obtain further confirmation by analyzing derivatives.
Note that we would guess that only one inflection point exists, at (0,0).
I invite you to check this.

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