Functions of two variables

12 min · 1 drill

In the textbook: Ch. 8 Analysis von Funktionen mit zwei Variablen

Until now a function had one variable, a number we change: for cost, the quantity. However many pieces are made, that decides the cost. In real life a result often depends on two things at once. Then the function has two variables, and a single derivative is no longer enough. This article shows how to read such functions and how to tell which of the two variables moves the result more.

Imagine a small bakery. How much bread it bakes in a day depends on two things: how many bakers it has and how many ovens. One does not work without the other: a baker without an oven has nowhere to bake, and an oven without a baker stays cold.

Right now the bakery has 4 bakers and 9 ovens and bakes 60 loaves a day. The owner wants to bake more. Her money covers one of two things:

  • hire one more baker;
  • or buy one more oven.

Which should she choose? To answer, she tries both options one after the other, and each time she changes only one thing:

BakersOvensLoaves a day
4960
5967
41063

The fifth baker, with the same ovens, gives 7 extra loaves. The tenth oven, with the same bakers, gives only 3. Now the owner has something to compare: if a baker costs no more than two ovens, hiring the baker pays off.

This very step is the core of the chapter. When a result depends on two quantities, you leave one as it is and look at what a change in the other brings. The increase you get this way is called the partial derivative: “partial” because only one of the variables changes. Below you learn to compute it with a formula instead of a table, and what else it solves in the exam: how much of one input replaces another and how best to spend a given budget.

In the exam only the setting changes:

In this articleIn the exam
a bakerya plant, a farm or a shop
bakers and ovenslabour and capital or two goods

The questions are the same ones the owner asked herself. Derivatives of functions of one variable (power rule, ex, ln⁡x, chain rule) are explained in the article “What the derivative is: slope and the rules”. After this article you can:

  • find the value f(x,y) at a point;
  • find a partial derivative;
  • find the second derivatives;
  • read a level curve;
  • find the slope of a level curve;
  • find the maximum under a constraint, for example with a given budget.

The function of two variables

The bakery from the start gave the output for only three combinations of bakers and ovens. To get it for any combination the relationship is written as a formula. That is done for any kind of production, not only for the bakery. The output of a factory depends on the number of workers and on the number of machines. Such a dependence is written as a function of two variables: f(x,y) takes two numbers and gives back one. An example: f(x,y)=x⋅y. At the point (2,3) the value is f(2,3)=2⋅3=6. The first number in the brackets is always x, the second y.

The values are easy to show in a table:

y=1y=2y=4
x=1124
x=2248
x=44816

If you put a column of height f(x,y) over every point (x,y) of the floor, the tops of the columns form a surface, like a landscape. You do not have to draw it in the exam. You need two moves: slice the surface along one axis (that is the partial derivative) and look at it from above like a height map (those are the level curves).

Partial derivative: hold one variable fixed

The bakery owner already made the first of the two moves when she kept the ovens as they were and added a baker. On the surface this is a slice along one axis. Hold y=2 fixed. Then f(x,2) is a function of the one variable x, a slice through the surface. Its slope is the partial derivative with respect to x (“partielle Ableitung”), written fx or ∂f∂x. The rule: differentiate with respect to x as usual and treat y as a number. For fy the other way round.

For this you need two rules for one variable, both from the article on the derivative:

  • The derivative of a sum is the sum of the derivatives. Example: (x2+3x)′=2x+3.
  • A constant factor stays, a number without a variable gives 0. Example: (5x)′=5, (7)′=0.

In the partial derivative, “number” also means the other variable. An example with respect to x: (5y⋅x)x=5y, but (3y)x=0, because there is no x in 3y.

The function f(x,y)=x2y+3y at the point (1,2):

fx=2xy,fx(1,2)=4;fy=x2+3,fy(1,2)=4

For fx the number is y: the factor y stays, (x2)′=2x, and the term 3y, which has no x, gives 0. For fy the number is x: the factor x2 stays, (y)′=1, and (3y)′=3.

Back to the bakery from the start of the article. Its output is described by this formula:

Q(L,K)=10⋅L⋅K

Here L stands for bakers, K for ovens and Q for loaves a day: Q(4,9)=10⋅2⋅3=60. The partial derivatives at the point (4,9):

QL=5KL=5⋅32=7.5,QK=5LK=5⋅23≈3.3

That gives 7.5 and 3.3 loaves. In the introduction the owner counted 7 and 3 when she added a whole baker and a whole oven. The partial derivative shows how fast output grows at the point itself, which is why the numbers differ a little.

What the number means: if x grows by 1 and y stays the same, f grows by about fx. For output this quantity is called the marginal product (“Grenzproduktivität”).

Your turn1 of 1

Given f(x,y)=x3y2+4xy−5y. What is fx at the point (1,2)?

Second-order partial derivatives

A partial derivative can be differentiated once more. For f=x2y+3y this gives:

  • fx=2xy differentiated again with respect to x gives 2y, with respect to y gives 2x;
  • fy=x2+3 gives 0 with respect to y and 2x again with respect to x.

This gives fxx (twice with respect to x), fyy (twice with respect to y) and the mixed one fxy (first with respect to x, then y). Both mixed ones came out as 2x: for the functions in the exam the order does not matter, fxy=fyx. All together:

fxx=2y,fyy=0,fxy=(2xy)y=2x,fyx=(x2+3)x=2x

The four numbers go into a 2×2 table, the Hessian matrix (“Hesse-Matrix”) H: fxx and fyy on the diagonal, the mixed fxy twice, off it. At the point (1,2) we get fxx=2⋅2=4, fyy=0 and fxy=2⋅1=2:

H(1,2)=(fxxfxyfxyfyy)=(4220)

The next section reads the Hessian to tell a peak, a pit and a saddle apart.

Peak, pit, saddle

Where both partial derivatives are zero the surface is flat, but a peak, the bottom of a pit and a mountain pass are all flat. The second derivatives from the previous section help to tell them apart. Compare three surfaces over the point (0,0):

  • u=−x2−y2;
  • v=x2+y2;
  • w=x2−y2.

For all three, both partial derivatives are 0 there. For example, wx=2x and wy=−2y give 0 and 0 at (0,0). A point where fx=0 and fy=0 both hold is called a stationary point (“stationärer Punkt”). But the surfaces over it look different.

Which case it is shows in the number D=fxxfyy−(fxy)2, the determinant of the Hessian. You multiply fxx by fyy and subtract the square of the mixed fxy.

  • If D<0, the surface goes up in one direction and down in the other: a saddle.
  • If D>0, both directions go the same way: a peak or a pit.
u=−x2−y2v=x2+y2w=x2−y2
along the x-axis (y=0)−x2: down on both sidesx2: upx2: up
along the y-axis (x=0)−y2: downy2: up−y2: down
second derivatives (twice in x, twice in y, mixed)−2, −2, 02, 2, 02, −2, 0
determinant D44−4
what lies at (0,0)peak, maximumpit, minimumsaddle

A saddle (“Sattelpunkt”) is like a mountain pass: in one direction the point is the lowest, in the other the highest, so it is neither a maximum nor a minimum. The determinant D of the Hessian tells the three cases apart: with D<0 it is a saddle; with D>0 a peak if fxx<0 and a pit if fxx>0. How this is used in tasks is shown in the method “Extrema in two variables and maximum profit”.

Level curves

Look at the surface from above. All points with the same height, f(x,y)=c, form a level curve (“Niveaulinie”, “Höhenlinie”), like the contour lines on a map. Take f=xy again: its level curve 4 passes through (1,4), (2,2) and (4,1). In the table of values of f=xy in the section “The function of two variables” these are all the cells with the number 4. The figure shows three level curves, xy=2, xy=4 and xy=8; the further from the origin, the higher.

Height map of f = xy: level curves 2, 4 and 8124124xy(2, 2)xy = 2xy = 4xy = 8

In economics level curves have their own names:

  • Isoquant (“Isoquante”): all combinations of inputs with the same output, for example all combinations of workers and machines that give 100 pieces a day.
  • Indifference curve (“Indifferenzkurve”): all combinations of two goods with the same utility, for example bread and milk that please a buyer equally.
  • Budget line (“Budgetgerade”) pxx+pyy=B, with the prices px and py of the goods: all combinations that cost exactly the budget B, for example with B=8 € and prices 2 € and 1 € the combinations (2,4) and (3,2).

The total differential

For f=x2y+3y at the point (1,2) we still have fx=4 and fy=4. We write the changes as dx=0.1 and dy=−0.2: x grows by 0.1, y falls by 0.2. The contribution of each move is worked out separately:

  • the move in x changes f by about fx⋅dx=4⋅0.1=0.4;
  • the move in y changes it by about fy⋅dy=4⋅(−0.2)=−0.8;
  • together 0.4−0.8=−0.4.

Exactly: f(1.1,1.8)=1.21⋅1.8+3⋅1.8=2.178+5.4=7.578, and 7.578−8=−0.422, close.

It always works like this: if both variables change, their contributions add up. Moving x by dx gives about fx dx, moving y by dy gives about fy dy. The sum is called the total differential (“totales Differential”):

df≈fx dx+fy dy

The slope of the level curve

Along a level curve f does not change, so df=0. The total differential gives the slope of the curve without writing y in terms of x:

dydx=−fxfy(fy≠0)

On the curve xy=4 at the point (2,2) the partial derivatives are fx=y=2 and fy=x=2, the slope is −22=−1. Check: on this curve y=4x, the derivative is −4x2, at x=2 that is −1.

The ratio fxfy, the slope of the level curve without the minus, says how many units of y one unit of x replaces. On the isoquant it is called the marginal rate of technical substitution (“Grenzrate der technischen Substitution”, GRS), on the indifference curve the marginal rate of substitution (“Grenzrate der Substitution”).

Maximum under a condition

The bakery owner's money was enough for only one thing, a baker or an oven. That is almost always so: the choice is limited by money. The best choice within that limit is found from the level curves and their slope. A buyer has 8 € for two goods, one unit of x costs 2 €, one unit of y costs 1 €, and the utility U(x,y)=x⋅y measures how good a bundle is. Which bundle should he choose?

Money limits the choice: only bundles on the budget line 2x+y=8 qualify. Such an equation is called a condition or constraint (“Nebenbedingung”). Without it there is no answer: the more of both goods, the higher U.

The figure shows the line and three indifference curves:

The curve xy = 8 touches the budget line at (2, 4)4824xybest bundle (2, 4)xy = 4xy = 8xy = 12budget 2x + y = 8
  • The curve xy=4 crosses the line twice: these bundles are affordable, but a higher curve is within reach.
  • The curve xy=12 does not reach the line: such bundles are too expensive.
  • The best curve within reach touches the line at one point. There the slopes of the curve and the line are equal.
  1. Slope of the indifference curve by the formula from the section “The slope of the level curve”: −UxUy=−yx.
  2. Slope of the line: −21.
  3. Equal slopes: yx=2, that is y=2x.
  4. Into the budget: 2x+2x=8, x=2, y=4, utility U=2⋅4=8.

This holds in general: at the optimum under a condition the level curve of the goal f touches the line of the condition, and the slopes agree. For a budget with prices px and py this is

fxfy=pxpy

On the left is the marginal rate of substitution, on the right the price ratio. The method “The Lagrange method and implicit functions” writes this condition down step by step. It also covers other conditions, such as a set output or two plants.

The topic in a minute

  • Value at a point f(x,y): put in both numbers. Trap: swapping the order; f(1,2) means x=1, y=2.
  • Partial derivative fx: the derivative with respect to x, with y treated as a number. Example: (x2y)x=2xy. Trap: differentiating y as well.
  • A sum term by term: (u+v)x=ux+vx, a term without x gives 0. Common mistake: writing 4 or 0, while (4xy)x=4y.
  • Second derivatives fxx, fyy, the mixed one fxy=fyx. Trap: the mixed one is forgotten.
  • Level curve f(x,y)=c: a curve in the x-y plane on which the value stays the same (isoquant, indifference curve). Trap: it is not the graph of f.
  • Total differential df≈fx dx+fy dy. Trap: putting in the new values instead of the changes dx, dy.
  • Slope of the level curve dydx=−fxfy. Trap: turning the fraction upside down or losing the minus.
  • Maximum under a constraint: at the optimum the level curve of the goal touches the constraint line, fxfy=pxpy. Trap: looking for the maximum without the constraint; U=xy has none.
  • Formula sheet (“Formelsammlung”, printed in the exam booklet after the tasks): the formula for the slope of the level curve is on it in other letters; the translation into our notation is in the section “Implicit derivative: slope of the isoquant”.

What comes next

Now practise it

Functions of two variables

Trainer · Functions of several variables

Practise
Next: Partial derivatives and the chain rule
0/1

Was this article helpful?