Notes on Calculus and Optimization
Total Page:16
File Type:pdf, Size:1020Kb
Economics 101A Section Notes GSI: David Albouy Notes on Calculus and Optimization 1 Basic Calculus 1.1 Definition of a Derivative Let f (x) be some function of x, then the derivative of f, if it exists, is given by the following limit df (x) f (x + h) f (x) = lim − (Definition of Derivative) dx h 0 h → df although often this definition is hard to apply directly. It is common to write f 0 (x),or dx to be shorter, or dy if y = f (x) then dx for the derivative of y with respect to x. 1.2 Calculus Rules Here are some handy formulas which can be derived using the definitions, where f (x) and g (x) are functions of x and k is a constant which does not depend on x. d df (x) [kf (x)] = k (Constant Rule) dx dx d df (x) df (x) [f (x)+g (x)] = + (Sum Rule) dx dx dy d df (x) dg (x) [f (x) g (x)] = g (x)+f (x) (Product Rule) dx dx dx d f (x) df (x) g (x) dg(x) f (x) = dx − dx (Quotient Rule) dx g (x) [g (x)]2 · ¸ d f [g (x)] dg (x) f [g (x)] = (Chain Rule) dx dg dx For specific forms of f the following rules are useful in economics d xk = kxk 1 (Power Rule) dx − d ex = ex (Exponent Rule) dx d 1 ln x = (Logarithm Rule) dx x 1 Finally assuming that we can invert y = f (x) by solving for x in terms of y so that x = f − (y) then the following rule applies 1 df − (y) 1 = 1 (Inverse Rule) dy df (f − (y)) dx Example 1 Let y = f (x)=ex/2, then using the exponent rule and the chain rule, where g (x)=x/2,we df (x) d x/2 d x/2 d x x/2 1 1 x/2 get dx = dx e = d(x/2) e dx 2 = e 2 = 2 e . The inverse function of f can be gotten · x/2 x/2 x x by solving for x in terms of y. y = e ln y =ln e = 2 ln (e)= 2 x =2lny using the facts ¡ ¢ u ¡ ¢ ¡ ⇒¢ ¡ ¢ 1⇒ from precalculus that ln e = u ln e and that ln e =1. The derivative of f − (y) can be solved directly as 1 d d 1 2 ¡ ¢ df − (y) 1 1 dy (2 ln y)=2dy (ln y)=2 y = y or indirectly through the Inverse Rule as dy = 1 x/2 = 1 2lny/2 = 2 e 2 e 2 2 ln y ln y = using the fact that³e ´ = y. e y 1 y x 5 10 2.5 7.5 0 0 2.5 5 7.5 10 5 y -2.5 2.5 0 -5 -5 -2.5 0 2.5 5 x dy 1 x =2lny dx = 2 y =exp(x/2) dx = 2 exp (x/2) dy y 1.3 Partial Differentiation Taking derivatives of functions in several variables is very straightforward (at least with the functions used in economics). Say we have a function in two variables, x and y,whichwecanwriteash (x, y). Partial differentiation, which uses a "∂" ("del") instead of a "d", can be done in either in x or in y,bywritingeither ∂ ∂ " ∂x"or"∂y "infrontofh (x, y), respectively, and then taking the derivative with respect to the variable chosen as we would in the single variable case, treating the other variable as a constant. Example 2 Let h (x, y)=3x2 ln y, shown below in the graphs for ranges 0 x 2 and 0 y 10 ≤ ≤ ≤ ≤ y 10 h(x,y) 20 7.5 10 57.5 y 02.50.25 0.5 0.75 1 1.25 1.5 1.75 2 x 5 -20 2.5 -40 0.5 1 1.5 2 x 3-D representation of 3x2 ln y Level curves 3x2 ln y = k for k =1, 2,...,27 Note the second plot of the level curves are like what you would find in a topographic contour map. Applying the partial differentiation rules we get the partial derivatives ∂ ∂ 3x2 ln y =3lny x2 =3lny (2x)=6x ln y ∂x ∂x µ ¶ ∂ ¡ ¢ ∂ 1 3x2 3x2 ln y =3x2 ln y =3x2 = ∂y ∂y y y µ ¶ µ ¶ ¡ ¢ 2 1.4 Total Differentiation Say that we know already that y is a function of x,sayy = f (x) and we want to see how a function in both variables, say h (x, y) responds when we let both x change and y change according to how it should according to f. The we could rewrite our expression as a function in a single variable H (x)=h (x, f (x)) and take the total derivative with respect to x to get dH (x) ∂h(x, f (x)) ∂h(x, f (x)) df (x) = + (Total Derivative) dx ∂x ∂y dx where the second term makes use of the chain rule. x/2 2 df (x) 1 x/2 Example 3 Let y = f (x)=e and again h (x, y)=3x ln y.Thendx = 2 e .Andsobythe dH(x) 3x2 1 x/2 above formulas we have dx =6x ln y + y 2 e . Notice that this expression is in both x and y.It x/2 dH(x) x/2 3x2 1 x/2 can be simplified to be just a function of x by substituting in y = e so dx =6x ln e + ex/2 2 e = 2 3x2 9 2 3x + 2 = 2 x . Of course had we substituted in directly for y from the beginning we would have gotten 2 x/2 3 3 dH(x) 9 2 H (x)=3x ln e = 2 x and differentiating directly dx = 2 x , but this is not as general a treatment. y 10 h(x,y) 20 7.5 10 57.5 y 02.50.25 0.5 0.75 1 1.25 1.5 1.75 2 x 5 -20 2.5 -40 0.5 1 1.5 2 x exp (x/2) crossing level curves h (x, f (x)) is given by curve on the surface 1.5 Implicit Differentiation Imagine that it is known that y depends on x, but that we do not have an "explicit" formula for y in terms of x, but that we do know that together x and y must satisfy some equation h (x, y)=k (Equation in 2 variables) where h (x, y) is a function and k is just a constant (any equation in x and y can be written like this). Sometimesitisdifficult to solve "explicitly" for y in terms of x, i.e. to find the function f such that y = f (x). Nevertheless by the implicit function theorem we can still findthederivativeoff by differentiating "implicitly" with respect to x,treatingy as a function of x,sowecanwrite H (x)=h (x, f (x)) = k Using what we learned about total differentiation we can differentiate totally with respect to x to get dH (x) ∂h(x, f (x)) ∂h(x, f (x)) df (x) = + =0 dx ∂x ∂y dx df (x) andthensolvingfor dx we get df (x) ∂h(x,f(x)) = ∂x (Implicit Derivative) dx − ∂h(x,f(x)) ∂y Note that this trick does not work if ∂h(x,f(x)) =0since the derivative is undefined. ∂y 3 Example 4 Assume that our equation is h (x, y)=3x2 ln y =3. Thenusingthederivativewetookabove 2 2 we have dH(x) =6x ln y+ 3x df (x) =0.Solvingfordf (x) we get df (x) = (6x ln y) / 3x . This expression dx y dx dx dx − y is in both x and y, but we could evaluate it meaningfully for any value of x and y satisfying³ ´ 3x2 ln y =3for df (1) 3 instance x =1and y = e which means that dx = (6 1) / e = 2e. Of course this derivative may be different for different values of x. − · − ¡ ¢ y 10 7.5 5 2.5 0.5 1 1.5 2 x Implicit derivative at x =1,y = e is 2e − 2 Optimization 2.1 Increasing and Decreasing Functions By looking at the definition of a derivative we can say "loosely speaking" that for h small h 0 and positive h>0 that ≈ df (x) f (x + h) f (x) − dx ≈ h or that df (x) h = f (x + h) f (x) dx − Now we say that a function f is increasing at x if we have f (x + h) >f(x) or f (x + h) f (x) > 0. df (x) − However since h>0 this implies that dx > 0. Equivalently a function f is decreasing at x if we have df (x) f (x + h) <f(x) which then implies that dx < 0. Therefore the sign of the derivative tells us whether or not a function is increasing (the derivative is positive) or decreasing (the derivative is negative). 2.2 Unconstrained Optimization 2.2.1 One Variable Consider first the case with one variables x where x R,i.e. x cantakeonanyrealvalue. Wewishto maximize the objective function f (x) and there are∈ no constraints. Thus we solve max f (x) x Assuming f (x) has a maximum (for example f does not go to )1 andthatitisdifferentiable everywhere, ∞ then any maximum (x∗) must solve the following first order necessary conditions (FOC) df (x ) ∗ =0 (FOC) dx 1 Weierstrauss’s Theorem say shat f (x, y) will be guaranteed to have a maximum if f is continuous and x and y are defined over a closed and bounded domain.