Trading Dev AcademyFree quant education

Free lesson · Partial derivatives

Constrained optimisation and multiple integrals

Open interactive lessonPractice calculationsExplore labs

Start with the idea

  • Constraints restrict the directions you are allowed to move.
  • Multiple integrals accumulate over more than one coordinate.
  • Both ideas require an explicit region: the feasible set for optimisation or the domain of integration.
Symbols, units & horizon
  • f(x,y): objective
  • g(x,y)=c: equality constraint
  • λ: Lagrange multiplier, not a probability
  • 𝓛: Lagrangian
  • ∇: gradient with respect to the decision variables
  • dy then dx: integrate y first, then x
  • c: fixed constraint level
  • Rectangle: x in [0,1], y in [0,2]

When and why to use this

Use constrained optimisation when resources or exposures must satisfy a rule; use multiple integrals for totals or expectations across continuous multidimensional regions.

  • At a regular equality-constrained optimum, the objective gradient can align with the constraint gradient.
  • A Lagrange multiplier records that alignment; it is not a free extra parameter to choose by intuition.
  • Inequality constraints require additional conditions such as feasibility and complementary slackness.
  • For a continuous function on a rectangle, an iterated integral integrates one variable while holding the other fixed, then integrates the remaining expression.
  • More general regions may have variable bounds.
  • Changing order requires appropriate integrability conditions and correctly redrawn bounds.
ℒ=f−λ(g−c),∇f=λ∇g,g=c;∫01∫02(x+y)dydx=3
Calculus: derivation and arithmetic

Constrained optimisation and multiple integrals

  1. Minimise f=x²+y² with g=x+y=1. Stationarity gives 2x=λ and 2y=λ. Thus x=y, and the constraint gives x=y=.5.
  2. Along the constraint y=1−x, the objective is x²+(1−x)²=2(x−.5)²+.5. This proves the candidate is the global minimum, not merely a stationary point.
  3. For the double integral, integrate x+y over y from 0 to 2 to get 2x+2. Integrating over x from 0 to 1 gives [x²+2x]₀¹=3.
Work it by hand

The constrained minimum is .5 at (.5,.5). The point (0,0) has smaller objective zero but is infeasible. The double integral is 3 over an area of 2, so the average value on that rectangle is 1.5.

An analogy to remember

A hiker tied to a fixed-length route cannot follow every downhill direction. Likewise, a total measured over a field must account for both its width and its length.

How this becomes a building block

Budget and exposure constraints are part of portfolio allocation, while joint-density integrals compute multi-factor expectations. The multiplier method and the integral are distinct tools that may both appear inside a larger investment model.

For current applications and implementation limits, see the research checkpoint in Differential Equations.

Research sources, review dates and limitations

Extend the research question

Change spot and volatility together, then compare the joint response with a one-factor sensitivity. Identify the assumptions used when holding other inputs fixed.

Continue with the connected research module →

Connect the ideas: Sensitivity and approximation

Retrieve: A local sensitivity describes how a model responds near a specified input.

Check the change: The input, its units and what is held fixed differ across slope, duration and option sensitivities.

Differential calculus → Rates, credit & macro → Stochastic calc → Options → Volatility

Explain it yourself: What must you check before using a small-move approximation for a large scenario?

Self-assessed. Write your explanation before opening this comparison.

Check the expansion point, units, held-fixed inputs, curvature and model domain; compare with a full repricing under the same scenario.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def minimum_squared_sum(total):
    x=y=total/2
    return x,y,x*x+y*y

def integral_x_plus_y(x0,x1,y0,y1):
    return .5*(x1*x1-x0*x0)*(y1-y0)+.5*(y1*y1-y0*y0)*(x1-x0)

print(minimum_squared_sum(1),integral_x_plus_y(0,1,0,2))

Continue learning

Multivariable Calculus & Partial Derivatives — all lessons
  1. Start with two inputs: change only one
  2. Partial derivatives: holding the other inputs fixed
  3. Gradients, directional derivatives and Jacobians
  4. Hessians, mixed derivatives and second-order scenarios
  5. Constrained optimisation and multiple integrals

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations