Mathematical Foundations

Chapter 10
Differential and Integral Calculus

Bachelors Program in Computer Applications
Mathematical Foundations   •   Bachelor

Differential and Integral Calculus

Introduction

Calculus is the mathematics of change and accumulation. In computer applications, it supports numerical optimization, simulation, graphics, data analysis, probability models, machine learning, and the study of algorithms whose behavior changes over time. Differential calculus describes instantaneous rates of change, while integral calculus describes accumulated quantities. Together they provide a language for analyzing continuous systems and approximating discrete computational processes.

A central idea is the limit. A limit formalizes what happens to a function as its input approaches a value, even when the function is not evaluated exactly at that value. Limits provide the foundation for continuity, derivatives, and definite integrals.

Learning Objectives

After completing this chapter, a student should be able to:

  • explain limits and continuity and evaluate common limits;
  • define and calculate derivatives using rules and first principles;
  • interpret derivatives as rates, slopes, sensitivities, and marginal changes;
  • apply differentiation to optimization and related-rate problems;
  • calculate and interpret partial derivatives and gradients;
  • explain definite and indefinite integration and the Fundamental Theorem of Calculus;
  • use substitution and basic numerical integration;
  • understand multivariable change, the chain rule, and the Jacobian;
  • connect calculus with optimization, simulation, and learning algorithms;
  • recognize assumptions, numerical limitations, and responsible-use issues.

1. Functions and Limits

A function assigns each permitted input exactly one output. In y = f(x), x is the independent variable and y is the dependent variable. The domain is the set of permitted inputs; the range is the set of resulting outputs.

The limit limx→a f(x) = L means that the values of f(x) can be made arbitrarily close to L by taking x sufficiently close to a, from either side. The function need not be defined at a. A two-sided limit exists only when the left-hand and right-hand limits exist and are equal.

For many functions, direct substitution evaluates a limit. For example,

limx→2(x² + 3x) = 2² + 3(2) = 10

If substitution produces an indeterminate form such as 0/0, algebraic simplification may reveal the limit:

limx→3 (x² − 9)/(x − 3)
= limx→3 [(x − 3)(x + 3)]/(x − 3)
= limx→3(x + 3) = 6

The original expression is undefined at x = 3, but its limit exists.

Important limit laws, when the individual limits exist, include

lim(f ± g) = lim f ± lim g
lim(fg) = (lim f)(lim g)
lim(f/g) = (lim f)/(lim g), provided lim g ≠ 0

The squeeze theorem states that if g(x) ≤ f(x) ≤ h(x) near a and both outer functions approach L, then f(x) also approaches L. This is useful for oscillating functions and numerical bounds.

Continuity

A function is continuous at x = a when:

  1. f(a) is defined;
  2. limx→a f(x) exists;
  3. limx→a f(x) = f(a).

Polynomial and exponential functions are continuous on their domains. Rational functions are continuous wherever their denominators are nonzero. Discontinuities may be removable, jump, or infinite. Continuity matters computationally because small input changes then produce small output changes, although continuity alone does not guarantee numerical stability.

2. Derivatives and Rates of Change

The derivative measures instantaneous change. It is defined from the slope of a secant line as the interval becomes infinitesimally small:

f′(a) = limh→0 [f(a + h) − f(a)]/h

Here h is an input change. The derivative exists only if this limit exists and is finite. Geometrically, f′(a) is the slope of the tangent line at a. If s = f(t) is position in metres and t is time in seconds, then f′(t) has units metres per second and represents velocity.

The tangent line at x = a is

y = f(a) + f′(a)(x − a)

This is also the basis of local linear approximation.

Basic differentiation rules

Assume the functions are differentiable on the relevant domain and c is constant.

Function or ruleDerivative
Constantd(c)/dx = 0
Powerd(xⁿ)/dx = nxⁿ⁻¹
Constant multipled(cf)/dx = cf′
Sum or differenced(f ± g)/dx = f′ ± g′
Product(fg)′ = f′g + fg′
Quotient(f/g)′ = (gf′ − fg′)/g², g ≠ 0
Composition(f(g(x)))′ = f′(g(x))g′(x)

Common derivatives include

d(sin x)/dx = cos x
d(cos x)/dx = −sin x
d(eˣ)/dx = eˣ
d(ln x)/dx = 1/x, x > 0

For y = (3x² + 1)5, the chain rule gives

dy/dx = 5(3x² + 1)4 × 6x = 30x(3x² + 1)4

Higher derivatives and interpretation

The second derivative f″(x) measures the change of the rate of change. For position, it represents acceleration. If f″(x) > 0, the graph is concave upward; if f″(x) < 0, it is concave downward. Higher derivatives are used in approximation, motion models, and numerical methods.

A critical point occurs where f′(x) = 0 or where the derivative does not exist. It may be a local maximum, local minimum, or neither. The first-derivative test examines changes in sign of f′. The second-derivative test states that if f′(a) = 0 and f″(a) > 0, then a is a local minimum; if f″(a) < 0, it is a local maximum. If f″(a) = 0, the test is inconclusive.

Worked example: optimization

Suppose a rectangular data-storage enclosure has fixed perimeter 40 cm. If its length is x cm, its width is 20 − x cm, with 0 < x < 20. Its area is

A(x) = x(20 − x) = 20x − x²
A′(x) = 20 − 2x

Setting A′(x) = 0 gives x = 10. Since A″(x) = −2 < 0, the area is maximized. The width is also 10 cm and the maximum area is 100 cm². The result depends on the assumptions of a rectangular shape, fixed perimeter, and continuous dimensions.

3. Applications of Derivatives

Related rates

When variables depend on time, differentiating a constraint with respect to time connects their rates. For a circle, A = πr². If radius changes at dr/dt = 0.4 m/s, then

dA/dt = 2πr(dr/dt)

At r = 5 m, the area increases at 2π(5)(0.4) = 4π m²/s, approximately 12.57 m²/s.

Sensitivity and marginal analysis

If output is y = f(x), a small change ∆x produces the approximation

∆y ≈ f′(x)∆x

The derivative is a local sensitivity measure. In computing, this helps estimate how errors in an input affect output, but nonlinear functions may require smaller changes or higher-order analysis.

Newton’s method

To approximate a root of f(x) = 0, Newton’s iteration is

xn+1 = xn − f(xn)/f′(xn)

It requires a differentiable function and a nonzero derivative at each iterate. Convergence can be rapid near a suitable root, but poor initial values, zero derivatives, or multiple roots can cause divergence.

4. Partial Derivatives and Multivariable Functions

A multivariable function maps several inputs to an output, such as z = f(x,y). The partial derivative with respect to x holds y constant:

∂f/∂x = limh→0 [f(x + h,y) − f(x,y)]/h

Similarly, ∂f/∂y holds x constant. For f(x,y) = x²y + 3y,

∂f/∂x = 2xy
∂f/∂y = x² + 3

The gradient is

∇f = [∂f/∂x, ∂f/∂y]

It points in the direction of greatest local increase, and its magnitude is the maximum rate of increase per unit distance. A level curve consists of points satisfying f(x,y) = c. The gradient is perpendicular to a level curve when the gradient is nonzero.

The total differential approximates change:

df ≈ (∂f/∂x)dx + (∂f/∂y)dy

For a function z = f(x,y), the multivariable chain rule applies when x = x(t) and y = y(t):

dz/dt = (∂f/∂x)(dx/dt) + (∂f/∂y)(dy/dt)

Optimization in several variables

An interior stationary point satisfies ∇f = 0. For a twice-differentiable function of two variables, define

D = fxxfyy − (fxy)²

At a stationary point, D > 0 and fxx > 0 indicate a local minimum; D > 0 and fxx < 0 indicate a local maximum; D < 0 indicates a saddle point. When D = 0, the test is inconclusive. Boundary constraints require separate analysis, often using parameterization or Lagrange multipliers.

Jacobian and change of variables

For a transformation from (u,v) to (x,y), the Jacobian is

J = ∂(x,y)/∂(u,v) = | xu xv |
| yu yv |

Its determinant is xu yv − xv yu. In double integration, provided the transformation is differentiable and one-to-one on the region,

dA = |J| du dv

The absolute value accounts for area scaling. For polar coordinates x = r cos θ and y = r sin θ, |J| = r, so dA = r dr dθ.

5. Integral Calculus

An indefinite integral represents a family of antiderivatives:

∫f(x)dx = F(x) + C, where F′(x) = f(x)

C is an arbitrary constant because derivatives of constants are zero. Basic rules include

∫xⁿdx = xⁿ⁺¹/(n + 1) + C, n ≠ −1
∫1/x dx = ln|x| + C
∫eˣ dx = eˣ + C
∫cos x dx = sin x + C

A definite integral is a signed accumulation over an interval. If f is integrable on [a,b]],

∫ab f(x)dx

represents net area when f is nonnegative, and signed area in general. Units are the product of the units of f and x. Thus integrating litres per minute over minutes produces litres.

Fundamental Theorem of Calculus

If F′(x) = f(x) and f is continuous on [a,b]], then

∫ab f(x)dx = F(b) − F(a)

Also, if G(x) = ∫ax f(t)dt and f is continuous, then G′(x) = f(x). This theorem links accumulation and rates of change.

Worked example: accumulated data

A sensor records data transfer at the rate r(t) = 2t + 5 megabytes per second for 0 ≤ t ≤ 10. The total transferred data is

∫010 (2t + 5)dt = [t² + 5t]010 = 100 + 50 = 150 MB

The calculation assumes the rate is accurately modeled by the stated continuous function and that the time unit is seconds.

Integration techniques

Substitution reverses the chain rule. If u = g(x) and du = g′(x)dx, then

∫f(g(x))g′(x)dx = ∫f(u)du

Integration by parts follows from the product rule:

∫u dv = uv − ∫v du

It applies when the integrand can be usefully split into u and dv. Improper integrals require limits, for example when an interval is unbounded or the integrand is unbounded.

Numerical integration

When an antiderivative is unavailable or data are given only as samples, numerical methods estimate an integral. With interval width h = (b − a)/n, the composite trapezoidal rule is

Tn = h[½f(x0) + f(x1) + ⋯ + f(xn−1) + ½f(xn)]

where xi = a + ih. For a twice continuously differentiable function, its error satisfies

|ET| ≤ [(b − a)h²/12] max|f″(x)| on [a,b]

This is an error bound, not necessarily the exact error. Smaller intervals generally improve accuracy but increase computation.

6. Calculus in Computing and Learning Algorithms

Many computational problems minimize a loss function. For parameters collected in θ and loss L(θ), gradient descent updates parameters by

θk+1 = θk − η∇L(θk)

Here η > 0 is the learning rate and k is the iteration index. The update moves opposite the gradient, the local direction of greatest increase. It is effective under appropriate smoothness and learning-rate conditions, but it may converge to a local minimum, saddle region, or an unsatisfactory point. In stochastic gradient descent, the gradient is estimated from a mini-batch, introducing noise that can improve efficiency but complicate convergence.

For a linear model ŷ = wᵀx + b with squared loss for one observation,

L = ½(ŷ − y)²

where x is the feature vector, w the weight vector, b the bias, and y the target. Since ∂L/∂w = (ŷ − y)x and ∂L/∂b = ŷ − y, gradients indicate how parameter changes affect prediction error. The factor ½ simplifies derivatives and does not change the minimizing parameters.

Automatic differentiation computes derivatives of composed programs by applying the chain rule systematically. It differs from symbolic algebra, which seeks an explicit formula, and from numerical finite differences, which approximate derivatives using function evaluations. Finite differences can suffer from truncation and round-off error; automatic differentiation is often more accurate but requires compatible computational representations.

7. Illustrative Case: Optimizing a Cloud-Service Configuration

Background. A software team must choose a server allocation for an API. Increasing capacity reduces response delay but increases operating cost.

Problem. An illustrative performance model gives average delay

D(c) = 120/c + 4 milliseconds for capacity c > 0, while daily cost is C(c) = 18c monetary units. The team uses the combined objective

J(c) = D(c) + 0.1C(c) = 120/c + 4 + 1.8c

The coefficient 0.1 expresses a chosen trade-off between delay and cost; it is not universal.

Analysis. Differentiate:

J′(c) = −120/c² + 1.8

Set the derivative to zero:

−120/c² + 1.8 = 0
c² = 120/1.8 = 66.6667
c ≈ 8.165

Because J″(c) = 240/c³ > 0 for c > 0, this is a minimum for the continuous model. If servers must be whole units, the team compares nearby values, such as 8 and 9, and also checks service-level constraints.

Approach and outcome. The continuous optimum provides a decision guide, not an automatic deployment choice. Measurements should validate the delay model, and the result should be stress-tested under workload variation. Security, redundancy, energy use, and fairness of service must also be considered.

Learning points. Derivatives support trade-off analysis; constraints and discrete decisions require additional evaluation; a mathematically optimal result is only as reliable as its model and objective weights.

8. Limitations, Responsible Use, and Best Practices

Calculus models continuous change, whereas software operates with finite precision, discrete time, and bounded resources. Derivatives may fail at discontinuities, corners, or non-differentiable activation functions. A local optimum is not necessarily globally optimal. Numerical integration and differentiation introduce approximation error, and ill-conditioned problems can magnify small data errors.

In AI and analytics, gradients can optimize a chosen loss while ignoring social costs, privacy, bias, or distributional harm. Practitioners should document assumptions, units, parameter scales, data provenance, objective weights, and stopping criteria. They should distinguish a mathematical model from observed reality, report uncertainty, test sensitivity, and retain human oversight for consequential decisions. Reproducible code, independent checks, boundary analysis, and comparison with measured outcomes are essential professional practices.

Chapter Summary

Limits describe function behavior near a point and establish continuity. A derivative is the limit of an incremental ratio and represents instantaneous rate, tangent slope, or sensitivity. Differentiation rules, optimization tests, related rates, and Newton’s method provide practical tools for one-variable analysis. Partial derivatives and gradients extend these ideas to several variables; the chain rule and Jacobian describe composite change and coordinate transformations. Integration measures accumulation, while the Fundamental Theorem connects integration with differentiation. Substitution, integration by parts, and numerical quadrature broaden the methods available in practice. Calculus underlies gradient-based learning and computational modeling, but results depend on assumptions, numerical precision, objective design, and responsible interpretation.

Key Terms

Limit: The value a function approaches as its input approaches a specified point.

Continuity: A property in which the function value equals its limit at a point.

Derivative: The instantaneous rate of change of a function.

Tangent line: The local linear line whose slope is the derivative.

Chain rule: A rule for differentiating a composition of functions.

Critical point: A point where the derivative is zero or does not exist.

Concavity: The direction in which a graph bends, indicated by the second derivative.

Optimization: Finding a maximum or minimum subject to stated conditions.

Partial derivative: A derivative with respect to one variable while others are held constant.

Gradient: The vector of first partial derivatives.

Level curve: A set of points at which a multivariable function has constant value.

Jacobian: A determinant describing local scaling under a coordinate transformation.

Antiderivative: A function whose derivative is the given integrand.

Definite integral: Signed accumulated value over an interval.

Indefinite integral: A family of antiderivatives plus an arbitrary constant.

Fundamental Theorem of Calculus: The theorem linking derivatives and definite integrals.

Numerical integration: Approximation of an integral using computed samples.

Gradient descent: An iterative method that moves opposite a loss gradient.

Automatic differentiation: Programmatic evaluation of derivatives using the chain rule.

Conditioning: The sensitivity of a problem’s output to small input changes.

Review Questions

5 Short Answer Questions

  1. What conditions must hold for a function to be continuous at a point?
  2. Define the derivative using a limit.
  3. What does a gradient represent geometrically?
  4. Distinguish an indefinite integral from a definite integral.
  5. Why is the learning rate important in gradient descent?

5 Long Answer Questions

  1. Explain the relationship among limits, continuity, and differentiability, including a case in which one property does not imply another.
  2. Derive and interpret the product and chain rules, and illustrate each with an example.
  3. Explain partial derivatives, total differentials, gradients, and the multivariable chain rule.
  4. State and apply the Fundamental Theorem of Calculus to an accumulation problem.
  5. Compare symbolic differentiation, finite differences, and automatic differentiation in computational work.

3 Analytical / Application Questions

  1. A function models computing cost as a continuous function of workload. Propose a derivative-based method to find a cost-minimizing operating point and identify assumptions that must be tested.
  2. For f(x,y) = x² + 4xy + y², calculate the gradient and classify the stationary point using the Hessian test.
  3. A sensor provides rate measurements at equally spaced times but no closed-form model. Design a numerical integration procedure, identify a suitable error check, and explain how measurement noise affects the result.

Multiple Choice Questions with Answers

Question 1

What does f′(a) represent geometrically?

A. The area under the curve

B. The slope of the tangent at x=a

C. The average value of the function over all inputs

D. The function’s maximum value

Correct Answer: B. The slope of the tangent at x=a

Question 2

If f(x)=x³−2x, what is f′(x)?

A. 3x²−2

B. x²−2

C. 3x−2

D. x³−2

Correct Answer: A. 3x²−2

Question 3

For f(x,y)=x²y+3y, what is ∂f/∂y?

A. 2xy

B. x²+3

C. x²y

D. 2x+3

Correct Answer: B. x²+3

Question 4

Evaluate ∫02 3x² dx.

A. 3

B. 4

C. 8

D. 12

Correct Answer: C. 8

Question 5

Which condition indicates a local minimum in the one-variable second-derivative test?

A. f′(a)=0 and f″(a)<0

B. f′(a)>0 and f″(a)=0

C. f′(a)=0 and f″(a)>0

D. f(a)=0 and f″(a)<0

Correct Answer: C. f′(a)=0 and f″(a)>0

Question 6

In gradient descent, the usual update is

A. θk+1=θk+η∇L

B. θk+1=θk−η∇L

C. θk+1=η−θk∇L

D. θk+1=θk/η

Correct Answer: B. θk+1=θk−η∇L

Question 7

What factor appears in the area element when converting to polar coordinates?

A. 1/r

B. r²

C. r

D. 2πr

Correct Answer: C. r

Question 8

If s(t) is position measured in metres and t in seconds, the units of s′(t) are

A. metres

B. seconds per metre

C. metres per second

D. metres per second squared

Correct Answer: C. metres per second

Question 9

Newton’s method is primarily used to approximate

A. roots of equations

B. areas without function values

C. units of measurement

D. partial derivative notation

Correct Answer: A. roots of equations

Question 10

The trapezoidal rule estimates an integral by using

A. only the maximum function value

B. rectangular or trapezoidal approximations from sampled values

C. the derivative at one endpoint only

D. a random value independent of interval width

Correct Answer: B. rectangular or trapezoidal approximations from sampled values

Mathematical Foundations
Chapter 10 of 15