L15-graphing1.mws

Calculus I

Lesson 15: Analysing the Graphs of Functions 1 -
Direction and Concavity

We graph each of the following functions and find:

- all critical points

- where the function is increasing and where it is decreasing

- where the function is concave down and where it is concave up

- all points of inflection

Example 1
g(x) = x^3-2*x^2+x+3

> restart: with(plots):

Warning, the name changecoords has been redefined

> g1:= x -> x^3 - 2*x^2 + x + 3;

g1 := proc (x) options operator, arrow; x^3-2*x^2+x...

> D(g1);

proc (x) options operator, arrow; 3*x^2-4*x+1 end p...

> factor(3*x^2 - 4*x + 1);

(3*x-1)*(x-1)

Thus we have critical points when 3*x-1 = 0 or x -1 = 0, i.e.,

critical points are: x = 1/3 and x = 1.

> a1:= plot(D(g1)(x), x = -1..2, color= black):

> b1:= plot([1/3,t,t = -1..2], color = red):

> c1:= plot([1,t,t = -1..2], color = red):

> d1:= textplot([.5,7,`g1'(x)`], color = blue):

> e1:= textplot([.27,4,`x = 1/3`], color = magenta, align = RIGHT):

> f1:= textplot([1.2,3,`x = 1`], color = magenta):

> display({a1,b1,c1,d1,e1,f1});

[Maple Plot]

From the graph we see that :

g1' (x) > 0 for x < 1/3 or 1 < x

g1' (x) < 0 for 1/3 < x < 1.

Thus g1 is increasing for x < 1/3 and for x > 1 and g1 is decreasing for 1/3 < x < 1.

Conclude (from first derivative test) that g1 has a local max when x = 1/3 and a local max when x = 1.

> D(D(g1));

proc (x) options operator, arrow; 6*x-4 end proc

Thus, g1'' (x) = 6*x-4 = 2*(3*x-2) and therefore

g1'' (x) > 0 for x > 2/3

g1'' (x) < 0 for x < 2/3.

Hence, g1 is concave up for x > 2/3 and concave down for x < 2/3 . There is a point of inflection

when x = 2/3 .

> plot(g1(x), x = -5..5, color = blue);

[Maple Plot]

Here is a Maple program called shape_plot that summarizes a function's attributes graphically. It plots the function so that the differing colors and thickness of the graph indicate what properties each portion of the graph has.

Increasing Decreasing

Curve color and thickness Thick blue curve Thin red curve

Concave up Concave down

Color area shading Green shading upward Beige shading downward

> shape_plot := proc(f,a,b)
local box,i,n,x1,x2,xmid,delta,y1,y2,A,B, m,M,slope, concav:
n:= 100; delta := (b-a)/n; x2 := a;
M := maximize( f(x), x = a..b); m := minimize(f(x), x = a..b);
for i from 1 to n do
x1 := evalf(x2); y1 := evalf( f(x1));
x2 := evalf(a + i*delta); y2 := evalf( f(x2)); xmid := x1 + delta/2;
slope := evalf( subs( x = xmid, diff( f(x), x )));
concav := evalf( subs( x = xmid, diff( f(x),x $ 2)));
if( slope > 0 )
then A[i]:=plot( f(x), x = x1..x2, color = blue, thickness = 4 );
else A[i]:=plot( f(x), x = x1..x2, color = red, thickness = 2 );
fi;
if( concav > 0 ) then
B[i]:=polygonplot([[x1,M],[x1,y1],[x2,y2],[x2,M]],
color=green,style=patchnogrid);
else
B[i]:=polygonplot( [[x1,m],[x1,y1],[x2,y2],[x2,m]],
color=sienna,style=patchnogrid);
fi;
od;
display({ seq( A[i],i=1..n ),seq( B[i],i=1..n ) } );
end:

> shape_plot(g1,-5,5);

[Maple Plot]

Note that local maxima occur where the curve changes from blue to red, and local minima occur where the graph changes from red to blue. Inflection points occur where the shading changes from green to beige or vice-versa.

Example 2
g ( x ) = x sin (x), x in [0, 2
Pi ].

> g2:= x -> x * sin(x);

g2 := proc (x) options operator, arrow; x*sin(x) en...

> plot(x * sin(x), x =-1..7);

[Maple Plot]

From the plot it appears that we have one local max and two local min.

> D(g2);

proc (x) options operator, arrow; sin(x)+x*cos(x) e...

>

We need to find where g2' (x) = 0; it is defined for all x.

When x = 0, we have g2'(x) = 0 and hence 0 is one critical value.

Setting g2' (x) = 0, and dividing by cos(x) we obtain: tan(x) = -x.

We plot y = tan(x) and y = -x and look for intersections. We do three plots to avoid where

tan(x) is not defined.

> a2:= plot(tan(x), x = 0..Pi/2 - .1, color = black):

> b2:= plot(-x, x = 0..4, color = blue):

> bb2:= textplot([3,5,`PLOT 1`], color = magenta):

> display({a2,b2,bb2});

[Maple Plot]

>

> c2:= plot(tan(x), x = Pi/2 + .1..(1.5)*Pi - .1, color = black):

> d2:= plot(-x, x = 0..5, color = blue):

> dd2:= textplot([2,5,`PLOT 2`], color = magenta):

> display({c2,d2,dd2});

[Maple Plot]

>

> e2:= plot(tan(x), x = (1.5)*Pi + .1.. 2* Pi, color = black):

> f2:= plot(-x, x = 0..7, color = blue):

> ff2:= textplot([2,-6,`PLOT 3`], color = magenta):

> display({e2,f2,ff2});

[Maple Plot]

>

From Plot 1 we see that x = 0 is a critical pont. From Plots 2 and 3 we see that there

is precisely one critical point in ( Pi /2, 3 Pi /2), call it c1, and precisely one critical

point in (3 Pi /2, 2 Pi ), call it c2. Lets get numerical estimates for c1 and c2.

> fsolve(tan(x) = -x, x = Pi/2.. 3*Pi/2);

2.028757838

> fsolve(tan(x) = -x, x = 3*Pi/2.. 2*Pi);

4.913180439

Hence there are three critical points: x = 0, x = c1 ~ 2.028757838 , and x = c2 ~ 4.913180439 .

We have that g2' (x) > 0 iff sin(x) > -x cos(x) iff (recall where cos(x) > 0)

tan(x) > -x for x in [0, Pi /2) OR x in (3 Pi /2, 2 Pi ] (recall where cos(x) > 0.)

OR

tan(x) < -x for x in ( Pi /2, 3 Pi /2).

(Recall where cos(x) > 0.)

From plots 1,2,3 we see that g2' (x) > 0 iff x is in (0, Pi /2), (c2, 2 Pi ), ( Pi /2,c1).

Hence, g2 is increasing iff x is in (0, Pi /2), (c2, 2 Pi ), ( Pi /2,c1).

Thus, g2 has a local min when x = 0, c2 and a local max when x = c1.

We now turn to concavity.

> D(D(g2));

proc (x) options operator, arrow; 2*cos(x)-x*sin(x)...

Thus g2'' (x) > 0 iff 2 cos(x) > x sin(x) iff (recall where sin(x) > 0)

2 cot(x) > x and x in (0, Pi ) OR

2 cot(x) < x and x in ( Pi ,2 Pi ).

Again, we plot y = cot(x) and y = x.

,

> h2:= plot(cot(x), x = 0.1..Pi-.1, color = black):

> i2:= plot(x/2, x = 0..4, color = blue):

> j2:= textplot([1,6,`PLOT 1`], color = magenta):

> display({h2,i2,j2});

[Maple Plot]

> k2:= plot(cot(x), x = Pi + .1 .. 2*Pi - .1, color = black):

> l2:= plot(x/2, x = 3..7, color = blue):

> m2:= textplot([4,8,`PLOT 2`], color = magenta):

> display({k2,l2,m2});

[Maple Plot]

Let e1 denote the unique point in ( 0, Pi ) where 2 cot(x) = x and let

e2 denote the unique point in ( Pi , 2 Pi ) where 2 cot(x) = x.

Thus, g2''(x) > 0 iff x is in (0, e1) OR (e2, 2 Pi ).

Hence g2 is concave up iff x is in (0, e1) OR (e2, 2 Pi ).

Both x = e1, e2 lead to points of inflection.

Lets get numerical estimates for e1,e2.

> fsolve(D(D(g2))(x) = 0, x, 0.1.. Pi - .1);

1.076873986

> fsolve(D(D(g2))(x) = 0, x, Pi + .1.. 2 * Pi - .1);

3.643597167

Thus, e1 ~ 1.076873986 and e2 ~ 3.643597167 .

> shape_plot(g2,-1,7);

[Maple Plot]

Example 3
g(x) = (3+x^2)/(x^2)

First note that we cannot use x = 0.

The limit of g(x) as x goes to positive (or negative) infinity is 1 and hence

we have a horizontal asymptote: y = 1.

> g3:= x -> (3 + x^2) / ( x^2);

g3 := proc (x) options operator, arrow; (3+x^2)/(x^...

Lets plot to see what the graph looks like.

> plot(g3(x), x = 1..4, color = black);

[Maple Plot]

> plot(g3(x), x = -4..-1, color = black);

[Maple Plot]

From the plot we conjecture there are no extrema, the function is increasing

for x <0 and decreasing for x > 0, concave up on ( - infinity , 0) and (0, infinity ).

No points of inflection. .

> D(g3);

proc (x) options operator, arrow; 2*1/x-2*(3+x^2)/(...

> simplify( 2 /x - 2*(3 + x^2)/(x^3));

-6*1/(x^3)

Thus, g3' (x) = -6/(x^3) and hence 0 is the only critical point.

Also, g3''(x) = 18/(x^4) , which is positive for x NOT 0.

Hence our conjecture is correct.

> shape_plot(g3,-4,-1);

[Maple Plot]

Example 4
g(x) = 2*x*(x-4)^(1/3)

> g4:= x -> surd(x-4,3) * 2 * x;

g4 := proc (x) options operator, arrow; 2*surd(x-4,...

> plot(g4(x), x = -5..7);

[Maple Plot]

From the plot is appears there is one minimum and no maximum.

> D(g4);

proc (x) options operator, arrow; 2/3*surd(x-4,3)*x...

> simplify( (2/3) * (surd(x-4,3)*x)/(x-4) + 2 * surd(x-4,3));

8/3*surd(x-4,3)*(x-3)/(x-4)

From the above we see there are two critical points; namely when x = 4 and x = 3.

Further simplification gives that

g4' (x) = 8/3*(x-3)/((x-4)^(2/3))

As the denominator is always positive (where defined), we have that

g4'(x) > 0 iff x > 3. Thus g4 is increasing iff x > 3.

Hence, g4 has a local minimum when x = 3.

We need to determine concavity.

> D(D(g4));

proc (x) options operator, arrow; -4/9*surd(x-4,3)*...

> simplify( -4/9*surd(x-4,3)*x/((x-4)^2)+4/3*surd(x-4,3)/(x-4));

8/9*surd(x-4,3)*(x-6)/((x-4)^2)

Thus, g4''(x) = 8/9*surd(x-4,3)*(x-6)/((x-4)^2) . We conclude that

g4''(x) > 0 iff x < 4 or x > 6.

Thus, g4 is concave up on (- infinity , 4) and (6, infinity ) and is concave down on

(4,6). Thus we obtain points of inflection when x = 4,6.

Can we better see the change in concavity when x = 6?

> plot(g4(x), x = 4..7, color = black);

[Maple Plot]

> shape_plot(g4,4,7);

[Maple Plot]