Salta al contenuto
Note per Studenti Differentiability and the Gradient Report

Differentiability and the Gradient

In questa pagina 8

This note builds on Partial and Directional DerivativesThe partial derivative with respect to x_i at x0 is the derivative of the one-variable function obtained by freezing all the other variables, so in practice one differentiates in x_i treating the others as constants. The gradient collects the partial derivatives; the directional derivative along a unit vector v is the limit of [f(x0 + hv) - f(x0)]/h. In several variables having all partial (even directional) derivatives does not guarantee continuity.Partial and Directional Derivatives →.

In one variable, ff differentiable at x0x_0 means f(x)=f(x0)+f′(x0)(x−x0)+o(x−x0)f(x) = f(x_0) + f'(x_0)(x - x_0) + o(x - x_0): near x0x_0 the function is approximated by the tangent line with a negligible error. In several variables the partial derivatives alone do not give this property (we saw that they do not even guarantee continuity). So we demand it as a definition.

Definition of differentiable function

A function f:A⊆Rn→Rf: A \subseteq \mathbb{R}^n \to \mathbb{R} is differentiable at a point x0x_0 interior to AA if there exists a vector a=(a1,…,an)∈Rna = (a_1, \dots, a_n) \in \mathbb{R}^n such that the increment of the function can be approximated linearly:

f(x)=f(x0)+a⋅(x−x0)+o(∥x−x0∥)as x→x0f(x) = f(x_0) + a \cdot (x - x_0) + o(\|x - x_0\|) \quad \text{as } x \to x_0

where a⋅(x−x0)a \cdot (x - x_0) is the differentialthe dot product of the gradient vector and the increment vector and o(∥x−x0∥)o(\|x - x_0\|) is a little-o terma term that tends to zero faster than the norm of the increment describing the approximation error.

Theorem. If ff is differentiable at x0x_0, then the vector aa is uniquely determined and equals the gradient of ff at x0x_0, i.e. a=∇f(x0)a = \nabla f(x_0). Moreover, ff is continuous at x0x_0 and has all its partial derivatives there.

Example. f(x,y)=x2+y2f(x,y) = x^2 + y^2 is differentiable at (1,2)(1,2) with a=∇f(1,2)=(2,4)a = \nabla f(1,2) = (2, 4): f(x,y)=5+2(x−1)+4(y−2)+o(∥(x,y)−(1,2)∥)f(x,y) = 5 + 2(x-1) + 4(y-2) + o(\|(x,y) - (1,2)\|).

Why.

  • Continuity: as x→x0x \to x_0 we have a⋅(x−x0)→0a \cdot (x - x_0) \to 0 and o(∥x−x0∥)→0o(\|x - x_0\|) \to 0, hence f(x)→f(x0)f(x) \to f(x_0).
  • a=∇f(x0)a = \nabla f(x_0): take x=x0+heix = x_0 + h e_i (we move along axis ii). Then a⋅(x−x0)=haia \cdot (x - x_0) = h a_i and f(x0+hei)−f(x0)h=ai+o(∣h∣)h→h→0ai\frac{f(x_0 + he_i) - f(x_0)}{h} = a_i + \frac{o(|h|)}{h} \xrightarrow[h \to 0]{} a_i so the ii-th partial derivative exists and equals aia_i.

In two variables, setting h=x−x0h = x - x_0 and k=y−y0k = y - y_0, the definition is rewritten as a limit to check: lim⁡(h,k)→(0,0)f(x0+h,y0+k)−f(x0,y0)−fx(x0,y0) h−fy(x0,y0) kh2+k2=0\lim_{(h,k) \to (0,0)} \frac{f(x_0 + h, y_0 + k) - f(x_0, y_0) - f_x(x_0, y_0)\,h - f_y(x_0, y_0)\,k}{\sqrt{h^2 + k^2}} = 0 This is the differentiability test: first compute the partial derivatives (if they do not exist, ff is not differentiable), then check this limit with the methods of Limits and Continuity in Several VariablesThe limit of a function of several variables exists if the value approaches L independently of the path; it is shown to exist with estimates in polar coordinates and shown not to exist by restricting to different curves. Continuity requires the limit to equal the value of the function at the point.Limits and Continuity in Several Variables →.

Gradient and tangent plane

The gradient is the vector of partial derivatives, ∇f(x0)=(∂f∂x1(x0),…,∂f∂xn(x0))\nabla f(x_0) = \left( \frac{\partial f}{\partial x_1}(x_0), \dots, \frac{\partial f}{\partial x_n}(x_0) \right) (see Partial and Directional DerivativesThe partial derivative with respect to x_i at x0 is the derivative of the one-variable function obtained by freezing all the other variables, so in practice one differentiates in x_i treating the others as constants. The gradient collects the partial derivatives; the directional derivative along a unit vector v is the limit of [f(x0 + hv) - f(x0)]/h. In several variables having all partial (even directional) derivatives does not guarantee continuity.Partial and Directional Derivatives →). If the function is differentiable, the plane tangent to the graph of ff at the point (x0,f(x0))(x_0, f(x_0)) has equation:

z=f(x0)+∇f(x0)⋅(x−x0)z = f(x_0) + \nabla f(x_0) \cdot (x - x_0)

In two variables, explicitly: z=f(x0,y0)+fx(x0,y0) (x−x0)+fy(x0,y0) (y−y0)z = f(x_0, y_0) + f_x(x_0, y_0)\,(x - x_0) + f_y(x_0, y_0)\,(y - y_0)

It is the plane passing through the point of the graph and having, along the two axes, the same slopes as the surface. Differentiability says that the vertical distance between graph and plane is o(∥x−x0∥)o(\|x - x_0\|), i.e. negligible with respect to the distance from x0x_0.

Example. f(x,y)=x2+y2f(x, y) = x^2 + y^2 at (1,2)(1, 2): f(1,2)=5f(1, 2) = 5, fx=2x=2f_x = 2x = 2, fy=2y=4f_y = 2y = 4. Tangent plane: z=5+2(x−1)+4(y−2)z = 5 + 2(x - 1) + 4(y - 2), i.e. z=2x+4y−5z = 2x + 4y - 5.

Sufficient condition

The existence of partial derivatives does not always guarantee differentiability. So we use the C1C^1 criterion:

Total differential theorem. If ff has partial derivatives in a neighbourhood of x0x_0 and these are continuousfunctions whose limit at the point equals the value at the point at x0x_0, then ff is differentiable at x0x_0.

Example. f(x,y)=xeyf(x,y) = x e^y has partial derivatives eye^y and xeyx e^y, continuous on all of R2\mathbb{R}^2: hence ff is differentiable at every point.

A function whose partial derivatives are continuous at every point of an open set is said to be of class C^1a function with continuous first partial derivatives.

Directional derivative and gradient

For a differentiable function, the derivative along a direction vv (with ∥v∥=1\|v\|=1) need not be computed through the limit of the difference quotient:

Gradient formula. If ff is differentiable at x0x_0, then for every unit vector vv the directional derivative Dvf(x0)D_v f(x_0) exists and is given by: Dvf(x0)=∇f(x0)⋅vD_v f(x_0) = \nabla f(x_0) \cdot v

Example. f(x,y)=x2+y2f(x,y) = x^2 + y^2 at (1,2)(1,2) with v=(35,45)v = \left(\frac{3}{5}, \frac{4}{5}\right): Dvf=(2,4)⋅(35,45)=6+165=225D_v f = (2, 4) \cdot \left(\frac{3}{5}, \frac{4}{5}\right) = \frac{6 + 16}{5} = \frac{22}{5}.

Why. Take x=x0+hvx = x_0 + hv in the definition: ∥x−x0∥=∣h∣\|x - x_0\| = |h| (because ∥v∥=1\|v\| = 1) and f(x0+hv)−f(x0)h=h ∇f(x0)⋅v+o(∣h∣)h→∇f(x0)⋅v\frac{f(x_0 + hv) - f(x_0)}{h} = \frac{h\,\nabla f(x_0) \cdot v + o(|h|)}{h} \to \nabla f(x_0) \cdot v

Geometric interpretation

  1. Steepest increase: the gradient ∇f(x0)\nabla f(x_0) points in the direction of steepest increase of the function. The value of the maximum slope is ∥∇f(x0)∥\|\nabla f(x_0)\|.

    Why: if θ\theta is the angle between ∇f(x0)\nabla f(x_0) and the unit vector vv, then Dvf(x0)=∇f(x0)⋅v=∥∇f(x0)∥cos⁡θD_v f(x_0) = \nabla f(x_0) \cdot v = \|\nabla f(x_0)\| \cos\theta. It is maximal for θ=0\theta = 0 (vv in the direction of the gradient, value ∥∇f∥\|\nabla f\|), minimal for θ=π\theta = \pi (opposite direction, value −∥∇f∥-\|\nabla f\|) and zero for θ=π2\theta = \frac{\pi}{2}.

  2. Orthogonality: the gradient is orthogonal to the level curvethe set of points where f equals a constant c through x0x_0.

    Why: along the level curve ff is constant, so the derivative in the direction tangent to the curve is 00; by point 1 that direction makes a right angle with the gradient.

Example. f(x,y)=x2+y2f(x, y) = x^2 + y^2 at (1,2)(1, 2): ∇f=(2,4)\nabla f = (2, 4), which points radially outward, perpendicular to the level circle x2+y2=5x^2 + y^2 = 5. The maximum slope is ∥(2,4)∥=20=25\|(2,4)\| = \sqrt{20} = 2\sqrt5; along the tangent to the circle, for instance v=15(2,−1)v = \frac{1}{\sqrt5}(2, -1), the derivative is 4−45=0\frac{4 - 4}{\sqrt5} = 0.

Grafico interattivo: f = x² + y² at (1, 2): grad f = (2, 4) is perpendicular to the level curve x² + y² = 5 (circle of radius √5) and to its tangent x + 2y = 5, and is the direction of steepest increase

Worked numerical example

Consider f(x,y)=exy+x2yf(x, y) = e^{xy} + x^2y. We check differentiability at (1,1)(1, 1).

  1. Compute the partial derivatives: ∂f∂x=yexy+2xy\frac{\partial f}{\partial x} = ye^{xy} + 2xy ∂f∂y=xexy+x2\frac{\partial f}{\partial y} = xe^{xy} + x^2
  2. At (1,1)(1, 1): fx(1,1)=e+2f_x(1,1) = e + 2, fy(1,1)=e+1f_y(1,1) = e + 1.
  3. The partial derivatives are elementary functions, continuous on all of R2\mathbb{R}^2. By the total differential theorem, ff is differentiable at (1,1)(1, 1) (in fact at every point).
  4. Tangent plane at (1,1)(1, 1): f(1,1)=e+1f(1, 1) = e + 1, so z=e+1+(e+2)(x−1)+(e+1)(y−1)z = e + 1 + (e + 2)(x - 1) + (e + 1)(y - 1).

Exercise: a function with partial derivatives, continuous but not differentiable

f(x,y)=sin⁡(xy)yf(x, y) = \dfrac{\sin(xy)}{y} for y≠0y \neq 0, f(x,0)=0f(x, 0) = 0. We study the origin.

  1. Continuity. With ∣sin⁡t∣≤∣t∣|\sin t| \leq |t|:  ∣f(x,y)∣≤∣xy∣∣y∣=∣x∣→0\ |f(x, y)| \leq \frac{|xy|}{|y|} = |x| \to 0 (for y=0y = 0 the function is 00). So ff is continuous at (0,0)(0, 0).
  2. Partial derivatives. f(h,0)=0f(h, 0) = 0, so fx(0,0)=0f_x(0,0) = 0. f(0,h)=sin⁡0h=0f(0, h) = \frac{\sin 0}{h} = 0, so fy(0,0)=0f_y(0, 0) = 0.
  3. Differentiability. The candidate plane is z=0z = 0; we must see whether f(h,k)h2+k2→0\frac{f(h,k)}{\sqrt{h^2+k^2}} \to 0. Along k=mhk = mh with m≠0m \neq 0, using sin⁡t∼t\sin t \sim t: sin⁡(mh2)mh h2(1+m2)∼mh2mh ∣h∣1+m2=h∣h∣⋅11+m2\frac{\sin(mh^2)}{mh\,\sqrt{h^2(1+m^2)}} \sim \frac{mh^2}{mh\,|h|\sqrt{1+m^2}} = \frac{h}{|h|}\cdot\frac{1}{\sqrt{1+m^2}} which equals ±11+m2\pm\frac{1}{\sqrt{1+m^2}} depending on the sign of hh: it does not tend to 00. The function is not differentiable at the origin, although it is continuous and has partial derivatives.

Functions with a parameter in the exponent: the four-step procedure

In exam problems the function is almost always of the form f(x,y)=g(x,y)(x2+y2)af(x,y)=\frac{g(x,y)}{(x^2+y^2)^a} at (0,0)(0,0) (with f(0,0)=0f(0,0)=0), or contains absolute values and roots, and one asks for which values of the parameter ff is continuous, has partial derivatives, is differentiable. Proceed as follows.

  1. Polar form. Set x=rcos⁡θx=r\cos\theta, y=rsin⁡θy=r\sin\theta; the numerator, homogeneous of degree pp (i.e. g≈rp h(θ)g\approx r^p\,h(\theta) with hh bounded and nonzero), gives f≈r p−2a h(θ)f\approx r^{\,p-2a}\,h(\theta). If log⁡(1−x)\log(1-x), sin⁡x\sin x, ex−1e^x-1 etc. appear, replace them by their equivalent (−x-x, xx, xx) and check that the remaining factor tends to 11 (is bounded).
  2. Continuity: f→0f\to0 if and only if p−2a>0p-2a>0. For p=2ap=2a the limit depends on θ\theta (it does not exist, unless h≡0h\equiv0); for p<2ap<2a it diverges.
  3. Partial derivatives at (0,0)(0,0): by the definition, because f(0,0)f(0,0) is given separately. If ff vanishes on the axes, fx(0,0)=fy(0,0)=0f_x(0,0)=f_y(0,0)=0 for every value of the parameter (even where ff is not continuous).
  4. Differentiability: the limit to study is fr≈r p−2a−1 h(θ)\frac{f}{r}\approx r^{\,p-2a-1}\,h(\theta) (the gradient is zero): it tends to 00 if and only if p−2a−1>0p-2a-1>0, i.e. a<p−12a<\frac{p-1}{2}. So the differentiability threshold is always lower by 12\frac12 than the continuity one.

Example: with p=3p=3, ff is continuous for a<32a<\frac32 and differentiable for a<1a<1.

Absolute values and roots. For fα(x,y)=∣x∣α∣y∣f_\alpha(x,y)=\sqrt{|x|^\alpha|y|} the partial derivatives at 00 equal 00 (the function vanishes on the axes), but the derivative in the direction (v,w)(v,w) is the limit of ∣t∣(α+1)/2t∣v∣α∣w∣\frac{|t|^{(\alpha+1)/2}}{t}\sqrt{|v|^\alpha|w|}: it exists only if α>1\alpha>1. If a directional derivative does not exist, ff cannot be differentiable.

Common mistakes

  • Swapping the implications: having partial derivatives does not imply differentiability. The classic counterexample is f(x,y)=xyx2+y2f(x,y) = \frac{xy}{x^2+y^2} (with f(0,0)=0f(0,0)=0), which has partial derivatives at the origin but is not continuous, hence not differentiable.
  • Forgetting the unit vector: in computing Dvf=∇f⋅vD_v f = \nabla f \cdot v, the vector vv must always be a unit vector (∥v∥=1\|v\|=1). If the direction is given by a non-unit vector, it must be normalized first.
  • Sufficient condition mistaken for necessary: continuity of the partial derivatives is sufficient but not necessary. A function can be differentiable even if the partial derivatives are discontinuous (for example (x2+y2)sin⁡1x2+y2(x^2+y^2)\sin\frac{1}{\sqrt{x^2+y^2}} at the origin): in that case use the limit test.
  • Stopping at the partial derivatives: finding fx(0,0)f_x(0,0) and fy(0,0)f_y(0,0) is not enough; the limit of the differentiability test must still be checked.

Versione ripasso

Definition. ff is differentiable at x0x_0 if there exists a=∇f(x0)a = \nabla f(x_0) with f(x)=f(x0)+∇f(x0)⋅(x−x0)+o(∥x−x0∥)as x→x0f(x) = f(x_0) + \nabla f(x_0) \cdot (x - x_0) + o(\|x - x_0\|) \quad \text{as } x \to x_0 Differentiable   ⟹  \implies continuous, with partial derivatives, and Dvf=∇f⋅vD_v f = \nabla f \cdot v. The converse is false.

Test in two variables. After computing the partial derivatives, check that lim⁡(h,k)→(0,0)f(x0+h,y0+k)−f(x0,y0)−fx(x0,y0) h−fy(x0,y0) kh2+k2=0\lim_{(h,k) \to (0,0)} \frac{f(x_0 + h, y_0 + k) - f(x_0, y_0) - f_x(x_0,y_0)\,h - f_y(x_0,y_0)\,k}{\sqrt{h^2 + k^2}} = 0 Example: f=sin⁡(xy)yf = \frac{\sin(xy)}{y} with f(x,0)=0f(x,0) = 0 is continuous with zero partial derivatives at (0,0)(0,0). Along k=mhk = mh the ratio equals h∣h∣⋅11+m2\frac{h}{|h|}\cdot\frac{1}{\sqrt{1+m^2}}, which does not tend to 00: not differentiable.

Total differential theorem. If the partial derivatives exist near x0x_0 and are continuous at x0x_0 (e.g. if f∈C1f \in C^1), then ff is differentiable. Example: f=xeyf = xe^y is differentiable everywhere.

Tangent plane. z=f(x0,y0)+fx(x0,y0)(x−x0)+fy(x0,y0)(y−y0)z = f(x_0,y_0) + f_x(x_0,y_0)(x - x_0) + f_y(x_0,y_0)(y - y_0). Example: f=x2+y2f = x^2+y^2 at (1,2)(1,2), f(1,2)=5f(1,2) = 5, ∇f=(2,4)\nabla f = (2,4), so z=2x+4y−5z = 2x + 4y - 5.

Interpretation. Dvf=∥∇f∥cos⁡θD_v f = \|\nabla f\|\cos\theta, with θ\theta the angle between ∇f\nabla f and vv. The gradient points in the direction of steepest increase, with slope ∥∇f∥\|\nabla f\|, and is orthogonal to the level curve. Example: for f=x2+y2f = x^2+y^2 at (1,2)(1,2), ∇f=(2,4)\nabla f = (2,4) is perpendicular to the circle x2+y2=5x^2+y^2 = 5. Along the tangent v=15(2,−1)v = \frac{1}{\sqrt5}(2,-1) the derivative is 00.

Numerical example. f=exy+x2yf = e^{xy} + x^2y at (1,1)(1,1): fx=yexy+2xyf_x = ye^{xy} + 2xy, fy=xexy+x2f_y = xe^{xy} + x^2, values e+2e+2 and e+1e+1. Continuous partial derivatives, hence differentiable. Plane: z=e+1+(e+2)(x−1)+(e+1)(y−1)z = e+1 + (e+2)(x-1) + (e+1)(y-1).

Functions with a parameter, f=g(x2+y2)af = \frac{g}{(x^2+y^2)^a} at (0,0)(0,0). In polar coordinates, with g≈rph(θ)g \approx r^p h(\theta), we get f≈rp−2ah(θ)f \approx r^{p-2a}h(\theta).

  1. Continuity:   ⟺  p−2a>0\iff p - 2a > 0. For p=2ap = 2a the limit depends on θ\theta.
  2. Partial derivatives: by the definition. If f=0f = 0 on the axes, they equal 00 for every parameter.
  3. Differentiability: fr≈rp−2a−1h(θ)→0\frac{f}{r} \approx r^{p-2a-1}h(\theta) \to 0   ⟺  a<p−12\iff a < \frac{p-1}{2}. The threshold is lower by 12\frac12 than the continuity one.

With p=3p = 3: continuous for a<32a < \frac32, differentiable for a<1a < 1.

Absolute values and roots. For ∣x∣α∣y∣\sqrt{|x|^\alpha|y|} the partial derivatives at 00 equal 00, but the derivative along (v,w)(v,w) exists only for α>1\alpha > 1. If a directional derivative does not exist, there is no differentiability.

Typical mistakes.

  • Confusing partial derivatives and differentiability: xyx2+y2\frac{xy}{x^2+y^2} has partial derivatives at 00 but is not continuous, hence not differentiable.
  • Swapping sufficient and necessary: continuous partial derivatives suffice but are not necessary (example: (x2+y2)sin⁡1x2+y2(x^2+y^2)\sin\frac{1}{\sqrt{x^2+y^2}} at the origin, to be studied with the test).
  • Stopping at the partial derivatives without checking the limit of the test.
  • Using a non-unit vector in DvfD_v f.

Teoria collegata