Limits, continuity, and derivatives
sm121_deriv1.mws
NOTE on the syntax: As you'll see almost all commands must end in either a ":" (to suppress output) or a ";" and almost always an "=" sign is preceeded by a ":".
EXAMPLE 1: Let's begin by examining the function sin(x)/x. It's plot (NOT drawn to scale) is as follows.
> plot(sin(x)/x,x=-10*Pi..10*Pi,y=-1..1);
![[Maple Plot]](images_sm121_deriv/sm121_deriv11.gif)
Nearer to x=0, the (correctly scaled) plot looks like to following.
> plot(sin(x)/x,x=-Pi/10..Pi/10,y=-1.1..1.1,scaling=CONSTRAINED);
![[Maple Plot]](images_sm121_deriv/sm121_deriv12.gif)
A table of values of sin(x)/x is easily computed as well.
> print(`x`.` `.`sin(x)/x`);
for i from -10 to 10 do
if i<>0 then print(evalf(i/100),evalf(sin(i/100)/(i/100)));
else print(`undefined at x=0`);
fi;
od;
![]()
We define f(x) (in MAPLE's "arrow" notation ->) to be sin(x)/x as follows.
> f:=x->sin(x)/x;
![]()
> Limit(f(x), x=0);
limit(f(x), x=0);
![]()
To test if sin(x)/x is continuous, we must make MAPLE load some commands in the package of programs called "iscont" as follows.
> readlib(iscont):
> iscont(f(x), x=-5..5 );
![]()
To compute the derivative type the diff command as follows.
> diff(f(x),x);
![[Maple Math]](images_sm121_deriv/sm121_deriv129.gif)
To us, this is a function of x but not to MAPLE. To get a function of x which is the derivative of f(x), the easiest is to use the following command.
> Df := unapply(diff(f(x),x),x);
![[Maple Math]](images_sm121_deriv/sm121_deriv130.gif)
> Limit(Df(x), x=0);
limit(Df(x), x=0);
![]()
> iscont(Df(x), x=-5..5 );
![]()
> plot1 := plot({f(x),Df(x)},x=-10..10):
plot2 := plots[textplot]({[1.2,-0.5,`y=D(sin
x/x)`],[3,0.5,`y=sin x/x`]},align = RIGHT):
> plots[display]({plot1,plot2});
![[Maple Plot]](images_sm121_deriv/sm121_deriv134.gif)
EXERCISE for Example 1(optional): Do all the same commands but replace sin(x)/x by (1-cos(x))/x^2.
EXAMPLE 2: Let's do some of the same things as we did above but for the simpler function sin(x). Since sin(x) is a predefined symbol in MAPLE, to set f(x)=sin(x) we don't have to use the arrow notation if we don't want to. The following command is shorter.
> f:=sin;
![]()
> Df := unapply(diff(f(x),x),x);
![]()
> plot1 := plot({f(x),Df(x)},x=-1..5):
plot2 := plots[textplot]({[.2,1.1,`y=D(sin
x)`],[3,0.5,`y=sin x`]},align = RIGHT):
> plots[display]({plot1,plot2});
![[Maple Plot]](images_sm121_deriv/sm121_deriv137.gif)
> plots[display]({plot1,plot2},scaling=CONSTRAINED);
![[Maple Plot]](images_sm121_deriv/sm121_deriv138.gif)
EXERCISE for Example 2(optional): Do all the same commands but replace sin(x) by cos(x).
EXAMPLE 3: The next example below illustrates the idea of a cusp.
> f:=x->1+((x^2)^(1/3)/(1+x^2)^(1/3));
![[Maple Math]](images_sm121_deriv/sm121_deriv139.gif)
> plot(f(x),x=-5..5,y=0..2,scaling=CONSTRAINED);
![[Maple Plot]](images_sm121_deriv/sm121_deriv140.gif)
> Df := unapply(diff(f(x),x),x);
![[Maple Math]](images_sm121_deriv/sm121_deriv141.gif)
> Limit(Df(x), x=0,right);
limit(Df(x), x=0,right);
Limit(Df(x), x=0,left);
limit(Df(x), x=0,left);
![]()
> plot1 := plot({f(x),Df(x)},x=-5..5,thickness=3):
plot2 := plots[textplot]({[2.1,-1.2,`y=D(f(x))`],[1.8,2.5,`y=f(x)`]},align
= RIGHT):
> plots[display]({plot1,plot2});
![[Maple Plot]](images_sm121_deriv/sm121_deriv146.gif)
EXAMPLE 4: Let's do some of the same things as we did above but for the following piecewise-defined function f(x).
> f:=x->piecewise(x<0,x^2,x<Pi,sin(x),x-Pi);
plot(f(x),x=-1..5);
![[Maple Plot]](images_sm121_deriv/sm121_deriv148.gif)
> Df := unapply(diff(f(x),x),x);
![]()
> Limit(f(x), x=Pi);
limit(f(x), x=Pi);
![]()
> Limit(Df(x), x=Pi, right);
limit(Df(x), x=Pi, right);
Limit(Df(x), x=Pi, left);
limit(Df(x), x=Pi, left);
![]()
Is this function f(x) continuous on the interval -1 < x < 5?
> iscont(f(x), x=-1..5 );
![]()
> iscont(Df(x), x=-1..1 );
![]()
> iscont(Df(x), x=1..3 );
![]()
> iscont(Df(x), x=3..5);
![]()
> plot1 := plot({f(x),Df(x)},x=-1..5,thickness=3):
plot2 := plots[textplot]({[2.1,-1.2,`y=D(f(x))`],[1.8,1.3,`y=f(x)`]},align
= RIGHT):
> plots[display]({plot1,plot2});
![[Maple Plot]](images_sm121_deriv/sm121_deriv160.gif)
EXERCISE for Example 4(optional): Do all the same commands but replace
f:=x->piecewise(x<0,x^2,x<Pi,sin(x),x-Pi);
by the "on-off" function
f:=x->Heaviside(x)-Heaviside(x-1)+Heaviside(x-2)-Heaviside(x-3);
(In MAPLE, the unit step function u(x) is denoted Heaviside(x).)
EXAMPLE 5: MAPLE knows the product rule for differentiation.
> diff(F(x)*G(x),x);
![]()
> S:=p->(1-p+p^2)*sin(p+1):
S(p);
![]()
> diff(S(p),p);
DS:=unapply(diff(S(p),p),p);
S(.75);
DS(.75);
![]()
EXERCISE for Example 5(optional): Do all the same commands but replace p by t and S(p) by
s:=t->sin(t)*exp(t);
EXAMPLE 6: MAPLE knows the quotient rule for differentiation.
> diff(F(x)/G(x),x);
simplify(diff(F(x)/G(x),x));
![[Maple Math]](images_sm121_deriv/sm121_deriv168.gif)
> h:=x->(x+1)/(x^3+x^2+1000*x-3001);
![[Maple Math]](images_sm121_deriv/sm121_deriv169.gif)
> diff(h(x),x);
![[Maple Math]](images_sm121_deriv/sm121_deriv170.gif)
EXERCISE for Example 6(optional): Do all the same commands but replace h(x) by
j:=x->sin(t)/(t^2+1);
EXAMPLE 7: MAPLE knows the chain rule for differentiation.
> diff(F(G(x)),x);
![]()
> k:=t->exp(t^3+1999*t);
![]()
> diff(k(t),t);
![]()
EXERCISE for Example 7(optional): Do all the same commands but replace k(t) by
k:=t->sin(t^2+1);