First and second derivative tests
sm121_der_tests1.mws,7-99
> restart;
with(plots):
Plot y=x^2-7x+3 and use the first derivative test to determine where the graph is increasing and decreasing.
> f:=x->sin(x^2-7*x+3);
Df:=unapply(diff(f(x),x),x);
_EnvAllSolutions := true:
critpts:=solve(Df(x)=0,x);
indets(critpts[1]);#indets(critpts[1]) or
indets(critpts[2]),
#whichever one is _Z1~ (which is an internal
#MAPLE integer variable)
![]()
> z:=indets(critpts[1])[1];
![]()
> a:=plot(f(x),x=0..6):
b:=plot(Df(x),x=0..6,linestyle=2):
c1:=plot([subs({z=-3},critpts[1]),t,t=-6..6],color=green):
c2:=plot([subs({z=-3},critpts[2]),t,t=-6..6],color=green):
c3:=plot([critpts[3],t,t=-6..6],color=green):
c4:=plot([subs({z=-2},critpts[2]),t,t=-6..6],color=green):
c5:=plot([subs({z=-1},critpts[2]),t,t=-6..6],color=green):
c6:=plot([subs({z=0},critpts[2]),t,t=-6..6],color=green):
c7:=plot([subs({z=-2},critpts[1]),t,t=-6..6],color=green):
display([a,b,c1,c2,c3,c4,c5,c6,c7],title=`function
in solid, derivative in dotted`);
![[Maple Plot]](images_der_tests/sm121_der_tests16.gif)
One can use fsolve to determine exactly where the x-intercepts of the function are.
> x1:=fsolve(f(x)=0,x=1/2);
x2:=fsolve(f(x)=0,x=1);
x3:=fsolve(f(x)=0,x=2);
x4:=fsolve(f(x)=0,x=5);
x5:=fsolve(f(x)=0,x=6);
![]()
Plot y=(x^2-9)/(2x-4) and use the first derivative test to determine where the graph is increasing and decreasing.
> f:=x->(x^2-9)/(2*x-4);
Df:=unapply(diff(f(x),x),x);
DDf:=unapply(diff(Df(x),x),x);
![[Maple Math]](images_der_tests/sm121_der_tests114.gif)
Because of the singularity at x=2, the functions go off the graph near x=2.
> a:=plot(f(x),x=-1..5,y=-15..15):
b:=plot(Df(x),x=-1..5,y=-15..15,linestyle=2):
c:=plot(DDf(x),x=-1..5,y=-15..15,linestyle=3):
display([a,b,c],title=`function in solid,
1st deriv in dotted, 2nd deriv dashed`);
![[Maple Plot]](images_der_tests/sm121_der_tests115.gif)
Plot y=x(x-1)(x-2)(x-3)(x-4) and use the first derivative test to determine where the graph is increasing and decreasing.
> f:=x->x*(x-1)*(x-2)*(x-3)*(x-4);
Df:=unapply(diff(f(x),x),x);
DDf:=unapply(diff(Df(x),x),x);
![]()
> a:=plot(f(x),x=-1..5,y=-15..15):
b:=plot(Df(x),x=-1..5,y=-15..15,linestyle=2):
c:=plot(DDf(x),x=-1..5,y=-15..15,linestyle=3):
display([a,b,c],title=`function in solid,
1st deriv in dotted, 2nd deriv dashed`);
![[Maple Plot]](images_der_tests/sm121_der_tests122.gif)
>
> f:=x->(2*x^2+x-6)/(x^2+3*x+2);
Df:=unapply(diff(f(x),x),x);
DDf:=unapply(diff(Df(x),x),x);
![[Maple Math]](images_der_tests/sm121_der_tests125.gif)
>
Plot y=|x^2-6x+5| and use the first derivative test to determine where the graph is increasing and decreasing.
> f:=x->abs(x^2-6*x+5);
Df:=unapply(diff(f(x),x),x);
DDf:=unapply(diff(Df(x),x),x);
![]()
Though this function isn't even diffrentiable everywhere, MAPLE can still plot it's derivative!
> a:=plot(f(x),x=-2..7,y=-10..10):
b:=plot(Df(x),x=-2..7,y=-10..10,linestyle=2):
c:=plot(DDf(x),x=-2..7,y=-10..10,linestyle=3):
display([a,b,c],title=`function in solid,
1st deriv in dotted, 2nd deriv dashed`);
![[Maple Plot]](images_der_tests/sm121_der_tests129.gif)