You are on page 1of 58

CALCULUS

Disclaimer: These notes have not been subjected to the usual scrutiny reserved for formal
publications. They may be distributed outside this class only with the permission of the
Instructor.

DIFFERENTIAL CALCULUS
LIMIT OF A FUNCTION

 𝐋𝐢𝐦𝐢𝐭[𝒇[𝒙], 𝒙 → 𝒂, 𝐃𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧 → 𝟏] computes the left hand limit of the function 𝑓(𝑥) at
the point 𝑥 = 𝑎 i.e. the value of lim𝑥→𝑎− 𝑓(𝑥) will be computed.
Examples:
i) Limit[(𝑥^5 − 32)⁄(𝑥^3 − 8) , 𝑥 → 2, Direction → 1]
20
Ans: .
3
ii) 𝑓[x_]: = 1⁄𝑥
Limit[𝑓[𝑥], 𝑥 → 0, Direction → 1]
Ans: −∞.

 𝐋𝐢𝐦𝐢𝐭[𝒇[𝒙], 𝒙 → 𝒂, 𝐃𝐢𝐫𝐞𝐜𝐭𝐢𝐨𝐧 → −𝟏] computes the right hand limit of the function 𝑓(𝑥)
at the point 𝑥 = 𝑎 i.e. the value of lim𝑥→𝑎+ 𝑓(𝑥) will be computed.
Examples:
i) Limit[(𝑥 5 − 32)⁄(𝑥 3 − 8) , 𝑥 → 2, Direction → −1]
20
Ans: .
3
ii) 𝑓[x_]: = 1⁄𝑥
Limit[𝑓[𝑥], 𝑥 → 0, Direction → −1]
Ans: +∞.

 𝐋𝐢𝐦𝐢𝐭[𝒇[𝒙], 𝒙 → 𝒂] computes the limit of the function 𝑓(𝑥) at the point 𝑥 = 𝑎 i.e. the
value of lim𝑥→𝑎 𝑓(𝑥) will be computed.
Examples:
i) Limit[(𝑥^5 − 32)⁄(𝑥^3 − 8) , 𝑥 → 2]
20
Ans: .
3
ii) 𝑓[x_]: = 1⁄𝑥
Limit[𝑓[𝑥], 𝑥 → 0]
Ans: ∞.

𝑥 5 −32
Problem-1: Suppose 𝑓(𝑥) = is a function.
𝑥 3 −8

i) Find the left hand limit of the function 𝑓(𝑥) at 𝑥 = 2 i.e. find lim𝑥→2− 𝑓(𝑥)
ii) Find the right hand limit of the function 𝑓(𝑥) at 𝑥 = 2 i.e. find lim𝑥→2+ 𝑓(𝑥)
iii) Test whether or not the limit of the function 𝑓(𝑥) at 𝑥 = 2 exist?
iv) Find the limit of the function 𝑓(𝑥) at 𝑥 = 2 i.e. find lim𝑥→2 𝑓(𝑥)

Solution:

𝑓[x_]: = (𝑥^5 − 32)⁄(𝑥^3 − 8) ;

i) lhl = Limit[𝑓[𝑥], 𝑥 → 2, Direction → 1]


20
Ans: .
3
ii) rhl = Limit[𝑓[𝑥], 𝑥 → 2, Direction → −1]
20
Ans: .
3
iii) If[lhl == rhl, Print["Limit Exist"], Print["Limit does not exist"]]
Ans: Limit Exist
iv) Limit[𝑓[𝑥], 𝑥 → 2]
20
Ans: .
3

1
Problem-2: Suppose 𝑓(𝑥) = 𝑥 is a function.

i) Find the left hand limit of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find lim𝑥→0− 𝑓(𝑥)
ii) Find the right hand limit of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find lim𝑥→0+ 𝑓(𝑥)
iii) Test whether or not the limit of the function 𝑓(𝑥) at 𝑥 = 0 exist?
iv) Find the limit of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find lim𝑥→0 𝑓(𝑥)

Solution:

1
𝑓[x_]: = ;
𝑥
v) lhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → 1]
Ans: −∞ .
vi) rhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → −1]
Ans: ∞ .
vii) If[lhl == rhl, Print["Limit Exist"], Print["Limit does not exist"]]
Ans: Limit does not exist
viii) Limit[𝑓[𝑥], 𝑥 → 0]
Ans: ∞ .

Problem-3: Using MATHEMATICA code, check whether or not limit of the function,
𝑥2
𝑓(𝑥) = (𝑥−1)(𝑥−2) at 𝑥 = 0 exist.

Solution:
2 Calculus with MATHEMATICA
f[x_]:=x^2/(x-1)(x-2);
lhl=Limit[f[x],x 0, Direction 1];
rhl=Limit[f[x],x 0, Direction -1];
If[lhl==rhl, Print["Limit Exist"], Print["Limit does not exist"]]

Ans: Limit Exist

Piecewise function in MATHEMATICA

 How do you write a piecewise function like


−3
3 + 2𝑥; ≤𝑥<0
2
3
𝑓(𝑥) = 3 − 2𝑥; 0 ≤ 𝑥 < 2 in MATHEMATICA (without using Palettes)?
3
{ −3 − 2𝑥; 𝑥≥2

Method-1:
𝑓[x_] ≔ Piecewise[{{3 + 2𝑥, −3⁄2 ≤ 𝑥 < 0}, {3 − 2𝑥, 0 ≤ 𝑥 < 3⁄2},
{−3 − 2𝑥, 𝑥 ≥ 3⁄2}}]
Method-2 (From Keyboard):

𝑓[x_ ] ≔ (𝑃𝑟𝑒𝑠𝑠)𝐸𝑠𝑐 + (𝑤𝑟𝑖𝑡𝑒) 𝑝𝑤 + (𝑃𝑟𝑒𝑠𝑠)𝐸𝑠𝑐


will create 𝑓[x_ ] ≔ {
Then Ctrl+Enter will create

Again, Ctrl+Enter will provide

Then after putting different pieces of the function with


respect to the conditions provided,𝑓(𝑥) will take the form:

3 Calculus with MATHEMATICA


CONTINUOUS FUNCTION
−3
3 + 2𝑥; ≤𝑥<0
2
3
Problem-1: Suppose 𝑓(𝑥) = 3 − 2𝑥; 0 ≤ 𝑥 < 2 is a function.
3
{ −3 − 2𝑥; 𝑥≥2

i) Find the left hand limit of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find lim𝑥→0− 𝑓(𝑥)
ii) Find the right hand limit of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find lim𝑥→0+ 𝑓(𝑥)
iii) Test whether or not the limit of the function 𝑓(𝑥) at 𝑥 = 0 exist?
iv) Find the value of the function 𝑓(𝑥) at 𝑥 = 0 i.e. find 𝑓(0)
v) Check the continuity of the function 𝑓(𝑥) at 𝑥 = 0
vi) Find the left hand limit of the function 𝑓(𝑥) at 𝑥 = 3/2 i.e. find lim𝑥→3/2− 𝑓(𝑥)
vii) Find the right hand limit of the function 𝑓(𝑥) at 𝑥 = 3/2 i.e. find lim𝑥→3/2+ 𝑓(𝑥)
viii) Test whether or not the limit of the function 𝑓(𝑥) at 𝑥 = 3/2 exist?
ix) Find the value of the function 𝑓(𝑥) at 𝑥 = 3/2 i.e. find 𝑓(3/2)
x) Check the continuity of the function 𝑓(𝑥) at 𝑥 = 3/2
xi) Sketch the graph of the function 𝑓(𝑥)

Solution:

𝑓[x_]: = Piecewise[{{3 + 2𝑥, −3⁄2 ≤ 𝑥 < 0}, {3 − 2𝑥, 0 ≤ 𝑥 < 3⁄2}, {−3 − 2𝑥, 𝑥
≥ 3⁄2}}]

i) lhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → 1]


Ans: 3
ii) rhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → −1]
Ans: 3
iii) If[lhl == rhl, Print["Limit exist at x = 0"], Print["Limit does not exist at x = 0"]]
Ans: Limit exist at x = 0
iv) fv = 𝑓[0]
Ans: 3
v) If[lhl == rhl == fv, Print["f(x) is continuous at x =
0"], Print["f(x) is not continuous at x = 0"]]
Ans: f(x) is continuous at x = 0
vi) lhl = Limit[𝑓[𝑥], 𝑥 → 3⁄2 , Direction → 1]
Ans: 0
vii) rhl = Limit[𝑓[𝑥], 𝑥 → 3⁄2 , Direction → −1]
Ans: −6

4 Calculus with MATHEMATICA


viii) If[lhl == rhl, Print["Limit exist at x = 3/2"], Print["Limit does not exist at x =
3/2"]]
3
Ans: Limit does not exist at x = 2
ix) fv = 𝑓[3⁄2]
Ans: −6
x) If[lhl==rhl==fv,Print["f(x) is continuous at
x=3/2"],Print["f(x) is not continuous at x=3/2"] ]
Ans: f(x) is not continuous at x=3/2
xi) Plot[f[x],{x,-5,5}]

4 2 2 4

10

1; 𝑥 < 0
𝜋
1 + sin 𝑥 ; 0 ≤ 𝑥 < 2
Problem-2: Suppose 𝑓(𝑥) = is a function.
𝜋 2 𝜋
{2 + (𝑥 − 2 ) ; 𝑥≥ 2

𝜋
i) Discuss the continuity of the function 𝑓(𝑥)at 𝑥 = 0 and 𝑥 = 2 .
ii) Sketch the graph of the function .

Solution:

ClearAll[𝑓]

i)

Continuity at 𝒙 = 𝟎:

5 Calculus with MATHEMATICA


lhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → 1];

rhl = Limit[𝑓[𝑥], 𝑥 → 0, Direction → −1];

fv = 𝑓[0];

If[lhl == rhl == fv, Print["f is continuous at x = 0"], Print["f is not continuous at x = 0"]]

Ans: f is continuous at x = 0.
𝝅
Continuity at 𝒙 = 𝟐 :

lhl = Limit[𝑓[𝑥], 𝑥 → Pi⁄2 , Direction → 1];

rhl = Limit[𝑓[𝑥], 𝑥 → Pi⁄2 , Direction → −1];

fv = 𝑓[Pi⁄2];

If[lhl == rhl == fv, Print["f is continuous at x = π/2"], Print["f is not continuous at x


= π/2"]]

Ans: f is continuous at x = π/2

ii) Plot[𝑓[𝑥], {𝑥, −10,10}]


50

40

30

20

10

10 5 5 10

5𝑥 − 4; 0 < 𝑥 ≤ 1
Problem-3: Suppose 𝑓(𝑥) = {4𝑥 2 − 3𝑥; 1 < 𝑥 < 2is a function.
3𝑥 + 4; 𝑥 ≥ 2

i) Discuss the continuity of the function 𝑓(𝑥)at 𝑥 = 1 and 𝑥 = 2


ii) Sketch the graph of the function .

6 Calculus with MATHEMATICA


Solution:

i)

Continuity at 𝒙 = 𝟏:

Clear All[f];
f[x_]:= Piecewise[{{5*x-4,0<x 1},{4*x^2-
3*x,1<x<2},{3*x+4,x 2}}];
lhl=Limit[f[x],x 1,Direction 1]
rhl=Limit[f[x],x 1,Direction -1]
fv=f[1]
If[lhl==rhl==fv,Print["f(x) is continuous at x=1"],Print["f(x) is not
continuous at x=1"] ]

Output: f(x) is continuous at x=1

Continuity at 𝒙 = 𝟐:

Clear All[f];
f[x_]:= Piecewise[{{5*x-4,0<x 1},{4*x^2-
3*x,1<x<2},{3*x+4,x 2}}];
lhl=Limit[f[x],x 2,Direction 1]
rhl=Limit[f[x],x 2,Direction -1]
fv=f[2]
If[lhl==rhl==fv,Print["f(x) is continuous at x=2"],Print["f(x) is not
continuous at x=2"] ]

Output: f(x) is continuous at x = 2

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

Output:

15

10

4 2 2 4

7 Calculus with MATHEMATICA


Problem-4: Check the continuity of the function, 𝑓(𝑥) = |𝑥| + |𝑥 − 1| at 𝑥 = 0 . Draw the
graph of the function, also.

Solution:

Part-1:

ClearAll[f]
f[x_]:=Abs[x]+Abs[x-1];
lhl=Limit[f[x],x 0,Direction 1]
rhl=Limit[f[x],x 0,Direction -1]
fv=f[0]
If[lhl==rhl==fv,Print["f(x) is continuous at
x=0"],Print["f(x) is not continuous at x=0"] ]

Output: f(x) is continuous at x=0

Part-2:

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

Output:

20

15

10

10 5 5 10

8 Calculus with MATHEMATICA


|𝑥|
Problem-5: Check the continuity of the function, 𝑓(𝑥) = , 𝑥 ≠ 0, 𝑓(0) = 1 at 𝑥 = 0. Draw
𝑥
the graph of the function, also.

Solution:

Part-1:

ClearAll[f]
f[x_]:=Abs[x]/x;
lhl=Limit[f[x],x 0,Direction 1]
rhl=Limit[f[x],x 0,Direction -1]
fv=1;
If[lhl==rhl==fv,Print["f(x) is continuous at
x=0"],Print["f(x) is not continuous at x=0"] ]

Output: f(x) is not continuous at x=0

Part-2:

Plot[𝑓[𝑥], {𝑥, −12,12}]

Output:
1.0

0.5

10 5 5 10

0.5

1.0

DIFFERENTIABLE FUNCTION

5𝑥 − 4; 0 < 𝑥 ≤ 1
Problem-1: Suppose 𝑓(𝑥) = {4𝑥 2 − 3𝑥; 1 < 𝑥 < 2 is a function.
3𝑥 + 4; 𝑥 ≥ 2

9 Calculus with MATHEMATICA


Discuss the differentiability of the function 𝑓(𝑥) at 𝑥 = 1 and 𝑥 = 2.

Solution:

Differentiability at 𝒙 = 𝟏:

ClearAll[f]
f[x_]:=Piecewise[{{5*x-4,0<x 1},{4*x^2-
3*x,1<x<2},{3*x+4,x 2}}];
lhd=Limit[(f[x+h]-f[x])/h,h 0,Direction 1]/.x 1
rhd=Limit[(f[x+h]-f[x])/h,h 0,Direction -1]/.x 1
If[lhd==rhd,Print["f is differentiable at x=1"], Print["f is not
differentiable atx=1"]]

Output: f is differentiable at x=1

Differentiability at 𝒙 = 𝟐:

ClearAll[f]
f[x_]:=Piecewise[{{5*x-4,0<x 1},{4*x^2-
3*x,1<x<2},{3*x+4,x 2}}];
lhd=Limit[(f[x+h]-f[x])/h,h 0,Direction 1]/.x 2
rhd=Limit[(f[x+h]-f[x])/h,h 0,Direction -1]/.x 2
If[lhd==rhd,Print["f is differentiable at x=2"], Print["f is not
differentiable at x=2"]]

Output: f is not differentiable at x=2

−3
3 + 2𝑥; ≤𝑥<0
2
3
Problem-2: Suppose 𝑓(𝑥) = 3 − 2𝑥; 0 ≤ 𝑥 < 2 is a function. Discuss the differentiability of
3
{ −3 − 2𝑥; 𝑥≥2
the function 𝑓(𝑥) at 𝑥 = 0.

Solution:

Clear All[f];
f[x_]:= Piecewise[{{3+2*x,-3/2 x<0},{3-2 *x,0 x<3/2},{-3-
2 *x,x 3/2}}];
lhd=Limit[(f[x+h]-f[x])/h,h 0,Direction 1]/.x 0
rhd=Limit[(f[x+h]-f[x])/h,h 0,Direction -1]/.x 0
If[lhd==rhd,Print["f is differentiable at x=0"], Print["f
is not differentiable atx=0"]]

10 Calculus with MATHEMATICA


Output: f is not differentiable atx=0

DIFFERENTIATION OF A FUNCTION

 𝑫[𝒇[𝒙], 𝒙] returns the derivative of 𝑓 with respect to 𝑥.


Examples:
i) 𝐷[𝑥^5 + 𝑥^4 + 𝑥^3 + 𝑥^2 + 𝑥 + 1, 𝑥]
Output: 1 + 2𝑥 + 3𝑥2 + 4𝑥3 + 5𝑥4
ii) 𝐷[𝑥^5 + 𝑥^4 + 𝑥^3 + 𝑥^2 + 𝑥 + 1, 𝑥]//TraditionalForm
Output: 5𝑥4 + 4𝑥3 + 3𝑥2 + 2𝑥 + 1
iii) 𝐷[Sin[𝑥]^10, 𝑥]
Output: 10Cos[𝑥]Sin[𝑥]9
 𝑫[𝒇[𝒙], {𝒙, 𝒏}] returns the 𝑛th derivative of 𝑓 with respect to 𝑥.
Examples:
i) 𝐷[𝑥^5 + 𝑥^4 + 𝑥^3 + 𝑥^2 + 𝑥 + 1, {𝑥, 2}]
Output: 2 + 6𝑥 + 12𝑥2 + 20𝑥3
%//TraditionalForm
Output: 20𝑥3 + 12𝑥2 + 6𝑥 + 2
ii) 𝐷[𝑥^5 + 𝑥^4 + 𝑥^3 + 𝑥^2 + 𝑥 + 1, {𝑥, 3}]
Output: 6 + 24𝑥 + 60𝑥2
iii) 𝐷[Sin[𝑥]^10, {𝑥, 4}]
Output: 5040Cos[𝑥]4 Sin[𝑥]6 − 4680Cos[𝑥]2 Sin[𝑥]8 + 280Sin[𝑥]10

Note that D treats every symbol in an expression that does not explicitly depend on x
as a constant.

 Derivative[n][f][x] returns the 𝑛th derivative of 𝑓 with respect to 𝑥.


Examples:
i) f[x_]:=x^5+x^4+x^3+x^2+x+1;
Derivative[1][f][x]
Output: 1 + 2𝑥 + 3𝑥2 + 4𝑥3 + 5𝑥4
Derivative[2][f][x]
Output: 2 + 6𝑥 + 12𝑥2 + 20𝑥3

ii) f[x_]:=Sin[x]^10;
Derivative[4][f][x]
Output: 5040Cos[𝑥]4 Sin[𝑥]6 − 4680Cos[𝑥]2 Sin[𝑥]8 + 280Sin[𝑥]10

11 Calculus with MATHEMATICA


 The numerical value of a derivative at a specific point can be computed several different
ways, depending upon how the derivative is computed. The next example illustrates the
most common techniques.

Examples:
i) D[x^5 + x^4 + x^3 + x^2 + x + 1, {x, 3}]/. x → 1
Output:90
ii) 𝑓[x_]: = 𝑥^5 + 𝑥^4 + 𝑥^3 + 𝑥^2 + 𝑥 + 1;
D[f[x], {x, 2}]/. x → 1
Output:40

g:=Derivative[2][f]
g[1]
Output:40

2
Problem-1: Compute the values of the first ten derivatives of 𝑓(𝑥) = 𝑒 𝑥 at x = 0. Put the results
in tabular form.

Solution:

ClearAll[f]
f[x_]:=Exp[x^2];
dt=Table[{n,D[f[x],{x,n}]/.x 0},{n,1,10}];
TableForm[dt,TableHeadings{None,{"n","fn(0)"}}]

Output:

Problem-2: Compute the values of the first seven derivatives of 𝑓(𝑥) = 𝑥 6 − 𝑥 4 + 𝑥 2 − 1 at


x = 0. Put the results in tabular form.

Solution:
ClearAll[f]
f[x_]:=x^6-x^4+x^2-1;
dt=Table[{n,D[f[x],{x,n}]/.x 0},{n,1,7}];

12 Calculus with MATHEMATICA


TableForm[dt,TableHeadings{None,{"n","fn(0)"}}]
Output:

Problem-3: Sketch the graph of the function 𝑓(𝑥) = 𝑥 4 − 50𝑥 2 + 300 and it’s derivative, on
one set of axes for −10 ≤ 𝑥 ≤ 10.
Solution:
ClearAll[f]
f[x_]:=x^4-50x^2+300;
df=D[f[x],{x,1}];
Plot[{f[x],df},{x,-10,10},PlotLegends{"f[x]","df"}]

Output:

2000

1000

10 5 5 10

1000

2000
f x

3000
df

Problem-4: Sketch the graph of the function 𝑓(𝑥) = √𝑥 6 + 5 − 𝑥 3 and it’s first and second
derivative, on one set of axes for −1.5 ≤ 𝑥 ≤ 5.
Solution:
ClearAll[f]
f[x_]:=Sqrt[x^6+5]-x^3;
df1=D[f[x],{x,1}];
df2=D[f[x],{x,2}];
Plot[{f[x],df1,df2},{x,-1.5,5},PlotLegends{"f[x]","df1","df2"}]

13 Calculus with MATHEMATICA


Output:

RELATIVE MAXIMA AND RELATIVE MINIMA

 𝐅𝐢𝐧𝐝𝐌𝐚𝐱𝐢𝐦𝐮𝐦[𝐟[𝐱], {𝐱, 𝐱 𝟎 }] finds the relative maximum of f(x) near x0 .


 𝐅𝐢𝐧𝐝𝐌𝐢𝐧𝐢𝐦𝐮𝐦[𝐟[𝐱], {𝐱, 𝐱 𝟎 }] finds the relative minimum of f(x) near x0 .

Problem-1: Find the relative maxima and relative minima of the function 𝑓(𝑥) = 𝑥 + sin 5𝑥 on
the interval [0, 𝜋].

Solution:

ClearAll[f]
f[x_]=x+Sin[5*x];
Plot[f[x],{x,0,Pi}]

Output:

0.5 1.0 1.5 2.0 2.5 3.0

14 Calculus with MATHEMATICA


FindMaximum[f[x],{x,0.3}]
Output: {1.3342267466303168,{x→0.3544308494898148}}

FindMaximum[f[x],{x,1.5}]
Output: {2.590863808066234,{x→1.6110679109439814}}

FindMaximum[f[x],{x,2.9}]
Output: {3.8475008695021513,{x→2.8677049718826826}}

FindMinimum[f[x],{x,0.9}]
Output: {-0.07758968519439935,{x→0.9022062119188224}}

FindMinimum[f[x],{x,2.1}]
Output: {1.179047376241518,{x→2.158843273417874}}

Note: Caution must be taken to examine the results of the calculation. The value obtained is not
necessarily the one closest to the initial guess. For example,

FindMaximum[f[x],{x,2.8}]
Output: {5.104137930938069,{x→4.124342033826391}}
but the value of x is not between 0 and π.

Class work & Home work:


 For the following functions, find relative extrema in the interval 0 < 𝑥 < 2𝜋:
i) 𝑓(𝑥) = √3𝑥 + 2𝑠𝑖𝑛𝑥
ii) 𝑓(𝑥) = 𝐶𝑜𝑠 2 𝑥
𝑆𝑖𝑛 𝑥
iii) 𝑓(𝑥) = 2−𝐶𝑜𝑠 𝑥
iv) 𝑓(𝑥) = | sin 2𝑥 |

 For the following functions, find relative extrema in the interval 0 ≤ 𝑥 ≤ 4:


i) 𝑓(𝑥) = 𝑥 4 − 4𝑥 3 + 2𝑥 2 + 4𝑥 + 2
ii) 𝑓(𝑥) = −2𝑥 5 + 17𝑥 4 − 46𝑥 3 + 39𝑥 2 + 4𝑥

ANALYSIS OF FUNCTIONS: INCREASING AND DECREASING, CONCAVE UP AND


CONCAVE DOWN:

15 Calculus with MATHEMATICA


Problem-1: Identify the intervals on which 𝑓(𝑥) = 17 − 15𝑥 + 9𝑥 2 − 𝑥 3 is increasing and
decreasing, concave up, and concave down. Locate all inflection points and confirm that your
conclusions are consistent with the graph.
Solution:

Increasing and Decreasing Functions:

ClearAll[f]
f[x_]:=17-15x+9x^2-x^3;
Plot[f[x],{x,-7,7}]
d1f=D[f[x],x];
sol=Solve[d1f0]

Output:

800

600

400

200

6 4 2 2 4 6

{{x→1},{x→5}}

d1fmito1=d1f/.xRandomReal[{-1000000,1}];
If[d1fmito1<0,Print["f is decreasing on (-,1)"],Print["f
is increasing on (-,1)"]]
d1f1to5=d1f/.xRandomReal[{1,5}];
If[d1f1to5<0,Print["f is decreasing on (1,5)"],Print["f is
increasing on (1,5)"]]
d1f5toi=d1f/.xRandomReal[{5.1,1000}];
If[d1f5toi<0,Print["f is decreasing on (5,)"],Print["f is increasing
on (5, )"]]

Output:

f is decreasing on (-∞,1)

f is increasing on (1,5)

16 Calculus with MATHEMATICA


f is decreasing on (5,∞)

Concavity:

d2f=D[f[x],{x,2}];
sol=NSolve[d2f0]

Output:

{{x→3.}}

d2fmi=d2f/.xRandomReal[{-1000,3}];
If[d2fmi<0,Print["f is concave down on (-,3)"],Print["f is
concave up on (-,3)"]]
d2f3=d2f/.xRandomReal[{3,3000}];
If[d2f3<0,Print["f is concave down on (3,)"],Print["f is concave up
on (3,)"]]

Output:

f is concave up on (-∞,3)

f is concave down on (3,∞)

Inflection Point(s):

f[3]

Output: 26

Since f changes from concave up to concave down at the point 𝑥 = 3. The inflection point is
(3, 𝑓(3)) = (3, 26 ). All of these conclusions are consistent with the graph of f .

Problem-2: Identify the intervals on which 𝑓(𝑥) = 3𝑥 4 + 4𝑥 3 − 12𝑥 2 + 2 is increasing and


decreasing, concave up, and concave down. Locate all inflection points and confirm that
your conclusions are consistent with the graph.

Solution:

Increasing and Decreasing Functions:

ClearAll[f]
f[x_]:=3x^4+4x^3-12x^2+2;
Plot[f[x],{x,-3,3}]
d1f=D[f[x],x];
17 Calculus with MATHEMATICA
sol=Solve[d1f0]

Output:

100

80

60

40

20

3 2 1 1 2 3

20

{{x→-2},{x→0},{x→1}}

d1fmitom2=d1f/.xRandomReal[{-1000000,-2}];
If[d1fmitom2<0,Print["f is decreasing on (-,-
2)"],Print["f is increasing on (-,-2)"]]
d1fm2to0=d1f/.xRandomReal[{-2,0}];
If[d1fm2to0<0,Print["f is decreasing on (-2,0)"],Print["f
is increasing on (-2,0)"]]
d1f0to1=d1f/.xRandomReal[{0,1}];
If[d1f0to1<0,Print["f is decreasing on (0,1)"],Print["f is
increasing on (0,1 )"]]
d1f1toi=d1f/.xRandomReal[{1,10000}];
If[d1f1toi<0,Print["f is decreasing on (1,)"],Print["f is
increasing on (1,)"]]

Output:

f is decreasing on (-∞,-2)

f is increasing on (-2,0)

f is decreasing on (0,1)

f is increasing on (1,∞)

Concavity:

d2f=D[f[x],{x,2}];
sol=NSolve[d2f0]
18 Calculus with MATHEMATICA
Output:

{{x→-1.2152504370215302},{x→0.5485837703548635}}

d2fmi=d2f/.xRandomReal[{-1000,-1.21525}];
If[d2fmi<0,Print["f is concave down on (-,-1.21525)"],Print["f is
concave up on (-,-1.21525)"]]

Output:

f is concave up on (-∞,-1.21525)

d2fm1=d2f/.xRandomReal[{-1.21525,0.548584}];
If[d2fm1<0,Print["f is concave down on (-1.21525,0.548584)"],Print["f
is concave up on (-1.21525,0.548584)"]]

Output:

f is concave down on (-1.21525,0.548584)

d2fp5=d2f/.xRandomReal[{0.548584,1000}];
If[d2fp5<0,Print["f is concave down on (0.548584,)"],Print["f is
concave up on (0.548584,)"]]

Output:

f is concave up on (0.548584,∞)

Inflection Point(s):

f[-1.2152504370215302]

Output:

-16.3577816624136

f[0.5485837703548635]

Output:

-0.6792553746234349

Since f changes from concave up to concave down at the point 𝑥 = −1.2152504370215302 and
concave down to concave up at the point 𝑥 = 0.5485837703548635. The inflection points are
(−1.2152504370215302, 𝑓(−1.2152504370215302))

= (−1.2152504370215302, -16.3577816624136) and


(0.5485837703548635, 𝑓(0.5485837703548635))

19 Calculus with MATHEMATICA


= (0.5485837703548635, -0.6792553746234349). All of these conclusions are consistent
with the graph of f .

Class work & Home work:


Determine the intervals on which the following functions are increasing and decreasing , concave
up, and concave down. Locate all inflection points and confirm that your conclusions are
consistent with the graph:

i) f ( x)  5  12 x  x3
ii) 𝑓(𝑥) = 𝑥 3
iii) 𝑓(𝑥) = 𝑥 2 − 4𝑥 + 3
iv) 𝑓(𝑥) = 𝑥 3 − 3𝑥 2 + 1
v) 𝑓(𝑥) = 𝑥 + 2 sin 𝑥

ABSOLUTE MAXIMUM AND ABSOLUTE MINIMUM

Problem-1: Find the absolute maximum and minimum values of the function
𝑓(𝑥) = −2𝑥 5 + 17𝑥 4 − 46𝑥 3 + 39𝑥 2 + 4𝑥 on the interval [0, 4].

Solution:

f[x_]:=-2x^5+17x^4-46x^3+39x^2+4x;
a=0;b=4;
ep={a,b};
df:=D[f[x],x];
cp=NSolve[df0]
pt=Union[ep,cp[[All,1,2]]]
a< x< b/.cp

Output:

{{x→-
0.0472410743439684},{x→1.0596216588487413},{x→2.274656668634987}
,{x→3.5129627468602407}}

{-
0.0472410743439684,0,1.0596216588487413,2.274656668634987,3.5129
627468602407,4}

{False,True,True,True}

20 Calculus with MATHEMATICA


pt=Complement[pt,{pt[[1]]}]

Output:

{0,1.0596216588487413,2.274656668634987,3.5129627468602407,4}

Print["The absolute Maximum is",Max[f[pt]]]

Output:

The absolute Maximum is 20.133970119212904

Print["The absolute Minimum is",Min[f[pt]]]

Output:

The absolute Minimum is 0

Plot[f[x],{x,0,4}]

Output:
20

15

10

1 2 3 4

Problem-2: Find the absolute extreme values of the function


𝑓(𝑥) = 𝑥 4 − 4𝑥 3 + 2𝑥 2 + 4𝑥 + 2 on the interval [0, 4].

Solution:

ClearAll[f]
f[x_]:=x^4-4x^3+2x^2+4x+2;
a=0;b=4;
ep={a,b};
df:=D[f[x],x];

21 Calculus with MATHEMATICA


cp=NSolve[df==0]
pt=Union[ep,cp[[All,1,2]]]
a< x< b/.cp

Output:

{{x→-
0.4142135623730952},{x→0.9999999999999999},{x→2.414213562373095}
}

{-0.4142135623730952,0,0.9999999999999999,2.414213562373095,4}

{False,True,True}

pt=Complement[pt,{pt[[1]]}]
Print["The absolute Maximum is ",Max[f[pt]]]
Print["The absolute Minimum is ",Min[f[pt]]]
Plot[f[x],{x,0,4}]

Output:

{0,0.9999999999999999,2.414213562373095,4}

The absolute Maximum is 50

The absolute Minimum is 1.

15

10

1 2 3 4

Alternative Method:
22 Calculus with MATHEMATICA
 Maximize[{f, cons},x] will maximize the function f with respect to x and subject to the
constraints, cons.
 Minimize[{f, cons},x] will minimize the function f with respect to x and subject to the
constraints, cons.

Problem-1: Find the absolute maximum and minimum values of f on the given closed interval,
and state where those values occur.
a) 𝑓(𝑥) = 𝑥 4 − 4𝑥 3 + 2𝑥 2 + 4𝑥 + 2; [0, 4]
b) 𝑓(𝑥) = 𝑥 + sin 5𝑥; [0, 𝜋]
c) 𝑓(𝑥) = −2𝑥 5 + 17𝑥 4 − 46𝑥 3 + 39𝑥 2 + 4𝑥 ; [0, 4]
d) 𝑓(𝑥) = 2𝑥 3 − 15𝑥 2 + 36𝑥 ; [1, 5]
4 1
e) 𝑓(𝑥) = 6𝑥 3 − 3𝑥 3 ; [−1, 1]

Solution:
a)
ClearAll[f]
f[x_]:=x^4-4x^3+2x^2+4x+2
Plot[f[x],{x,0,4}]
Maximize[{f[x],0 x 4},x]
Minimize[{f[x],0 x 4},x]//Simplify

Output:

15

10

1 2 3 4
{50,{x→4}}
{1,{x→1+√2}}

b)
ClearAll[f,x]
f[x_]:=x+Sin[5x];
Plot[f[x],{x,0,Pi}]
Maximize[{f[x],0 x Pi},x]//N
23 Calculus with MATHEMATICA
Minimize[{f[x],0xPi},x]//N
Output:

0.5 1.0 1.5 2.0 2.5 3.0


{3.8475008695021513,{x→2.8677049723888803}}
{-0.07758968519439935,{x→0.9022062119188718}}

c)
ClearAll[f]
f[x_]:=-2x^5+17x^4-46x^3+39x^2+4x
Plot[f[x],{x,0,4}]
Maximize[{f[x],0 x 4},x]//N
Minimize[{f[x],0 x 4},x]//Simplify

Output:
20

15

10

1 2 3 4
{20.133970119213018,{x→3.5129627468602433}}
{0,{x→0}}

d)
ClearAll[f]
f[x_]:=2x^3-15x^2+36x
24 Calculus with MATHEMATICA
Plot[f[x],{x,1,5}]
Maximize[{f[x],1 x 5},x]//N
Minimize[{f[x],1 x 5},x]//Simplify
Output:

45

40

35

30

25

2 3 4 5

{55.,{x→5.}}

{23,{x→1}}

e)

ClearAll[f]
f[x_]:=6x^(4/3)-3x^(1/3)
Plot[f[x],{x,-1,1}]
Maximize[{f[x],-1 x 1},x]//N
Minimize[{f[x],-1 x 1},x]//Simplify

Output:
3

1.0 0.5 0.5 1.0

{3.,{x→1.}}

25 Calculus with MATHEMATICA


{-9/8,{x→1/8}}

ASYMPTOTES

Problem-1: Find the horizontal, vertical, oblique and curvilinear asymptotes (if they exist) of the
following function:
𝑥3
a) 𝑓(𝑥) = 𝑥 2 −1
1
b) 𝑓(𝑥) = 𝑥 2 +1
2𝑥 2 +7
c) 𝑓(𝑥) = 3𝑥 2 +𝑥+12
2𝑥 2 −3𝑥+5
d) 𝑓(𝑥) = 3𝑥 2 +5𝑥−12
𝑥 3 −1
e) 𝑓(𝑥) = 𝑥
(𝑥−2)3
f) 𝑓(𝑥) = 𝑥2

Solution:

a)

ClearAll[f,x,m,n]
f[x_]:=x^3/(x^2-1);

Horizontal asymptotes:
Limit[f[x],x ]
Limit[f[x],x -]

Output:


-∞

Therefore, there are no horizontal asymptotes.

Vertical asymptotes:
Solve[x^2-1==0,x]

Output:

{{x→-1},{x→1}}

26 Calculus with MATHEMATICA


Therefore, the vertical asymptotes are the lines, 𝑥 = 1 and 𝑥 = −1.

Oblique asymptotes:

m=Limit[(f[x])⁄x,x→Infinity]

Output:

1
n=Limit[f[x]-m*x,x→Infinity]

Output:

Print["The Oblique asymptotes is y=",m*x+n]

Output:

The Oblique asymptotes is y=x

b)
Horizontal asymptotes:

ClearAll[f,x,m,n]
f[x_]:=1/(x^2+1);
Limit[f[x],x ]

Output:

Therefore, the horizontal asymptote is the line, 𝑦 = 0.

Vertical asymptotes:

Solve[x^2+1==0]

Output:

{{x→-ⅈ},{x→ⅈ}}

Therefore, there are no ho vertical asymptotes.

27 Calculus with MATHEMATICA


c)
Horizontal asymptotes:

ClearAll[f,x,m,n]
f[x_]:=(2x^2+7)/(3x^2+x+12);
Limit[f[x],x ]
Limit[f[x],x -]

Output:

2/3
2/3
Therefore, the horizontal asymptote is the line, 𝑦 = 2/3.

Vertical asymptotes:

Solve[3x^2+x+12==0,x]

Output:

{{x→1/6(-1-ⅈ√143)},{x→1/6(-1+ⅈ√143)}}

Therefore, there are no ho vertical asymptotes.

d)
Horizontal asymptotes:

ClearAll[f,x,m,n]
f[x_]:=(2x^2-3x+5)/(3x^2+5x-12);
Limit[f[x],x ]
Limit[f[x],x -]

Output:

2/3

2/3

Therefore, the horizontal asymptote is the line, 𝑦 = 2/3.

Vertical asymptotes:

Solve[3x^2+5x-12==0,x]

28 Calculus with MATHEMATICA


Output:

{{x→-3},{x→4/3}}

Therefore, the vertical asymptotes are the lines, 𝑥 = −3 and 𝑥 = 4/3.

e)
Horizontal asymptotes:

ClearAll[f,x,m,n]
f[x_]:=(x^3-1)/x;
Limit[f[x],x ]
Limit[f[x],x -]

Output:

Therefore, there are no horizontal asymptotes.

Vertical asymptotes:

The vertical asymptote is the line, 𝑥 = 0.

Curvilinear asymptotes:

m=Limit[(f[x])⁄(x^2),x→∞]

Output:

n=Limit[(f[x]-m*x^2),x→∞]

Output:

Print["The Curvilinear asymptotes is y=",m*x^2+n]

Output:

29 Calculus with MATHEMATICA


The Curvilinear asymptotes is y=x^2

f)
Horizontal asymptotes:

ClearAll[f,x,m,n]
f[x_]:=(x-2)^3/x^2;
Limit[f[x],x ]
Limit[f[x],x -]

Output:

-∞

Therefore, there are no horizontal asymptotes.

Vertical asymptotes:

Solve[x^2==0,x]

Output:

{{x→0},{x→0}}

Therefore, the vertical asymptote is the line, 𝑥 = 0.

Oblique asymptotes:

m=Limit[(f[x])⁄x,x→Infinity]

Output:

n=Limit[f[x]-m*x,x→Infinity]

Output:

-6
30 Calculus with MATHEMATICA
Print["The Oblique asymptote is y=",m*x+n]

Output:

The Oblique asymptote is y=-6+x

IMPLICIT DIFFERENTIATION
𝑑𝑓
 Dt[f, x] gives the total derivative 𝑑𝑥 .
Examples:
i) Dt[a*x+b,x]
Output:
a+xDt[a,x]+Dt[b,x]
ii) Dt[a*x+y,x]
Output:
a+xDt[a,x]+Dt[y,x]

%//TraditionalForm
Output:
𝑥 ⅆ𝑎/ ⅆ𝑥 + 𝑎 + ⅆ𝑦/ ⅆ𝑥
where as D[a*x+y,x]gives a as output.

𝑑𝑛 𝑓
 Dt[f, {x,n}] gives the multiple derivative 𝑑𝑥 𝑛.
Examples:
i) Dt[x^2y,{x,2}]
Output:
2y+4xDt[y,x]+x^2 Dt[y,{x,2}]

%//TraditionalForm
Output:
2
ⅆ2𝑦 ⅆ𝑦
𝑥 2
+ 4𝑥 + 2𝑦
ⅆ𝑥 ⅆ𝑥

Problem-1: Use implicit differentiation to find dy/dx if

i) 𝑥𝑦 − 1 = 0
ii) 5𝑦 2 + sin 𝑦 − 𝑥 2 = 0

31 Calculus with MATHEMATICA


Solution:

i)

a=x*y-1
b=Dt[a,x]

Output:

-1+xy
y+xDt[y,x]

c=Solve[b==0,Dt[y,x]]
Output:
{Dt[y,x]→-y/x}}
%//TraditionalForm
ⅆ𝑦 𝑦
{{ → − }}
ⅆ𝑥 𝑥

ii) ClearAll[a,b,c]
a=5y^2+Sin[y]-x^2
b=Dt[a,x]
c=Solve[b==0,Dt[y,x]]
Output:

-x^2+5y^2+Sin[y]

-2x+10yDt[y,x]+Cos[y]Dt[y,x]
2𝑥
{{Dt[𝑦, 𝑥] → }}
10𝑦+Cos[𝑦]

𝑑2 𝑦
Problem-2: Use implicit differentiation to find 𝑑𝑥 2 if

i) 4𝑥 2 − 2𝑦 2 = 9
ii) 𝑦 + 𝑠𝑖𝑛 𝑦 − 𝑥 = 0
iii) 2𝑥 2 + 3𝑦 2 = 4
iv) 𝑥3𝑦3 = 4

Solution:

i)

32 Calculus with MATHEMATICA


ClearAll[a,b,c,d,e,f]
a=4x^2-2y^2-9
b=Dt[a,x]
c=Solve[b==0,Dt[y,x]]
d=Dt[a,{x,2}]
e=Solve[d==0,Dt[y,{x,2}]]

Output:
−9 + 4𝑥 2 − 2𝑦 2
8 x-4 y Dt[y,x]
{{Dt[y,x](2 x)/y}}
8-2 (2 Dt[y,x]2+2 y Dt[y,{x,2}])
{{Dt[y,{x,2}](2-Dt[y,x]2)/y}}

f=e/.Dt[y,x](2 x)/y

{{Dt[y,{x,2}](2-(4 x2)/y2)/y}}

%//TraditionalForm
{{2y/x2(2 (y2-2 x2))/y3}}

ii)
ClearAll[a,b,c,d,e,f]
a=y+Sin[y]-x
b=Dt[a,x]
c=Solve[b==0,Dt[y,x]]
d=Dt[a,{x,2}]
e=Solve[d==0,Dt[y,{x,2}]]

Output:

-x+y+Sin[y]
-1+Dt[y,x]+Cos[y] Dt[y,x]
{{Dt[y,x]1/(1+Cos[y])}}
Dt[y,{x,2}]+Cos[y] Dt[y,{x,2}]-Dt[y,x]2 Sin[y]
{{Dt[y,{x,2}](Dt[y,x]2 Sin[y])/(1+Cos[y])}}

f=e/.Dt[y,x]1/(1+Cos[y])
{{Dt[y,{x,2}]Sin[y]/(1+Cos[y])3}}
%//TraditionalForm
{{2y/x2sin(y)/(cos(y)+1)3}}

33 Calculus with MATHEMATICA


iii)
ClearAll[a,b,c,d,e,f]
a=2x^2-3y^2-4
b=Dt[a,x]
c=Solve[b==0,Dt[y,x]]
d=Dt[a,{x,2}]
e=Solve[d==0,Dt[y,{x,2}]]
Output:

-4+2 x2-3 y2
4 x-6 y Dt[y,x]
{{Dt[y,x](2 x)/(3 y)}}
4-3 (2 Dt[y,x]2+2 y Dt[y,{x,2}])
{{Dt[y,{x,2}](2-3 Dt[y,x]2)/(3 y)}}

f=e/.Dt[y,x](2 x)/(3 y)
{{Dt[y,{x,2}](2-(4 x2)/(3 y2))/(3 y)}}
%//TraditionalForm
{{2y/x2(2-(4 x2)/(3 y2))/(3 y)}}

iv)
ClearAll[a,b,c,d,e,f]
a=x^3y^3-4
b=Dt[a,x]
c=Solve[b==0,Dt[y,x]]
d=Dt[a,{x,2}]
e=Solve[d==0,Dt[y,{x,2}]]
Output:

-4+x3 y3
3 x2 y3+3 x3 y2 Dt[y,x]
{{Dt[y,x]-(y/x)}}
6 x y3+18 x2 y2 Dt[y,x]+x3 (6 y Dt[y,x]2+3 y2 Dt[y,{x,2}])
{{Dt[y,{x,2}]-((2 (y2+3 x y Dt[y,x]+x2 Dt[y,x]2))/(x2 y))}}

f=e/.Dt[y,x]-(y/x)
{{Dt[y,{x,2}](2 y)/x2}}
%//TraditionalForm
{{2y/x2(2 y)/x2}}
34 Calculus with MATHEMATICA
ROLLE’S THEOREM

Problem-1: Apply Rolle’s theorem to find the values of c for the following functions:

i) 𝑓(𝑥) = 4𝑥 + 39𝑥 2 − 46𝑥 3 + 17𝑥 4 − 2𝑥 5 on the interval [0, 4]


ii) 𝑓(𝑥) = 𝑥 4 + 𝑥 3 − 𝑥 2 + 𝑥 − 2 on the interval [−2, 1]

Solution:

i)
f[x_]:=4x+39x^2-46x^3+17x^4-2x^5
a=0;b=4;
Plot[f[x],{x,a,b}]
f[a]==f[b]==0
df=D[f[x],x]
dfc=df/.x c
sol=NSolve[dfc==0]
Print["The values of c inside the interval are"]
For[i=1,i4,i++,If[a<c<b/.c sol[[i,1,2]],Print[sol[[i,1,2]]]]]

Output:
20

15

10

1 2 3 4

True
4+78 x-138 x2+68 x3-10 x4
4+78 c-138 c2+68 c3-10 c4
{{c-0.0472411},{c1.05962},{c2.27466},{c3.51296}}
The values of c inside the interval are
1.05962
2.27466
3.51296
35 Calculus with MATHEMATICA
ii)
f[x_]:=-2+x-x^2+x^3+x^4
a=-2;b=1;
Plot[f[x],{x,a,b}]
f[a]==f[b]==0
df=D[f[x],x]
dfc=df/.x c
sol=NSolve[dfc==0]
Print["The values of c inside the interval are"]
For[i=1,i3,i++,If[a<c<b/.c sol[[i,1,2]],Print[sol[[i,1,2]]]]]
2.0 1.5 1.0 0.5 0.5 1.0

True
1-2 x+3 x2+4 x3
1-2 c+3 c2+4 c3
{{c-1.28858},{c0.269292_-0.348559 },{c0.269292_+0.348559 }}
The values of c inside the interval are
-1.28858
Less::nord: Invalid comparison with _0.269292_-0.348559 _ attempted. 
Less::nord: Invalid comparison with _0.269292_-0.348559 _ attempted. 
Less::nord: Invalid comparison with _0.269292_-0.348559 _ attempted. 
General::stop: Further output of _Less::nord_ will be suppressed during this
calculation. 

Problem-1: Verify Rolle’s theorem for the following functions:

i) 𝑓(𝑥) = 𝑒 −𝑥 sin 𝑥; [0, 𝜋]


ii) 𝑓(𝑥) = 𝑥 2 − 3𝑥 + 2; [1, 2]
iii) 𝑓(𝑥) = log(−𝑥 2 + 2𝑥 + 4) ; [−1, 3]

36 Calculus with MATHEMATICA


Solution:

i)
ClearAll[f,x]
f[x_]:=Exp[-x]Sin[x]
a=0;b=Pi;
f[a]==f[b]==0
Plot[f[x],{x,a,b}]
True
0.30

0.25

0.20

0.15

0.10

0.05

0.5 1.0 1.5 2.0 2.5 3.0


df=D[f[x],x]
dfc=df/.x c
-x Cos[x]--x Sin[x]
-c Cos[c]--c Sin[c]
s=FindRoot[dfc==0,{c,1}]
If[a<c<b/.s,Print["Rolle's Theorem is verified"]]
{c0.785398}
Rolle's Theorem is verified

ii)
ClearAll[f,x]
f[x_]:=x^2-3x+2
a=1;b=2;
f[a]==f[b]==0
Plot[f[x],{x,a,b}]
True

37 Calculus with MATHEMATICA


1.2 1.4 1.6 1.8 2.0

0.05

0.10

0.15

0.20

0.25
df=D[f[x],x]
dfc=df/.x c
s=FindRoot[dfc==0,{c,1.5}]
If[a<c<b/.s,Print["Rolle's Theorem is verified"]]
-3+2 x
-3+2 c
{c1.5}
Rolle's Theorem is verified

iii)
ClearAll[f,x]
f[x_]:=Log[4+2x-x^2]
a=-1;b=3;
f[a]==f[b]==0
Plot[f[x],{x,a,b}]
True
1.5

1.0

0.5

1 1 2 3
df=D[f[x],x]
dfc=df/.x c
s=FindRoot[dfc==0,{c,1.1}]
If[a<c<b/.s,Print["Rolle's Theorem is verified"]]
38 Calculus with MATHEMATICA
(2-2 x)/(4+2 x-x2)
(2-2 c)/(4+2 c-c2)

Rolle's Theorem is verified

MEAN-VALUE THEOREM

Problem-1: Apply Mean-Value Theorem to find the values of c for the following functions;
hence verify the Mean-Value Theorem.

i) 𝑓(𝑥) = (𝑥 − 1)(𝑥 − 2)(𝑥 − 3); [0, 4]


ii) 𝑓(𝑥) = √𝑥 + sin 2𝜋𝑥 ; [0, 2]
iii) 𝑓(𝑥) = 𝑥 3 + 𝑥 − 4; [−1, 2]
iv) 𝑓(𝑥) = √25 − 𝑥 2 ; [−5, 3]

Solution:

i)

ClearAll[f,x]
f[x_]=(x-1)(x-2)(x-3)
a=0;b=4;
ContourPlot[{y==f[x],(x-a)/(a-b)==(y-f[a])/(f[a]-f[b])},{x,a,b},{y,-
6,6},AxesTrue,FrameFalse]
(-3+x) (-2+x) (-1+x)

39 Calculus with MATHEMATICA


6

1 2 3 4

sol=FindRoot[f[b]-f[a](b-a)f'[c],{c,{1,3}}]
{c{0.845299,3.1547}}
For[i=1,i 2,i++,If[a<c<b/.c sol[[1,2,i]],Print["Mean-value Theorem is verified"]]]
Mean-value Theorem is verified

ii)

ClearAll[f,x]
f[x_]=Sqrt[x]+Sin[2Pi*x]
a=0;b=2;
ContourPlot[{y==f[x],(x-a)/(a-b)==(y-f[a])/(f[a]-f[b])},{x,a,b},{y,-
1,3},AxesTrue,FrameFalse]
x
+Sin[2  x]

40 Calculus with MATHEMATICA


3

0.5 1.0 1.5 2.0

1
s1=FindRoot[f[b]-f[a]==(b-a)f'[c],{c,{0.25,0.75,1.25,1.75}}]
{c{0.257071,0.753319,1.24344,1.75836}}
For[i=1,i 4,i++,If[a<c<b/.c s1[[1,2,i]],Print["Mean-value Theorem is
verified"];Break[];]]
Mean-value Theorem is verified
iii)

ClearAll[f,x]
f[x_]=x^3+x-4
a=-1;b=2;
ContourPlot[{y==f[x],(x-a)/(a-b)==(y-f[a])/(f[a]-f[b])},{x,a,b},{y,-
7,10},AxesTrue,FrameFalse]
-4+x+x3

41 Calculus with MATHEMATICA


10

1.0 0.5 0.5 1.0 1.5 2.0

s1=FindRoot[f[b]-f[a]==(b-a)f'[c],{c,0.8}]
{c1.}
If[a<c<b/.s1,Print["Mean-value Theorem is verified."]]
Mean-value Theorem is verified.

iv)
ClearAll[f,x]
f[x_]=Sqrt[25-x^2];
a=-5;b=3;
ContourPlot[{y==f[x],(x-a)/(a-b)==(y-f[a])/(f[a]-f[b])},{x,a,b},{y,-
2,5},AxesTrue,FrameFalse]

42 Calculus with MATHEMATICA


5

4 2 2

s1=FindRoot[f[b]-f[a]==(b-a)f'[c],{c,-2}]
{c-2.23607}
If[a<c<b/.s1,Print["Mean-value Theorem is verified."]]
Mean-value Theorem is verified.

POWER SERIES

 Series[f,{x,x0,n}] generates a power series expansion for f about the point x=x 0 to order
(x-x0)n.
 SeriesCoefficient[series,n] finds the coefficient of nth order term in the form generated
by series.
 SeriesCoefficient[f,{x,x0,n}] find the coefficient of (x-x0)n in the expansion of f about the
point x=x0 .
𝜋
Problem-1: Expand 𝑆𝑖𝑛 𝑥 in power of (𝑥 − ).
2

Solution:

Series[Sin[x],{x,Pi/2,10}]
1-1/2 (x-/2)2+1/24 (x-/2)4-1/720 (x-/2)6+(x-/2)8/40320-(x-/2)10/3628800+O[x-/2]11
𝜋
Problem-2: Expand 𝐶𝑜𝑠 𝑥 in power of (𝑥 − 2 ).

Solution:
43 Calculus with MATHEMATICA
Series[Cos[x],{x,Pi/2,10}]//Normal
/2-x+1/6 (-(/2)+x)3-1/120 (-(/2)+x)5+(-(/2)+x)7/5040-(-(/2)+x)9/362880

Problem-3: Obtain the coefficient of 𝑥 7 in the expansion of 𝑒 𝑥 .

Solution:

s=Series[Exp[x],{x,0,7}]
1+x+x2/2+x3/6+x4/24+x5/120+x6/720+x7/5040+O[x]8
SeriesCoefficient[s,7]
1/5040

OR

SeriesCoefficient[Exp[x],{x,0,7}]
1/5040

Problem-4: Construct the Taylor polynomials about x=1 for 𝑓(𝑥) = 𝑆𝑖𝑛𝑥 of degree 9. In
addition, construct an error function and computes it’s value from x=1 to 2 in increment 0.2.
Finally, Place the results in the form of a table and comment on the values on the error as x gets
further from 1.

Solution:

s1=Series[Sin[x],{x,1,9}]//Normal
err[x_]=Abs[s1-Sin[x]];
s=Table[{x,err[x]},{x,1,2,0.2}];
TableForm[s,TableHeadings →{None,{"x","err(x)"}}]

(-1+x) Cos[1]-1/6 (-1+x)3 Cos[1]+1/120 (-1+x)5 Cos[1]-((-1+x)7 Cos[1])/5040+((-1+x)9


Cos[1])/362880+Sin[1]-1/2 (-1+x)2 Sin[1]+1/24 (-1+x)4 Sin[1]-1/720 (-1+x)6 Sin[1]+((-1+x)8
Sin[1])/40320

Comment: err[x] is increasing as x gets further from 1.

Problem-5: Construct the Taylor polynomials about x=0 for 𝑓(𝑥) = 𝑒 𝑥 of degree 11. In
addition, construct an error function and computes it’s value from x=0 to 8 in increment 2.
Finally, Place the results in the form of a table.

44 Calculus with MATHEMATICA


Solution:

s1=Series[Exp[x],{x,0,11}]//Normal
err[x_]=Abs[s1-Sin[x]];
s=Table[{x,err[x]},{x,0,8,2}];
TableForm[s,TableHeadings→{None,{"x","err(x)"}}]

1+x+x2/2+x3/6+x4/24+x5/120+x6/720+x7/5040+x8/40320+x9/362880+x10/3628800+x11/39
916800

TANGENT AND NORMAL

Problem-1: Obtain the equation of tangent and normal for the following curves at the point
given with them and plot them in the same set of axes:

a) 𝑥 2 + 2𝑦 2 = 3 at (−1, 1)
b) 𝑦 = 𝑥 2 at (2, 4)
c) 𝑦 2 = 8𝑥 at (2, 4)
d) 𝑥 2 − 𝑦 2 = 9 at (5, 4)

Solution:

a)

x1=1;y1=-1;
d1=Dt[x^2+2y^2==3,x]
2 x+4 y Dt[y,x]0
sol=Solve[d1,Dt[y,x]]
{{Dt[y,x]-(x/(2 y))}}
m=sol[[1,1,2]]/.{x x1,y y1}
1/2
tangent=y-y1m(x-x1)//Simplify
45 Calculus with MATHEMATICA
normal=y-y1-(1/m)(x-x1)//Simplify
x3+2 y
2 x+y1
ContourPlot[{x^2+2y^2==3,x3+2 y,2 x+y1},{x,-2,3},{y,-
2,2},AxesTrue,FrameFalse]
2

2 1 1 2 3

b)
x1=2;y1=4;
d1=Dt[y==x^2,x]
sol=Solve[d1,Dt[y,x]]
m=sol[[1,1,2]]/.{x x1,y y1}
tangent=y-y1m(x-x1)//Simplify
normal=y-y1-(1/m)(x-x1)//Simplify

Dt[y,x]2 x
{{Dt[y,x]2 x}}
4
4 x4+y
x+4 y18
ContourPlot[{y==x^2,4 x4+y,x+4 y18},{x,-5,5},{y,-
5,10},AxesTrue,FrameFalse]

46 Calculus with MATHEMATICA


10

4 2 2 4

c)
x1=2;y1=4;
d1=Dt[y^28x,x]
sol=Solve[d1,Dt[y,x]]
m=sol[[1,1,2]]/.{x x1,y y1}
tangent=y-y1m(x-x1)//Simplify
normal=y-y1-(1/m)(x-x1)//Simplify

2 y Dt[y,x]8
{{Dt[y,x]4/y}}
1
2+xy
x+y6
ContourPlot[{y^28x,2+xy,x+y6},{x,-10,10},{y,-
10,10},AxesTrue,FrameFalse]

47 Calculus with MATHEMATICA


10

10 5 5 10

10

d)
x1=5;y1=4;
d1=Dt[x^2-y^29,x]
sol=Solve[d1,Dt[y,x]]
m=sol[[1,1,2]]/.{x x1,y y1}
tangent=y-y1m(x-x1)//Simplify
normal=y-y1-(1/m)(x-x1)//Simplify

2 x-2 y Dt[y,x]0
{{Dt[y,x]x/y}}
5/4
5 x9+4 y
(4 x)/5+y8
ContourPlot[{x^2-y^29,5 x9+4 y,(4 x)/5+y8},{x,-10,10},{y,-
10,10},AxesTrue,FrameFalse]

48 Calculus with MATHEMATICA


10

10 5 5 10

10

49 Calculus with MATHEMATICA


INTEGRAL CALCULUS
 Integrate[f[x],x] computes the indefinite integral ∫ 𝑓(𝑥)ⅆ𝑥.
𝑏
 Integrate[f[x],{x,a,b}] computes the definite integral ∫𝑎 𝑓(𝑥)ⅆ𝑥.

Problem-1: Evaluate the following Integrals:

a) ∫ 𝑥 2 𝑒 𝑥 𝑠𝑖𝑛𝑥 ⅆ𝑥
1
b) ∫ (√𝑥 + 𝑥) ⅆ𝑥

1
c) ∫ √1−𝑥 2 ⅆ𝑥
1
d) ∫ (𝑥 4 +1)2 ⅆ𝑥

Solution:
a)
Integrate[x^2Exp[x]Sin[x],x]
1/2 x (-(-1+x)2 Cos[x]+(-1+x2) Sin[x])

b)
Integrate[(Sqrt[x]+1/Sqrt[x]),x]
2/3 x (3+x)
c)
Integrate[(1/Sqrt[1-x^2]),x]
ArcSin[x]

Integrate[(1/(x^4+1)^2),x]
1/32 ((8 x)/(1+x4)-6 2 ArcTan[1- 2
x]+6 2
ArcTan[1+ 2
x]-3
2 Log[1- 2 x+x2]+3 2 Log[1+ 2 x+x2])

Problem-2: Calculate a table of integrals ∫ 𝑠𝑖𝑛𝑛 𝑥 ⅆ𝑥 for 𝑛 = 0 to 10.

Solution:
tab=Table[{n,Integrate[Sin[x]^n,x]},{n,0,10}];
TableForm[tab,TableHeadings {None,{"n","\[Integral](Sinnx dx"}}]

50 Calculus with MATHEMATICA


Problem-3: Evaluate the following definite integrals:
1
a) ∫0 sin(𝑠𝑖𝑛 𝑥) ⅆ𝑥
10 𝑑𝑥
b) ∫4 (1+𝑥 2 )√1−𝑥 2
1
c) ∫0 𝑥𝑒 𝑥 𝑠𝑖𝑛𝑥 ⅆ𝑥

Solution:
Integrate[Sin[Sin[x]],{x,0,1}]//N
0.430606

Integrate[1/((1+x^2)Sqrt[1-x^2]),{x,4,10}]//N
0._-0.0258087 

Integrate[x*Exp[x]*Sin[x],{x,0,1}]
1/2 (-1+ Sin[1])

NIntegrate[x*Exp[x]*Sin[x],{x,0,1}]
0.643678

51 Calculus with MATHEMATICA


Problem-4: Compute the approximate length of one complete arc of a sine curve.
Solution:

f[x_]=Sin[x];
a=0;b=Pi;
Plot[f[x],{x,a,b}]
1.0

0.8

0.6

0.4

0.2

0.5 1.0 1.5 2.0 2.5 3.0

arclen=NIntegrate[Sqrt[1+(f'[x])^2],{x,a,b}]
3.820197789023311

Problem-5: Compute the approximate length of one complete arc of a cosine curve.
Solution:
f[x_]=Cos[x];
a=-Pi/2;b=Pi/2;
Plot[f[x],{x,a,b}]
1.0

0.8

0.6

0.4

0.2

1.5 1.0 0.5 0.5 1.0 1.5

arclen=NIntegrate[Sqrt[1+(f'[x])^2],{x,a,b}]
3.820197789023311
Problem-6: Find the length of the following curve from x=1 to x=2:

𝑦 = (𝑥 + 1)(𝑥 + 2) − 1/8𝑙𝑛(2𝑥 + 3)

52 Calculus with MATHEMATICA


Solution:
ClearAll[f];
f[x_]=(x+1)(x+2)-(1/8)Log[2x+3];
a=1;b=2;
Plot[f[x],{x,a,b}]
arclen=NIntegrate[Sqrt[1+(f'[x])^2],{x,a,b}]

11

10

6
1.2 1.4 1.6 1.8 2.0
6.04206

Problem-7: Find the area bounded by the curve 𝑦 = sin 𝑥, the axis of x and straight lines x=0 to
x=𝜋.

Solution:
ClearAll[f];
f[x_]=Sin[x];
ContourPlot[{y==f[x],x==0,x==Pi},{x,-
1,4},{y,0,1},Axes→True,Frame →False]
area=Integrate[f[x],{x,0,Pi}]

53 Calculus with MATHEMATICA


1.0

0.8

0.6

0.4

0.2

1 1 2 3 4
2

Problem-8: Find the area bounded by the curve 𝑦 = 𝑥 2 , the axis of x and two straight lines
𝑥 = 1, 𝑥 = 3.

Solution:
ClearAll[f];
f[x_]=x^2;
ContourPlot[{y==f[x],x==1,x==3},{x,0,4},{y,0,10},Axes→True,
Frame→False]
area=Integrate[f[x],{x,1,3}]

54 Calculus with MATHEMATICA


10

1 2 3 4
26/3
Problem-9: Compute the area bounded by the following curves:

a) 𝑓1 (𝑥) = 1 − 𝑥 2 and 𝑓2 (𝑥) = 𝑥 4 − 3𝑥 2


b) 𝑦 2 = 4𝑥 and 𝑦 = 2𝑥 − 4

Solution:

a)
ClearAll[f];
f1[x_]=1-x^2;
f2[x_]=x^4-3x^2
Plot[{f1[x],f2[x]},{x,-2,2},FillingTrue]
-3 x2+x4

55 Calculus with MATHEMATICA


Solve[f1[x]==f2[x]]
{{x- 1 2 },{x 1 2 },{x- 1 2 },{x 1 2 }}
1 2
a=- ;
b= 1 2
;
area=NIntegrate[(f1[x]-f2[x]),{x,a,b}]
4.48665

b)
ClearAll[a,b];
f1[y_]=y^2/4;
f2[y_]=(y+4)/2;
Plot[{f1[y],f2[y]},{y,-4,4},Filling True]
Solve[f1[y]==f2[y]]

{{y-2},{y4}}
a=-2;b=4;
area=NIntegrate[(f2[y]-f1[y]),{y,a,b}]
9.
𝑥2 𝑦2
Problem-10: Find the volume of the solid generated by revolving the ellipse 𝑎2 + 𝑏2 = 1 about
x-axis.

Solution:

Solve[x^2/a^2+y^2/b^2==1,y]
2 2 2 2
{{y-((b a x )/a)},{y(b a x )/a}}
2 2
y=(b a x )/a
Volume=Integrate[Pi*y^2,{x,-a,a}]
2 2
(b a x )/a
4/3 a b2  
56 Calculus with MATHEMATICA
𝑥2 𝑦2
Problem-11: Find the volume of the solid generated by revolving the ellipse 𝑎2 + 𝑏2 = 1 about
y-axis.
Solution:

ClearAll[x,y,a,b];
Solve[x^2/a^2+y^2/b^2==1,x]

{{x-((a b2 y2 )/b)},{x(a b2 y2 )/b}}


2 2
x=(a b y )/b;
Volume=Integrate[Pi*x^2,{y,-b,b}]
4/3 a2 b 

Problem-12: Compute the volume of the sphere obtained if the semicircle 𝑦 = √𝑟 2 − 𝑥 2 , −𝑟 ≤


𝑥 ≤ 𝑟 is rotated about the x-axis.

Solution:

ClearAll[a,b,x,y];
y=Sqrt[r^2-x^2];
a=-r;b=r;
volume=Pi*Integrate[y^2,{x,a,b}]
(4  r3)/3

57 Calculus with MATHEMATICA


REFERENCES

[1] The Student’s Introduction to Mathematica ® A Handbook for Precalculus, Calculus, and
Linear Algebra, Second edition, Bruce F. Torrence & Eve A. Torrence, CAMBRIDGE
UNIVERSITY PRESS, 2009.

[2] Mathematica, Third Edition, Eugene Don, Schaum’s Outline Series, 2019.

[3] MATHEMATICA, Hafizur, Sanjit and Sarwar, TITAS MATH SERIES, 2012.

[4] Differential Calculus using MATHEMATICA,CÉSAR PÉREZ LÓPEZ.

[5] Analysis with Mathematica® Volume 1: Single Variable Calculus, Galina Filipuk, Andrzej
Kozłowski, 2019.

[6] MATHEMATICA BOOK, 5TH EDITION, STEPHEN WOLFRAM, 2003.

[7] CALCULUS EARLY TRANSCENDENTALS, 10TH EDITION, HOWARD ANTON, IRL


BIVENS, STEPHEN DAVIS, 2012.

**********************************************************************

58 Calculus with MATHEMATICA

You might also like