(C) Calculus Practical
(C) Calculus Practical
. FY.BSC-CS Roll no: ____ has completed the required number of practicals
. 2022-2023.
______________ _____________
. Course Co-ordinator Prof. Incharge
______________ ______________
Sr.
No. Date INDEX Pg.
No. Sign.
*******
Theory- 1
A function is a relation from a set of inputs to a set of possible outputs where each input is related to
exactly one output.
The domain of a function is the complete set of possible values of the independent variable.
The range of a function is the complete set of all possible resulting values of the dependent variable
(y, usually), after we have substituted the domain.
In Sage Math, functions can be defined using the def keyword and operations on
functions can be performed using standard mathematical operations like addition,
subtraction, multiplication, and division.
In Geogebra, functions can be defined using the f(x) = syntax and operations on
functions can be performed using standard mathematical operations. For
example, to define the function f(x) = x^2 and g(x) = x+ 1, you would do the
following:
• Click the "New Function" button and enter f(x) = x^2.
• Repeat step 1 for the function g(x) =x+ 1.
• To add the functions, enter h(x) = f(x) + g(x) into the input bar.
• Repeat step 3 for subtraction, multiplication, and division.
• These examples demonstrate the basic syntax for defining and performing
operations on functions in Sage Math and Geogebra.
1
c. Continuity of functions of one variable
Continuity of a function of one variable is a property that ensures that the function
does not have any sudden jumps or breaks at any points in its domain. In other
words, a continuous function has a well-defined value for every point in its
domain and the value of the function changes smoothly as the input changes.
In Geogebra, derivatives can be calculated using the Tangent tool. To find the
derivative of the function f(x) = x^2 at the point 2:
• Create the graph of the function f(x) = x^2.
• Select the Tangent tool and click on the point (2, 4) on the graph
• A tangent line will be drawn on the graph, and the slope of the tangent line
is equal to the derivative of the function at that point.
2
Practical 1
Ex-1)
To define the function f(x) = x^2 and g(x) = x + 1 and perform operations on it you would do
the following:
Code:
Output:
3
Ex-2)
To find the domain and range of x^2
Code:
Output:
4
b. Limits of functions of one variable
Ex-1)
To calculate the limit of a function f(x) =x^2 as x approaches 2, you would do the
Following:
Code:
Output:
Code:
Output:
5
d. Derivatives of functions of one variable
Ex-1)
To calculate the derivative of the function f(x)=x^2, you would do the
Following:
Code:
Output:
6
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is a function?
2. What is Domain and Co-Domain of a function?
3. What is Image and Pre-image of a function?
4. What is Range of a function?
7
Theory- 2
Applications of Derivatives I-
In Sage Math, the first derivative of a function can be used to determine whether
it is increasing or decreasing. If the derivative of the function is positive on an
interval, then the function is increasing on that interval. If the derivative of the
function is negative on an interval, then the function is decreasing on that
interval.
8
b. Concavity and inflection points
The concavity of a function refers to the manner in which the function bends. A
function is said to be concave up if, as the input increases, the rate of change of
the funcion increases. A function is said to be concave down if, as the input
increases, the rate of change of the function decreases. An inflection point is a
point on a function where the concavity changes.
In Sage Math, the second derivative of a function can be used determine its
concavity and find its inflection points. If the second derivative of the function is
positive, then the function is concave up. If the second derivative of the function
is negative, then the function is concave down. To find the inflection points of the
function, you can find the points where the second derivative is equal to 0 or
does not exist.
In Geogebra, the second derivative of a function can also be used to determine
its concavity and find its inflection points. To determine the concavity and find the
inflection points of the function f(x) = x^3:
• Create the graph of the function f(x) = x^3.
• Calculate the first derivative of the function using the Tangent tool.
• Calculate the second derivative of the first derivative using the Tangent
tool.
• Observe the sign of the second derivative function to determine the
concavity of the original function.
• Find the points where the second derivative function is equal to 0 or does
not exist to find the inflection points of the original function.
These examples demonstrate the basic methods for determining the concavity
and finding the inflection points of a function using derivatives in Sage Math and
Geogebra.
c. Relative Extrema
The relative extrema of a function are the local maximum and minimum values of
the function. The absolute extrema of a function are the global maximum and
minimum values of the function over its entire domain.
In Sage Math, the first derivative ofa function can be used to find its relative
extrema.
In Geogebra, the first derivative of a function can also be used to find its relative
extrema. To find the relative extrema of the function f(x) = x^3:
• Create the graph of the function f(x) = x^3.
• Calculate the first derivative of the function using the Tangent tool.
• Find the points where the first derivative is equal to 0 or does not exist to
find the relative extrema of the function.
9
d. Absolute Extrema
To find the absolute extrema of the function, you can evaluate the function at the
endpoints of its domain and compare the values to the values of the function at
the relative extrema.
To find the absolute extrema of the function, you can evaluate the function at the
endpoints of its domain and compare the values to the values of the function at
the relative extrema. To find the absolute extrema of the function f(x) = x^3 over
the interval [-1, 1]:
• Create the graph of the function f(x) FX^3.
• Evaluate the function at the endpoints of the interval-1, 1].
• Find the relative extrema of the function as described above.
• Compare the values of the function at the endpoints and relative extrema
to determine the absolute extrema.
10
Practical 2
Applications of Derivatives I-
Ex-1)
To determine whether the function f(x) = x^2 is increasing
or decreasing on the interval [0, 2] you would do the following:
Code:
Output:
11
b. Concavity and inflection points
Ex-1) To determine the concavity and find the inflection
points of the function f(x) = x^3, you would do the following:
Code:
Output:
12
c. Relative Extrema
Ex-1) To find the relative extrema of the function f(x) = 2x^3-15x^2+36x+10, you would do the
following:
Code:
Output:
13
d. Absolute Extrema
Ex-1) To find the absolute extrema of the function x^4 - 2x^3 over the interval [-2,2]:
Code:
14
Output:
15
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1.How to identify if a function is an increasing function?
2. How to identify if a function is a decreasing function?
3. How to find Maxima of a function?
4. How to find Minima of a function?
16
Theory- 3
Applications of Derivatives II -
a. Analysis of polynomials
In Sage Math, one can use the diff function to find the derivative of a polynomial,
and the solve function to find the critical points.
We can use the second derivative test to determine
whether the critical points correspond to local maxima, minima, or inflection
points.
In Geogebra, one can plot the polynomial and its derivatives using the "Function"
tool, and then use the "Minimum" and "Maximum" tools to find the local extrema.
The critical points can be found by finding the roots of the derivative. The second
derivative can be found by differentiating the derivative and using the second
derivative test to determine the nature of the critical points.
• Sketching the graph of the rational function and its derivatives, including
vertical and horizontal asymptotes, critical points, and inflection points.
• Finding the maximum and minimum values of a rational function on a given
interval, by analyzing its critical points and asymptotes.
• Investigating the behavior of a function near a specific point, by finding its
Taylor polynomial and using that to approximate the function's value.
In Sage Math, one can use the diff function to find the derivative of a rational
function, and the solve function to find the critical points.
In Geogebra, one can plot the rational function using the "Function" tool, and
then use the "Minimum" and "Maximum" tools to find the local extrema. The
critical points and asymptotes can be found by finding the roots of the numerator
and denominator and analyzing the behavior of the function as x approaches
infinity or zero.
17
c. Graphs With Vertical Tangents And Cusps
In Sage Math and Geogebra, derivatives can be used to analyze the behavior of
a function near a vertical tangent or a cusp.
In Sage Math, one can use the diff function to find the first and second
derivatives of a function, and the solve function to find the critical points.
In Geogebra, one can plot the function using the "Function" tool, and then use
the "Tangent" tool to find the vertical tangent. The cusp can be found by
examining the behavior of the function near a critical point, such as finding the
Taylor polynomial of the function and using that to approximate the function's
value near the critical point.
18
d. Newton"s method to find approximate solution of an equation
In Sage Math, one can use the diff function to find the derivative of a function and
the subs function to evaluate the function and its derivative at a specific point.
In Geogebra, one can plot the function using the "Function" tool, and then use
the "Tangent" tool and the "Point" tool to find the tangent line at the initial guess
and the intersection of the tangent line with the x-axis, respectively. The
intersection point can then be used as the next approximation to the solution, and
the process can be repeated until the desired accuracy is achieved.
19
Practical 3
Applications of Derivatives II -
a. Analysis of polynomial
Ex-1) For example, if you have the polynomial f(x) = x^3 + X^2 - 3x + 2, you can find its first
derivative as follows
Code:
Output:
20
b. Graphing rational functions
Ex-1)
For example, if you have the rational function f(x) = (x^2 + 1)/(x^3-2x + 2), you can find its first
derivative as follows:
Code:
Output:
21
Ex-2) To find the vertical and horizontal asymptotes, we need to consider the behavior of the
function as x approaches infinity or zero:
Code:
Output:
22
c. Graphs With Vertical Tangents And Cusps
Ex-1) To plot x^⅓
Code:
23
Output:
24
d. Newton"s method to find approximate solution of an equation
Ex-1)
To find an approximate solution to the equation f(x) = x^2 - 2=0
using Newton's method, we could write:
Code:
25
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. Which function is used to find the derivative of a function?
2. Which function is used to plot the graph?
3. What is critical points of a function?
4. What is the formula of Newton's method?
For Faculty Use
26
Theory- 4
Integration -
In Sage Math and Geogebra, there are two main methods for finding the area
under a curve: the rectangle method and the antiderivative method.
Rectangle Method: This method approximates the area under the curve by
dividing the interval of integration into subintervals and summing the areas
of rectangles inscribed in each subinterval. The height of each rectangle is
the value of the function at the right endpoint of the subinterval.
In Sage Math, one can use the integral function to find the definite integral of a
function, and the linspace function to generate the subintervals.
In Geogebra, one can plot the function using the "Function" tol, and then use
the "Integral" tool with the rectangle method to find the area under the curve.
• Antiderivative Method: This method uses the fundamental theorem of
calculus, which states that the derivative of an antiderivative of a function is
the function itself. In other words, if F is an antiderivative of f, then f= F'.
Given a function f, we can find its antiderivative F and use it to find the
definite integral of f by computing F(b) - F(a), where a and b are the limits
of integration.
In Sage Math, one can use the integral function to find the antiderivative of a
function.
In Geogebra, one can plot the function using the "Function" tool, and then use
the "Integral" tool with the antiderivative method to find the area under the curve.
27
b. Indefinite and definite integrals
In Sage Math and Geogebra, one can find both indefinite and definite integrals of
functions.
Indefinite Integral: An indefinite integral of a function is an antiderivative of
the function, which is a function whose derivative is the original function. In
other words, if F is an indefinite integral of f, then f = F.
In Sage Math, one can use the integral function to find the indefinite integral of a
function.
In Geogebra, one can plot the function using the "Function" tool, and then use
the "Integral" tool to find the indefinite integral of the function.
In Sage Math, one can use the integral function to find the indefinite integral of a
function, and then evaluate it at the limits of integration to find the definite
integral.
In Geogebra, one can plot the function using the "Function" tool, and then use
the "Integral" tool to find the definite integral of the function by specifying the
limits of integration.
c. Properties of integrals
In Sage Math and Geogebra, one can explore and analyze the properties of
integrals.
• Linearity: The definite integral of a sum of two functions is equal to the sum
of the definite integrals of the individual functions. That is, if f(x) and g(x)
are integrable on the interval [a, b], then:
∫_a^b (f(x)+ g(x) dx = ∫_a^b f(x) dx+∫_a^b g(x) dx
This property can be verified by finding the definite integrals of f(x) and g(x)
separately and then adding the results.
This property can be verified by finding the definite integral of f(x) and then
multiplying the result by the constant k.
28
• Additivity: The definite integral of a function over the union of two disjoint
intervals is equal to the sum of the definite integrals of the function over the
individual intervals. That is, if f(x) is integrable on the intervals [a, b] and [c,
d] with b <c, then:
∫_a^d f(x) dx = ∫_a^b f(x) dx + ∫_c^d f(x) dx
This property can be verified by finding the definite integrals of f(x) over the
individual intervals and then adding the results.
In Geogebra, one can plot the functions and use the "Integral" tool to find the
definite integrals of the functions, and then verify the properties by performing the
operations and comparing the results.
In Sage Math, one can use the numerical_integral function to approximate the
definite integral using Simpson's rule. The function takes as input the function to
be integrated, the lower and upper bounds of the interval of integration, and the
number of subintervals to use.
In Geogebra, one can use the "Numeric" tool under the "Calculus" menu to
approximate the definite integral using Simpson's rule. The tool requires the
function to be integrated, the lower and upper bounds of the interval of
integration, and the number of subintervals to use. The result of the approximation
is displayed on the screen and can also be saved in a variable for
further analysis.
29
Practical 4
Output:
30
b. Indefinite and definite integrals
Ex-1)
To find the indefinite integral of f(x) = x^2, we could write:
Code:
Output:
Ex-2)
To find the definite integral of f(x) = x^2 on the
interval [0,2], we could write:
Code:
Output:
31
c. Properties of integrals
Ex-1)
To find the definite integral of f(x) = x^2 on the
interval [0,2], we could write:
Output:
Ex-2)
To find the indefinite integral of f(x) = x^2, we could write:
Code:
Output:
32
d. Numerical integration using Simpson's rule.
Ex-1)
An example using the function f(x) = x^3 integrated over the interval [0, 1]
with 10 subintervals:
Code:
Output:
33
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is Indefinite Integration?
2. What is Definite Integration?
3. Which function is used to find integration of a function?
4. What is the formula of Simpson's Rule?
34
Theory- 5
Applications of Integration -
The area between two curves can be found by finding the definite integral of the
difference of the two functions over the interval that defines the region between
the two curves.
In Sage Math, one can use the numerical integral function to approximate the
area between two curves. The function takes as input the difference of the two
functions to be integrated, the lower and upper bounds of the interval of
integration, and the number of subintervals to use.
In Geogebra, one can plot the two functions and use the "Integral between
curves" tool under the "Calculus" menu to find the area between the curves. The
tool requires the two functions, the lower and upper bounds of the interval of
integration, and the number of subintervals to use. The result of the calculation is
displayed on the screen and can also be saved in a variable for further analysis.
The length of a plane curve can be found using the definite integral of the square
root of the sum of the squares of the first derivatives of the function defining the
Curve.
In Sage Math, one can use the numerical integral function to approximate the
length of a plane curve. The function takes as input the square root of the sum of
the squares of the first derivatives of the function defining the curve, the lower
and upper bounds of the interval of integration, and the number of subintervals to
use.
In Geogebra, one can plot the function defining the curve and use the "Arc
Length" tool under the "Calculus" menu to find the length of the curve. The tool
requires the function defining the curve, the lower and upper bounds of the
interval of integration, and the number of subintervals to use. The result of the
calculation is displayed on the screen and can also be saved in a variable for
further analysis.
35
Practical 5
Applications of Integration -
Code:
Output:
36
Ex-2) To find the area between the curves f(x) = 2x-x^2 and g(x)=x over the interval [0,1].
Code:
Output:
37
b. Length of a plane curve
Ex-1) To find the length of the curve f(x) = x^2 over the interval [0, 1]:
Code:
Output:
Ex-2) Find the arc length of curve y=x^3/2 from (1,1) to (2,√2).
Code:
Output:
38
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. How to find the area under the curve?
2. How to find the integral of a function?
3. Which function is used to find square root of an expression?
4. How to find arc length of curve?
39
Theory- 6
Differential Equations -
The variable separable method for solving first order first degree differential
equations involves separating the variables and integrating both sides to find the
general solution.
In Sage Math, one can use the desolve function from the diffgral package to find
the solution of a first order first degree differential equation using the variable
separable method. The function takes as input the differential equation, the
variable to be solved for, and the independent variable.
In Geogebra, one can use the "Solve Differential Equation" tool under the
"Calculus" menu to find the solution of a first order first degree differential
equation using the variable separable method. The tool requires the differential
equation, the initial condition, and the independent variable. The result of the
calculation is displayed on the screen and can also be saved in a variable for
further analysis.
In Geogebra, one can use the "Solve Differential Equation" tool under the
"Calculus" menu to find the solution of a first order linear differential equation
using the integrating factor method. The tool requires the differential equation,
the initial condition, and the independent variable. The result of the calculation is
displayed on the screen and can also be saved in a variable for further analysis
40
c. Numerical solution of first-order equations using Euler's method.
Euler's method is a numerical method for approximating the solution ofa
first-order differential equation. The method involves approximating the solution
at discrete time points by using the slope of the solution at the previous time
point.
In Sage Math, one can use a loop to implement Euler's method to approximate
the solution of a first-order differential equation.
In Geogebra, one can use the "Numeric" tool under the "Calculus" menu to find
the numerical solution of a first-order differential equation using Euler's method.
The tool requires the differential equation, the initial condition, the step size, and
the number of steps. The result of the calculation is displayed on the screen and
can also be saved in a variable for further analysis.
41
Practical 6
Code:
Output:
42
b. Solution of a first order linear differential equation using integrating
Factor
Ex-1 )To solve the differential equation y' + 2y =x using the integrating factor method:
Code:
Output:
43
c. Numerical solution of first-order equations using Euler's method.
Ex-1)
To solve the differential equation y' = 2x using Euler's method with a step size of 0.1:
Code:
Output:
44
d. Modeling using differential equation
Ex-1)
For example, consider the following differential equation (dydx(x, y) = x + y) that models the
population growth of a species:
Code:
Output:
45
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is differential equation?
2. What is 1st order Differential equation?
3. What is Modelling using a differential equation?
4. What is Euler's method?
46
Theory- 7
The level curves of the function are plotted using the plot_implicit argument of the
plot 3d function, which plots the solutíons to the equation f(x, y) = k for a set of
values of k.
47
Practical 7
Functions of Several Variables -
48
Ex-2) Perform operations on the functions
Code:
Output:
49
Ex-3) Plot Level Curve
Code:
Output:
50
Ex-4) Plot 3d graph
Code:
Output:
51
b. Limits of functions of two or three variables
Ex-1)
Example of finding the limit of a function of two variables in Sage Math:
Code:
Output:
Output:
52
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is a function?
2. How to find limit of a function?
3. How to find continuity of a function?
4. Which function is used to plot 3d graph?
53
Theory- 8
Partial Derivatives I-
The diff method takes the variable with respect to which the derivative is to be taken as
its argument.
The partial derivatives are stored in the variables df dx, df dy, d2f dx2,
d2f dxdy, and d2f dy2. These variables can be used to calculate higher order
partial derivatives ina similar way.
The mixed derivative theorem states that if a function of two or more variables is
continuously differentiable, then the partial derivatives with respect to different variables commute,
i.e., d^2f/dxdy = d^2f/dydx. This theorem can be verified by comparing the values of d2f dxdy and
d2f dy2.
54
Practical 8
Ex-1)
Example of calculating partial derivatives in Sage Math:
Code:
Output:
55
b. Differential for functions of two or three variables
Ex-1) To find derivative of x^2+y^2
Code:
Output:
Output:
56
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is partial derivative of a function?
2. What is 1st Order partial derivative?
3. What is 2nd Order partial derivative?
4. What is Mixed Derivative Theorem?
57
Theory- 9
A Chain Rule for two or three variables states that when differentiating a composite function of
multiple variables, the derivative of the overall function is equal to the product of all of the individual
derivatives. This can be written as:
b. Implicit differentiation
Implicit differentiation is a method of finding the derivative of a function without having to solve for
the function explicitly. It involves differentiating both sides of an equation (implicitly) with respect to
a given variable. The resulting equation is known as the derivative of the implicit function.
dy/dx = (dy/du)(du/dx)
58
c. Directional derivatives and gradient
A directional derivative is a measure of how a multivariable function changes when you move in a
specific direction. It is calculated by taking the dot product of the gradient of the function and the unit
vector of the direction you are moving in. The formula for a directional derivative is:
Df(x,y)/dv = ∇f • v
Where ∇f is the gradient of the function and v is the unit vector of the direction you are moving in.
∇f = (∂f/∂x, ∂f/∂y)
Where ∂f/∂x and ∂f/∂y represent the partial derivatives of the function with respect to x and y,
respectively.
59
Practical 9
Output:
60
b. Implicit differentiation
Ex-1) To find implicit differentiation of √x + √y = √a:
Code:
Output:
61
c. Directional derivatives and gradient
Ex-1)
Here is an example of code in Sage Math for computing the directional derivative
of a function of two variables at a given point in the direction of a given vector:
Code:
Output:
62
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is chain rule?
2. What is the formula of chain rule for 2 variable function?
3. What is the formula of chain rule for 3 variable function?
4. What is directional derivative?
63
Theory- 10
Tangent planes and normal vectors are mathematical tools used to study and measure the behavior of
functions of two or three variables. A tangent plane is a plane that passes through a point on the
surface of a function and is perpendicular to all points on the surface of the function at that point. A
normal vector is a vector that is perpendicular to the tangent plane at a given point on the surface of
the function.
The formula for a tangent plane at a point (x, y, z) on the surface of a function f(x, y, z) is:
Where a, b, and c are constants determined by taking the partial derivatives of the function f with
respect to x, y, and z respectively.
The formula for a normal vector at a point (x, y, z) on the surface of a function f(x, y, z) is:
Where ∂f/∂x, ∂f/∂y, and ∂f/∂z are the partial derivatives of the function f with respect to x, y, and z
respectively.
To find Tangent Planes and Normal Vectors for functions of two or three
Variables
1. Open Geogebra and create a function of two or three variables.
2. Select the point at which you want to find the tangent plane and normal vector.
3. Select the “Calculus” tool from the toolbar.
4. Select the “Tangent Plane” option from the “Calculus” menu.
5. Enter the coordinates of the point at which you want to find the tangent plane and normal vector.
6. Geogebra will display the tangent plane and normal vector at the specified point.
64
b. Maxima and Minima of Functions of Two Variables
Maxima and minima of functions of two variables are points where the function takes on an extreme
value, either a minimum or a maximum.
The formulas for finding these points are known as the first and second derivatives.
The first derivative is used to find the critical points of a function.
The critical points of a function are the points where the function changes direction, either increasing
or decreasing.
The second derivative is used to determine if the critical points are maxima or minima. If the second
derivative is positive, then the critical points are maxima.
If the second derivative is negative, then the critical points are minima.
To find the maxima and minima of a function of two variables in Sage Math, you
can use the following steps:
• Define the function of two variables: You need to define the function that you
want to find the maxima and minima of. For example, f(x, y) = x^2 + y^2.
• Find partial derivatives: You need to find the partial derivatives of the function
with respect to x and y. For the example above, the partial derivatives would be
df/dx = 2x and df/dy = 2y.
• Find critical points: The critical points of the function are the points where the
partial derivatives are equal to zero. You can solve the equations df/dx = 0 and
df/dy = 0 to find the critical points. For example, the critical points of f(x, y) = x^2
+ y^2 would be (0, 0).
• Evaluate the function at the critical points: You can evaluate the function at the
critical points to find the values of the maxima and minima.
65
Practical 10
a. Tangent Planes and Normal Vectors for functions of two or three Variables
Ex-1)To plot a function of two variables and find its tangent plane and normal vector at a point:
Code:
Output:
66
b. Maxima and Minima of Functions of Two Variables
Ex-1) To find Maxima and Minima of f(x,y) = x^3 + y^3 - 6xy
Code:
Output:
67
Result and Discussion :
Learning outcome :
Course outcome :
Conclusion :
Viva Questions :
1. What is tangent plane?
2. What is critical points?
3. What is Maxima of a function?
4. What is Minima of a function?
68