Skip to main content

Optimality Conditions in Several Variables

Published

Last modified: 2026-11-24 09:19:45 (PST)

1 Optimality conditions in several variables

This section is adapted from the multivariate calculus and optimality-condition parts of Zhou [1], used under the MIT License (see the license text in Linear Algebra). The source states the second-order Taylor approximation and the optimality conditions without proof; here they are proved from the one-variable Taylor theorem, and the approximation is made exact by evaluating the Hessian at a point between \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\). The source calls points with zero gradient critical points; here they are stationary points, because Definition 2 in Critical Points and Optimization gives “critical point” a wider meaning. The source states these results for differentiable functions without saying how smooth; here the first-order results assume continuous first partial derivatives, and the second-order results continuous second partial derivatives. These parts of the source are not part of this section:

  • its remark that maximizing \(f\) is minimizing \(-f\), and its classification of constraints
  • its figure of local, strict local and global minima
  • its one-variable Taylor example and its plots
  • matrix calculus
  • convexity
  • Lagrange multipliers
  • Newton’s method and gradient descent

A local minimizer of a differentiable function on an open interval is a flat point (Definition 1 in Critical Points and Optimization), and, at a flat point, a positive second derivative guarantees a strict local minimum. This section extends both facts to a function \(f\) of a \(p \times 1\) vector \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\): the gradient \(\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) takes the place of the first derivative, and a \(p \times p\) matrix of second partial derivatives takes the place of the second; both facts are proved in this section, for every \(p \ge 1\). Throughout, \(\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})\) means the gradient evaluated at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}\).

LemTheorem 1 (A minimizer has derivative zero)

Theorem 1 (A minimizer has derivative zero) Let \(g\) be a real-valued function on an open interval containing \(c\), and let \(g\) be differentiable at \(c\). If \(c\) is a local minimizer of \(g\), then \(g'(c) = 0\). [2]

Proof. Take \(\delta> 0\) as in the definition of a local minimizer, shrunk if needed so that \((c - \delta, c + \delta)\) lies inside the interval; then \(g(c) \le g(c + h)\) whenever \(\mathopen{}\left|h\right|\mathclose{} < \delta\). For \(0 < h < \delta\), the difference quotient is

\[ \frac{g(c + h) - g(c)}{h} \ge 0, \]

because its numerator is at least \(0\) and its denominator is positive. As \(h \to 0\) from the right, these quotients tend to \(g'(c)\) (the two-sided limit exists, so the one-sided limit equals it), and a limit of numbers that are all at least \(0\) is at least \(0\); so \(g'(c) \ge 0\). For \(-\delta< h < 0\), the numerator is still at least \(0\) but the denominator is negative, so the quotient is at most \(0\), and in the same way, with \(h \to 0\) from the left, \(g'(c) \le 0\). Together, \(g'(c) = 0\).

ExmExample 1 (Applying the test, and its limits)

Example 1 (Applying the test, and its limits)  

  • \(g(x) = (x - 2)^2\) has its minimizer at \(c = 2\), and

    \[ \begin{aligned} g'(2) &= 2 (2 - 2) \\ &= 0. \end{aligned} \]

  • The converse fails: \(g(x) = x^3\) has

    \[ \begin{aligned} g'(0) &= 3 \cdot 0^2 \\ &= 0, \end{aligned} \]

    but \(0\) is not a local minimizer, since

    \[ \begin{aligned} g(-h) &= -h^3 \\ &< 0 \\ &= g(0) \end{aligned} \]

    for every \(h > 0\).

  • Differentiability is needed: \(g(x) = \mathopen{}\left|x\right|\mathclose{}\) has its minimizer at \(0\), but the difference quotient \(\mathopen{}\left|h\right|\mathclose{} / h\) is \(1\) for \(h > 0\) and \(-1\) for \(h < 0\), so it has no limit and \(g'(0)\) does not exist.

DefDefinition 1 (Stationary point)

Definition 1 (Stationary point) Let \(f\) be a scalar-valued function of a \(p \times 1\) vector \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\). A point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}\) at which the gradient exists and

\[ \frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}) = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{p \times 1} \]

is a stationary point of \(f\).

ExmExample 2 (A stationary point, and a point that is not one)

Example 2 (A stationary point, and a point that is not one) Let \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 + x_2^2 - 2 x_1\). Its gradient is

\[ \nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = {(2 x_1 - 2,\ 2 x_2)}^{\top}, \]

which is \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\) exactly when \(x_1 = 1\) and \(x_2 = 0\). So \({(1, 0)}^{\top}\) is its only stationary point, and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is not one: \(\nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}) = {(-2, 0)}^{\top}\).

Show code
sp_x1_fs <- seq(-1, 3, length.out = 101)
sp_x2_fs <- seq(-2, 2, length.out = 101)
sp_grid_fs <- expand.grid(x1 = sp_x1_fs, x2 = sp_x2_fs)
sp_grid_fs$value <- sp_grid_fs$x1^2 + sp_grid_fs$x2^2 - 2 * sp_grid_fs$x1
sp_marks_x1_fs <- c(1, 0)
sp_marks_kind_fs <- c("stationary point", "not stationary")
sp_marks_fs <- tibble::tibble(
  x1 = sp_marks_x1_fs, x2 = 0, kind = sp_marks_kind_fs
)
sp_aes_fs <- ggplot2::aes(x1, x2, z = value)
sp_marks_aes_fs <- ggplot2::aes(x1, x2, shape = kind, z = NULL)
sp_shapes_fs <- c("stationary point" = 16, "not stationary" = 17)
ggplot2::ggplot(sp_grid_fs, sp_aes_fs) +
  ggplot2::geom_contour(colour = "#0072B2") +
  ggplot2::geom_point(
    data = sp_marks_fs, mapping = sp_marks_aes_fs,
    colour = "#D55E00", size = 3, inherit.aes = FALSE
  ) +
  ggplot2::scale_shape_manual(values = sp_shapes_fs) +
  ggplot2::coord_fixed() +
  ggplot2::labs(x = "x1", y = "x2", shape = NULL)
Show code
import matplotlib.pyplot as plt
import numpy as np

sp_x1_fs = np.linspace(-1, 3, 101)
sp_x2_fs = np.linspace(-2, 2, 101)
sp_x1_grid_fs, sp_x2_grid_fs = np.meshgrid(sp_x1_fs, sp_x2_fs)
sp_value_fs = sp_x1_grid_fs**2 + sp_x2_grid_fs**2 - 2 * sp_x1_grid_fs
fig, ax = plt.subplots(figsize=(5, 4), layout="constrained")
ax.contour(sp_x1_grid_fs, sp_x2_grid_fs, sp_value_fs, colors="#0072B2")
ax.plot(1, 0, "o", color="#D55E00", markersize=8, label="stationary point")
ax.plot(0, 0, "^", color="#D55E00", markersize=8, label="not stationary")
ax.set_aspect("equal")
ax.set_xlabel("x1")
ax.set_ylabel("x2")
ax.legend(loc="upper right")
plt.show()
Figure 1: Level curves of the function of Example 2. The gradient is \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) only at the center \((1, 0)\) of the circles, the stationary point (circle). At the origin (triangle) the gradient is \(\nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}) = {(-2, 0)}^{\top}\), which is not \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\).
Show code
sp_x1_sf <- seq(-1, 3, length.out = 101)
sp_x2_sf <- seq(-2, 2, length.out = 101)
sp_grid_sf <- tidyr::expand_grid(x1 = sp_x1_sf, x2 = sp_x2_sf)
sp_value_sf <- sp_grid_sf$x1^2 + sp_grid_sf$x2^2 - 2 * sp_grid_sf$x1
sp_n2_sf <- length(sp_x2_sf)
sp_z_sf <- matrix(sp_value_sf, nrow = sp_n2_sf)
sp_m_x1_sf <- c(1, 0)
sp_m_x2_sf <- c(0, 0)
sp_m_kind_sf <- c("stationary point", "not stationary")
sp_m_symbol_sf <- c("circle", "diamond")
sp_marks_sf <- tibble::tibble(
  x1 = sp_m_x1_sf,
  x2 = sp_m_x2_sf,
  kind = sp_m_kind_sf,
  symbol = sp_m_symbol_sf
)
sp_marks_sf$z <- sp_marks_sf$x1^2 + sp_marks_sf$x2^2 - 2 * sp_marks_sf$x1
sp_marker_sf <- list(color = "#D55E00", size = 6, symbol = ~symbol)
sp_stops_sf <- c(0, 1)
sp_cols_sf <- c("#CCE0F0", "#0072B2")
sp_scale_sf <- list(sp_stops_sf, sp_cols_sf)
sp_eye_sf <- list(x = 1.6, y = -1.6, z = 0.9)
sp_camera_sf <- list(eye = sp_eye_sf)
sp_xaxis_sf <- list(title = "x1")
sp_yaxis_sf <- list(title = "x2")
sp_zaxis_sf <- list(title = "f(x)")
sp_scene_sf <- list(
  xaxis = sp_xaxis_sf,
  yaxis = sp_yaxis_sf,
  zaxis = sp_zaxis_sf,
  camera = sp_camera_sf
)
sp_legend_sf <- list(orientation = "h")
plotly::plot_ly() |>
  plotly::add_surface(
    x = sp_x1_sf,
    y = sp_x2_sf,
    z = sp_z_sf,
    colorscale = sp_scale_sf,
    showscale = FALSE,
    opacity = 0.8
  ) |>
  plotly::add_markers(
    data = sp_marks_sf,
    x = ~x1,
    y = ~x2,
    z = ~z,
    text = ~kind,
    hoverinfo = "text",
    showlegend = FALSE,
    marker = sp_marker_sf
  ) |>
  plotly::layout(scene = sp_scene_sf, legend = sp_legend_sf)
Show code
import html
import numpy as np
import plotly.graph_objects as go

fig_alt = (
    "Surface plot of x1 squared plus x2 squared minus 2 x1 over x1 from -1 to 3 "
    "and x2 from -2 to 2, a bowl-shaped surface opening upward. The lowest "
    "point of the bowl, at (1, 0) and height -1, is marked by a vermilion "
    "circle and is the stationary point. A vermilion diamond marks the point of "
    "the surface above the origin, at height 0, where the surface is not flat."
)

sp_x1_3d = np.linspace(-1, 3, 101)
sp_x2_3d = np.linspace(-2, 2, 101)
sp_x1_grid_3d, sp_x2_grid_3d = np.meshgrid(sp_x1_3d, sp_x2_3d)
sp_value_3d = sp_x1_grid_3d**2 + sp_x2_grid_3d**2 - 2 * sp_x1_grid_3d
fig = go.Figure(data=[
    go.Surface(
        x=sp_x1_3d,
        y=sp_x2_3d,
        z=sp_value_3d,
        colorscale=[[0, "#CCE0F0"], [1, "#0072B2"]],
        showscale=False,
        opacity=0.6,
        showlegend=False,
    ),
    go.Scatter3d(x=[1], y=[0], z=[-1], mode="markers",
                 marker=dict(color="#D55E00", size=4, symbol="circle"),
                 name="stationary point"),
    go.Scatter3d(x=[0], y=[0], z=[0], mode="markers",
                 marker=dict(color="#D55E00", size=4, symbol="diamond"),
                 name="not stationary"),
])
fig.update_layout(
    scene=dict(
        xaxis_title="x1",
        yaxis_title="x2",
        zaxis_title="f(x)",
        camera=dict(eye=dict(x=1.6, y=-1.6, z=0.9)),
    ),
    legend=dict(orientation="h"),
);
print(
    "```{=html}\n"
    + f'<div role="img" aria-label="{html.escape(fig_alt)}">\n'
    + fig.to_html(full_html=False, include_plotlyjs="cdn")
    + "\n</div>\n```"
)
Figure 2: The graph of the function of Example 2, the surface whose level curves are in Figure 1. The surface is flat, with gradient \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\), only at the bottom of the bowl above the center \((1, 0)\) of the circles, the stationary point (circle). Above the origin (diamond) the surface descends toward the stationary point.
RemarkRemark 1 (Stationary points in one variable)

Remark 1 (Stationary points in one variable). For \(p = 1\), a stationary point is a flat point (Definition 1 in Critical Points and Optimization).

LemTheorem 2 (First-order necessary condition)

Theorem 2 (First-order necessary condition) Let \(f : \mathbb{R}^p \to \mathbb{R}\). If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is a local minimizer of \(f\) and the gradient of \(f\) exists at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\), then \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is a stationary point of \(f\) (Definition 1).

Proof. Take \(\delta> 0\) as in the definition of a local minimizer. Let \(i \in \mathopen{}\left\{1, \ldots, p\right\}\mathclose{}\), let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i\) be the vector with \(1\) in entry \(i\) and \(0\) elsewhere, and let \(g_i(t) \stackrel{\text{def}}{=}f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* + t\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i)\) for \(t \in \mathbb{R}\). For \(\mathopen{}\left|t\right|\mathclose{} < \delta\),

\[ \begin{aligned} \mathopen{}\left\lVert(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* + t\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i) - \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} &= \mathopen{}\left|t\right|\mathclose{}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i\right\rVert\mathclose{} \\ &= \mathopen{}\left|t\right|\mathclose{} \\ &< \delta, \end{aligned} \]

so

\[ \begin{aligned} g_i(0) &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) \\ &\le f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* + t\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i) \\ &= g_i(t): \end{aligned} \]

\(0\) is a local minimizer of \(g_i\). Moving \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\) from \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) along \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{e}}\vphantom{e}}_i\) changes only \(x_i\), so \(g_i'(0)\) is the partial derivative \(\frac{\partial}{\partial x_i} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\), which exists because the gradient does. By Theorem 1,

\[ \begin{aligned} \frac{\partial}{\partial x_i} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) &= g_i'(0) \\ &= 0. \end{aligned} \]

The equation \(g_i'(0) = 0\) holds for every \(i\), so every entry of the gradient at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is \(0\).

ExmExample 3 (Using the condition to locate, and to rule out, minimizers)

Example 3 (Using the condition to locate, and to rule out, minimizers)  

  • For \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 + x_2^2 - 2 x_1\) of Example 2, any local minimizer must be the stationary point \({(1, 0)}^{\top}\). It is one: completing the square,

    \[ \begin{aligned} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) &= (x_1 - 1)^2 + x_2^2 - 1 \\ &\ge -1 \\ &= f(1, 0). \end{aligned} \]

  • For \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = e^{2x_1 + x_2} - x_1\) of the Hessian example, the second entry of \(\nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) is \(e^{2x_1 + x_2} > 0\), so \(f\) has no stationary point, and so no local minimizer.

  • The converse fails: \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 - x_2^2\) has gradient \({(2 x_1,\ -2 x_2)}^{\top}\), so \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is a stationary point, but

    \[ \begin{aligned} f(0, t) &= -t^2 \\ &< 0 \\ &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}) \end{aligned} \]

    for every \(t \ne 0\), so \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is not a local minimizer.

ExmExample 4 (A stationary point of the sum of squared errors, on real data)

Example 4 (A stationary point of the sum of squared errors, on real data) The Auto data record the horsepower and fuel economy (miles per gallon) of 392 car models sold between 1970 and 1982. They come from the StatLib library at Carnegie Mellon University and ship with the book An Introduction to Statistical Learning, in the Python package ISLP (ISLP.load_data("Auto")) and the R package ISLR2 (ISLR2::Auto). This site has a copy at data/auto.csv, and both code tabs below read that file.

Let \(y_i\) be the miles per gallon and \(x_i\) the horsepower of car \(i\). To predict miles per gallon from horsepower with a line, write \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}= {(\beta_{0}, \beta_{1})}^{\top}\) and let \(\mathbf{X}\) be the matrix whose row \(i\) is \((1, x_i)\). The sum of squared errors is

\[ f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}) = \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}- \mathbf{X}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}\right\rVert\mathclose{}^2, \]

a scalar-valued function of the \(2 \times 1\) vector \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}\). Its gradient is

\[ \nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}) = -2\,{\mathbf{X}}^{\top}(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}- \mathbf{X}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}). \]

By Theorem 2, a minimizer of \(f\) must make this gradient \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\), which is the equation \({\mathbf{X}}^{\top}\mathbf{X}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}= {\mathbf{X}}^{\top}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}\). The code below solves that equation and evaluates the gradient at the solution and at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{\beta}}\vphantom{\beta}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\).

import numpy as np
import pandas as pd

auto = pd.read_csv("data/auto.csv")
y = auto["mpg"].to_numpy(dtype=float)
X = np.column_stack([np.ones(len(auto)), auto["horsepower"].to_numpy(dtype=float)])

def grad(beta):
    return -2 * X.T @ (y - X @ beta)

beta_hat = np.linalg.solve(X.T @ X, X.T @ y)
grad_hat = grad(beta_hat)
grad_zero = grad(np.zeros(2))

pd.DataFrame(
    {"beta": [beta_hat, np.zeros(2)], "gradient": [grad_hat, grad_zero]},
    index=["solution", "zero vector"],
)
#>                                beta                gradient
#> solution     [39.935861, -0.157845]              [0.0, 0.0]
#> zero vector              [0.0, 0.0]  [-18381.6, -1737437.6]

A library fit gives the same coefficients:

import numpy as np

# np.polyfit returns the slope first, so reverse to (intercept, slope).
beta_polyfit = np.polyfit(auto["horsepower"], auto["mpg"], deg=1)[::-1]
beta_polyfit
#> array([39.93586102, -0.15784473])
auto <- read.csv("data/auto.csv")
y <- auto$mpg
X <- cbind(1, auto$horsepower)

grad <- function(beta) -2 * t(X) %*% (y - X %*% beta)

beta_hat <- solve(t(X) %*% X, t(X) %*% y)
grad_hat <- grad(beta_hat)
grad_zero <- grad(c(0, 0))

list(
  solution = list(beta = c(beta_hat), gradient = c(grad_hat)),
  zero_vector = list(beta = c(0, 0), gradient = c(grad_zero))
)
#> $solution
#> $solution$beta
#> [1] 39.9358610 -0.1578447
#> 
#> $solution$gradient
#> [1] 9.471535e-12 6.662049e-11
#> 
#> 
#> $zero_vector
#> $zero_vector$beta
#> [1] 0 0
#> 
#> $zero_vector$gradient
#> [1]   -18381.6 -1737437.6

A library fit gives the same coefficients:

coef(lm(mpg ~ horsepower, data = auto))
#> (Intercept)  horsepower 
#>  39.9358610  -0.1578447

The solution is an intercept of 39.9 miles per gallon and a slope of -0.158 miles per gallon per unit of horsepower. The largest entry of the gradient there is 6.7e-11, zero up to rounding error, against 1,737,438 at the zero vector. So the solution is a stationary point (Definition 1), and the zero vector is not. The library fits above agree with the solution of that equation.

LemTheorem 3 (Taylor’s theorem with a second-order remainder)

Theorem 3 (Taylor’s theorem with a second-order remainder) Let \(a < b\), and let \(g\) be a real-valued function on \([a, b]\) whose derivative \(g'\) is continuous on \([a, b]\) and whose second derivative \(g''\) exists at every point of \((a, b)\). Then there is a \(\tau\in (a, b)\) with [3]

\[ g(b) = g(a) + g'(a)\,(b - a) + \frac{1}{2}\,g''(\tau)\,(b - a)^2. \]

This is the case \(n = 2\) of [4], Theorem 5.15, whose proof uses the mean value theorem, which these notes do not develop.

ExmExample 5 (The remainder point for \(e^x\))

Example 5 (The remainder point for \(e^x\)) Take \(g(x) = e^x\) on \([0, 1]\), so

\[ \begin{aligned} g' &= g'' \\ &= g. \end{aligned} \]

Theorem 3 says \(e = 1 + 1 + \tfrac{1}{2}\,e^{\tau}\) for some \(\tau\in (0, 1)\). Solving,

\[ \begin{aligned} e^{\tau} &= 2 (e - 2) \\ &\approx 2 \times 0.71828 \\ &= 1.43656, \end{aligned} \]

so \(\tau= \log 1.43656 \approx 0.362\), where \(\log\) is the natural logarithm. This \(\tau\) is in \((0, 1)\).

LemTheorem 4 (Second-order Taylor theorem in several variables)

Theorem 4 (Second-order Taylor theorem in several variables) Let \(f : \mathbb{R}^p \to \mathbb{R}\) have first and second partial derivatives that are continuous on \(\mathbb{R}^p\), and let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}, \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \in \mathbb{R}^p\). Then there is a \(\tau\in (0, 1)\) with [3]

\[ f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) = f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}) + {\mathopen{}\left(\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})\right)\mathclose{}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \tau\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}. \]

Proof. Let \(g(t) \stackrel{\text{def}}{=}f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\) for \(t \in \mathbb{R}\), the values of \(f\) along the line through \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}\) in the direction \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\). The inner function \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}(t) = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\) has entries \(y_j = z_j + t h_j\), so \(\frac{\partial}{\partial t} y_j = h_j\), and its derivative is the \(1 \times p\) matrix \({\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\). By the vector chain rule applied with the argument \(t\), the inner function \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}(t) = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\), and the outer function \(f\),

\[ \begin{aligned} g'(t) &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) && \text{(vector chain rule)} \\ &= \sum_{j=1}^ph_j\,\frac{\partial}{\partial x_j} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}). && \text{(matrix product)} \end{aligned} \]

The second step writes out the matrix product. \(g'\) is continuous: \(t \mapsto \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\) is continuous, since \(\mathopen{}\left\lVert(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + s \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) - (\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\right\rVert\mathclose{} = \mathopen{}\left|s - t\right|\mathclose{}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}\), each \(\frac{\partial}{\partial x_j} f\) is continuous by assumption, and compositions, sums and constant multiples of continuous functions are continuous. Each \(\frac{\partial}{\partial x_j} f\) has continuous partial derivatives, the second partial derivatives of \(f\), so the same chain-rule computation applies to it: \(\frac{\partial}{\partial t} \mathopen{}\left[\frac{\partial}{\partial x_j} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\right]\mathclose{} = \sum_{i=1}^ph_i\,\frac{\partial}{\partial x_i} \mathopen{}\left(\frac{\partial}{\partial x_j} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\right)\mathclose{}\). So

\[ \begin{aligned} g''(t) &= \sum_{j=1}^ph_j \sum_{i=1}^ph_i\,\frac{\partial}{\partial x_i} \mathopen{}\left(\frac{\partial}{\partial x_j} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\right)\mathclose{} && \text{(differentiate each term of } g'(t) \text{)} \\ &= \sum_{i=1}^p\sum_{j=1}^ph_i\,\mathopen{}\left[\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\right]\mathclose{}_{ij}\,h_j && \text{(definition of the Hessian; reorder the finite sums)} \\ &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + t \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}. && \text{(matrix product)} \end{aligned} \]

The last step is again the matrix product. Now apply Theorem 3 to \(g\) on \([0, 1]\): there is a \(\tau\in (0, 1)\) with

\[ \begin{aligned} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) &= g(1) && \text{(definition of } g \text{)} \\ &= g(0) + g'(0)\,(1 - 0) + \frac{1}{2}\,g''(\tau)\,(1 - 0)^2 && \text{(}\href{#thm-taylor-1d}{\text{Theorem~3}}\text{, with } a = 0, b = 1 \text{)} \\ &= g(0) + g'(0) + \frac{1}{2}\,g''(\tau) && \text{(} 1 - 0 = 1 \text{)} \\ &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}) + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}) + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \tau\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(substitute } g(0), g'(0), g''(\tau) \text{)} \\ &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}) + {\mathopen{}\left(\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})\right)\mathclose{}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \tau\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}. && \text{(a } 1 \times 1 \text{ matrix equals its transpose)} \end{aligned} \]

ExmExample 6 (For a quadratic form the expansion is exact)

Example 6 (For a quadratic form the expansion is exact) Let \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\) with \(\mathbf{S}\) symmetric and constant. Its gradient is \(\nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = 2 \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\) (quadratic form gradient) and its Hessian is \(2 \mathbf{S}\) at every point (quadratic form Hessian), so whatever \(\tau\) is, Theorem 4 reads

\[ \begin{aligned} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + {(2 \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} (2 \mathbf{S}) \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \\ &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + 2\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}, \end{aligned} \]

using

\[ \begin{aligned} {(2 \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})}^{\top} &= 2\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top}\,{\mathbf{S}}^{\top} \\ &= 2\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S}. \end{aligned} \]

Multiplying out directly gives the same:

\[ \begin{aligned} {(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})}^{\top} \mathbf{S} (\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(distribute)} \\ &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} + 2\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}. && \text{(} {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}} = {({\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}})}^{\top} \text{, which equals } {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{z}}\vphantom{z}}}^{\top} \mathbf{S} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \text{)} \end{aligned} \]

DefDefinition 2 (Strict local minimizer)

Definition 2 (Strict local minimizer) Let \(f : \mathbb{R}^p \to \mathbb{R}\). A point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is a strict local minimizer of \(f\) if there is a number \(\delta> 0\) such that \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) < f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) for every \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\ne \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) with \(\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} < \delta\).

ExmExample 7 (Strict and non-strict local minimizers)

Example 7 (Strict and non-strict local minimizers)  

  • \(f(x) = (x - 2)^2\) has

    \[ \begin{aligned} f(2) &= 0 \\ &< (x - 2)^2 \\ &= f(x) \end{aligned} \]

    for every \(x \ne 2\), so \(2\) is a strict local minimizer (any \(\delta> 0\) works).

  • A constant function \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = 0\) has \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) \le f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) for all \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\), so every point is a local minimizer, but no point is a strict one: \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) < f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) never holds.

LemLemma 1 (A quadratic form is at least the smallest eigenvalue times the squared length)

Lemma 1 (A quadratic form is at least the smallest eigenvalue times the squared length) Let \(\mathbf{A}\) be a symmetric \(p \times p\) matrix, and let \(\lambda_{\min}\) be the smallest of its eigenvalues. Then \({\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{A} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \ge \lambda_{\min}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2\) for every \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \in \mathbb{R}^p\).

Proof. By the spectral theorem, write \(\mathbf{A} = \mathbf{Q} \mathbf{\Lambda} {\mathbf{Q}}^{\top}\) with \(\mathbf{Q}\) an orthogonal matrix and \(\mathbf{\Lambda} = \operatorname{diag}(\lambda_1, \ldots, \lambda_p)\), and let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}} = {\mathbf{Q}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\). Then

\[ \begin{aligned} {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{A} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{Q} \mathbf{\Lambda} {\mathbf{Q}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(substitute the eigendecomposition)} \\ &= {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}}^{\top} \mathbf{\Lambda} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}} && \text{(} {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{Q} = {({\mathbf{Q}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}})}^{\top} \text{, transpose of a product)} \\ &= \sum_{i=1}^p\lambda_i\,y_i^2 && \text{(} \mathbf{\Lambda} \text{ is diagonal)} \\ &\ge \sum_{i=1}^p\lambda_{\min}\,y_i^2 && \text{(} \lambda_i \ge \lambda_{\min} \text{ and } y_i^2 \ge 0 \text{)} \\ &= \lambda_{\min}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}\right\rVert\mathclose{}^2 && \text{(the squared length is the sum of squares)} \\ &= \lambda_{\min}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2. && \text{(orthogonal matrices preserve length)} \end{aligned} \]

The second step is the transpose of a product. The last step applies orthogonal matrices preserve length to \({\mathbf{Q}}^{\top}\). That theorem applies because \({\mathbf{Q}}^{\top}\) is an orthogonal matrix: since \(\mathbf{Q}\) is square with \({\mathbf{Q}}^{\top} \mathbf{Q} = \mathbf{I}_p\), also \(\mathbf{Q} {\mathbf{Q}}^{\top} = \mathbf{I}_p\), so

\[ {({\mathbf{Q}}^{\top})}^{\top} {\mathbf{Q}}^{\top} = \mathbf{Q} {\mathbf{Q}}^{\top} = \mathbf{I}_p. \]

ExmExample 8 (Checking the bound)

Example 8 (Checking the bound) \(\mathbf{A} = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}\) has eigenvalues \(3\) and \(1\), so \(\lambda_{\min} = 1\). At \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} = {(1, 0)}^{\top}\), \({\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{A} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} = 2 \ge 1 \cdot 1\). At \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} = {(1, -1)}^{\top}\),

\[ \begin{aligned} {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{A} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} &= 2 - 1 - 1 + 2 \\ &= 2 \\ &= 1 \cdot 2: \end{aligned} \]

the bound holds with equality, since this \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\) is an eigenvector for \(\lambda_{\min}\).

LemLemma 2 (A quadratic form with small entries is small)

Lemma 2 (A quadratic form with small entries is small) Let \(\mathbf{E}\) be a \(p \times p\) matrix whose entries all satisfy \(\mathopen{}\left|e_{ij}\right|\mathclose{} \le m\). Then \(\mathopen{}\left|{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{E} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right|\mathclose{} \le p\,m\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2\) for every \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \in \mathbb{R}^p\).

Proof. Let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{a}}\vphantom{a}} = {(\mathopen{}\left|h_1\right|\mathclose{}, \ldots, \mathopen{}\left|h_p\right|\mathclose{})}^{\top}\) and \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{1}}\vphantom{1}} = {(1, \ldots, 1)}^{\top}\), both in \(\mathbb{R}^p\). Then

\[ \begin{aligned} \mathopen{}\left|{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{E} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right|\mathclose{} &= \mathopen{}\left|\sum_{i=1}^p\sum_{j=1}^ph_i\,e_{ij}\,h_j\right|\mathclose{} && \text{(matrix product)} \\ &\le \sum_{i=1}^p\sum_{j=1}^p\mathopen{}\left|h_i\right|\mathclose{}\,\mathopen{}\left|e_{ij}\right|\mathclose{}\,\mathopen{}\left|h_j\right|\mathclose{} && \text{(triangle inequality for numbers)} \\ &\le m \sum_{i=1}^p\sum_{j=1}^p\mathopen{}\left|h_i\right|\mathclose{}\,\mathopen{}\left|h_j\right|\mathclose{} && \text{(} \mathopen{}\left|e_{ij}\right|\mathclose{} \le m \text{)} \\ &= m\,\mathopen{}\left(\sum_{i=1}^p\mathopen{}\left|h_i\right|\mathclose{}\right)\mathclose{}^2 && \text{(the double sum factors)} \\ &= m\,(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{1}}\vphantom{1}} \cdot \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{a}}\vphantom{a}})^2 && \text{(dot product)} \\ &\le m\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{1}}\vphantom{1}}\right\rVert\mathclose{}^2\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{a}}\vphantom{a}}\right\rVert\mathclose{}^2 && \text{(Cauchy-Schwarz, squared)} \\ &= m\,p\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2. && \text{(} \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{1}}\vphantom{1}}\right\rVert\mathclose{}^2 = p \text{ and } \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{a}}\vphantom{a}}\right\rVert\mathclose{}^2 = \textstyle\sum_i h_i^2 \text{, which equals } \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 \text{)} \end{aligned} \]

The steps use the matrix product, the dot product and the Cauchy-Schwarz inequality.

ExmExample 9 (Checking the bound)

Example 9 (Checking the bound) Let \(\mathbf{E} = \begin{bmatrix} 0.1 & -0.2 \\ -0.2 & 0.1 \end{bmatrix}\), so \(m = 0.2\) works. Let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} = {(1, 1)}^{\top}\), so \(\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 = 2\). Then

\[ \begin{aligned} {\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top} \mathbf{E} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} &= 0.1 - 0.2 - 0.2 + 0.1 \\ &= -0.2, \end{aligned} \]

and

\[ \begin{aligned} \mathopen{}\left|-0.2\right|\mathclose{} &= 0.2 \\ &\le 2 \cdot 0.2 \cdot 2 \\ &= 0.8. \end{aligned} \]

LemTheorem 5 (Second-order sufficient condition)

Theorem 5 (Second-order sufficient condition) Let \(f : \mathbb{R}^p \to \mathbb{R}\) have first and second partial derivatives that are continuous on \(\mathbb{R}^p\). If \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is a stationary point of \(f\) (Definition 1) and \(\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\) is positive definite, then \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\) is a strict local minimizer of \(f\) (Definition 2).

Proof. \(\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\) is positive definite, and so symmetric, so its smallest eigenvalue \(\lambda\) is positive, by the eigenvalue test for definiteness. Each of the \(p^2\) entries of \(\mathbf{H}_f\) is continuous at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\): for \(\varepsilon= \lambda/ (2p)\) there is a \(\delta_{ij} > 0\) with \(\mathopen{}\left|\mathopen{}\left[\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}})\right]\mathclose{}_{ij} - \mathopen{}\left[\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\right]\mathclose{}_{ij}\right|\mathclose{} < \lambda/ (2p)\) whenever \(\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} < \delta_{ij}\). Let \(\delta\) be the smallest of these \(p^2\) numbers.

Now let \(0 < \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{} < \delta\). By Theorem 4 there is a \(\tau\in (0, 1)\) for which the first step of the next display holds; let \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}\stackrel{\text{def}}{=}\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* + \tau\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\) and \(\mathbf{E} \stackrel{\text{def}}{=}\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}) - \mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\). Since \(\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} = \tau\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{} < \delta\), every entry of \(\mathbf{E}\) has absolute value less than \(\lambda/ (2p)\), so Lemma 2 applies with \(m = \lambda/ (2p)\):

\[ \begin{aligned} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* + \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}) - f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) &= {\mathopen{}\left(\frac{\partial}{\partial \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}} f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\right)\mathclose{}}^{\top} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(}\href{#thm-taylor-mv}{\text{Theorem~4}}\text{)} \\ &= \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}})\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(} \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* \text{ is stationary)} \\ &= \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*)\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{E}\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(} \mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{y}}\vphantom{y}}) = \mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) + \mathbf{E} \text{; distribute)} \\ &\ge \frac{1}{2}\,\lambda\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 + \frac{1}{2}\,{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{E}\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} && \text{(}\href{#lem-qf-eigen-bound}{\text{Lemma~1}}\text{)} \\ &\ge \frac{1}{2}\,\lambda\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 - \frac{1}{2}\,\mathopen{}\left|{\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}}^{\top}\,\mathbf{E}\,\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right|\mathclose{} && \text{(a number is at least minus its absolute value)} \\ &\ge \frac{1}{2}\,\lambda\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 - \frac{1}{2}\,p\,\frac{\lambda}{2p}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 && \text{(}\href{#lem-qf-entry-bound}{\text{Lemma~2}}\text{, } m = \lambda/ (2p) \text{)} \\ &= \frac{\lambda}{4}\,\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}}\right\rVert\mathclose{}^2 && \text{(arithmetic)} \\ &> 0. && \text{(} \lambda> 0 \text{ and } \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} \ne \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\text{)} \end{aligned} \]

So \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) < f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) whenever \(0 < \mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} < \delta\) (take \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{h}}\vphantom{h}} = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\)).

ExmExample 10 (Classifying stationary points)

Example 10 (Classifying stationary points)  

  • \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 + x_2^2 - 2 x_1\) has the stationary point \({(1, 0)}^{\top}\) (Example 2), and its Hessian is

    \[ \begin{aligned} \mathbf{H}_f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) &= \begin{bmatrix} 2 & 0 \\ 0 & 2 \end{bmatrix} \\ &= 2 \mathbf{I}_2, \end{aligned} \]

    which is positive definite, so \({(1, 0)}^{\top}\) is a strict local minimizer.

  • \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 - x_2^2\) has the stationary point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) and Hessian \(\begin{bmatrix} 2 & 0 \\ 0 & -2 \end{bmatrix}\), which is not positive definite (\({(0, 1)}^{\top}\) gives \(-2\)). Indeed, \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is not a local minimizer (Example 3).

Show code
so_x_so <- seq(-1.5, 2.5, length.out = 101)
so_y_so <- seq(-1.5, 1.5, length.out = 101)
so_grid_so <- tidyr::expand_grid(x = so_x_so, y = so_y_so)
so_gx_so <- so_grid_so$x
so_gy_so <- so_grid_so$y
so_bowl_so <- so_gx_so^2 + so_gy_so^2 - 2 * so_gx_so
so_saddle_so <- so_gx_so^2 - so_gy_so^2
so_bowl_tbl_so <- dplyr::mutate(
  so_grid_so, z = so_bowl_so, panel = "positive definite Hessian"
)
so_saddle_tbl_so <- dplyr::mutate(
  so_grid_so, z = so_saddle_so, panel = "indefinite Hessian"
)
so_all_so <- dplyr::bind_rows(so_bowl_tbl_so, so_saddle_tbl_so)
so_order_so <- c("positive definite Hessian", "indefinite Hessian")
so_all_so$panel <- factor(so_all_so$panel, levels = so_order_so)
so_min_panel_so <- factor(so_order_so[1], levels = so_order_so)
so_sad_panel_so <- factor(so_order_so[2], levels = so_order_so)
so_min_so <- tibble::tibble(x = 1, y = 0, panel = so_min_panel_so)
so_sad_so <- tibble::tibble(x = 0, y = 0, panel = so_sad_panel_so)
so_aes_so <- ggplot2::aes(x, y)
ggplot2::ggplot(so_all_so, so_aes_so) +
  ggplot2::geom_contour(ggplot2::aes(z = z), colour = "grey70", bins = 12) +
  ggplot2::geom_point(data = so_min_so, colour = "#0072B2", size = 3) +
  ggplot2::geom_point(
    data = so_sad_so, colour = "#D55E00", size = 3, shape = 17
  ) +
  ggplot2::facet_wrap(~panel) +
  ggplot2::coord_equal() +
  ggplot2::labs(x = "first coordinate", y = "second coordinate")
Show code
import matplotlib.pyplot as plt
import numpy as np

so_x_ax = np.linspace(-1.5, 2.5, 101)
so_y_ax = np.linspace(-1.5, 1.5, 101)
so_xx_ax, so_yy_ax = np.meshgrid(so_x_ax, so_y_ax)
so_bowl_ax = so_xx_ax**2 + so_yy_ax**2 - 2 * so_xx_ax
so_saddle_ax = so_xx_ax**2 - so_yy_ax**2
fig, axes = plt.subplots(1, 2, figsize=(7, 3.5), layout="constrained")
so_style_ax = {"levels": 12, "colors": "0.7", "negative_linestyles": "solid"}
axes[0].contour(so_xx_ax, so_yy_ax, so_bowl_ax, **so_style_ax)
axes[0].plot(1, 0, "o", color="#0072B2", markersize=8)
axes[0].set_title("positive definite Hessian")
axes[1].contour(so_xx_ax, so_yy_ax, so_saddle_ax, **so_style_ax)
axes[1].plot(0, 0, "^", color="#D55E00", markersize=8)
axes[1].set_title("indefinite Hessian")
for ax in axes:
    ax.set_aspect("equal")
    ax.set_xlabel("first coordinate")
    ax.set_ylabel("second coordinate")
plt.show();
Figure 3: Level curves of the two functions in Example 10. At the stationary point \({(1, 0)}^{\top}\) of \(x_1^2 + x_2^2 - 2 x_1\) (blue circle), the Hessian is positive definite. The level curves close around a strict local minimizer. At the stationary point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) of \(x_1^2 - x_2^2\) (vermilion triangle), the Hessian is not positive definite. Along the first coordinate axis, \(x_1^2 - x_2^2\) rises, and along the second it falls. So \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is not a local minimizer.
Show code
so_x_sf <- seq(-1.5, 2.5, length.out = 101)
so_y_sf <- seq(-1.5, 1.5, length.out = 101)
so_grid_sf <- tidyr::expand_grid(x = so_x_sf, y = so_y_sf)
so_bowl_value_sf <- so_grid_sf$x^2 + so_grid_sf$y^2 - 2 * so_grid_sf$x
so_saddle_value_sf <- so_grid_sf$x^2 - so_grid_sf$y^2
so_ny_sf <- length(so_y_sf)
so_bowl_sf <- matrix(so_bowl_value_sf, nrow = so_ny_sf)
so_saddle_sf <- matrix(so_saddle_value_sf, nrow = so_ny_sf)
so_min_sf <- list(color = "#0072B2", size = 6, symbol = "circle")
so_pt_sf <- list(color = "#D55E00", size = 6, symbol = "diamond")
so_title_left_sf <- list(
  text = "positive definite Hessian",
  x = 0.22,
  y = 1,
  xref = "paper",
  yref = "paper",
  showarrow = FALSE
)
so_title_right_sf <- list(
  text = "indefinite Hessian",
  x = 0.78,
  y = 1,
  xref = "paper",
  yref = "paper",
  showarrow = FALSE
)
so_titles_sf <- list(so_title_left_sf, so_title_right_sf)
so_eye_sf <- list(x = 1.6, y = -1.6, z = 0.9)
so_camera_sf <- list(eye = so_eye_sf)
so_xaxis_sf <- list(title = "x")
so_yaxis_sf <- list(title = "y")
so_zaxis_sf <- list(title = "f")
so_left_sf <- c(0, 0.5)
so_right_sf <- c(0.5, 1)
so_dom_left_sf <- list(x = so_left_sf)
so_dom_right_sf <- list(x = so_right_sf)
so_scene_left_sf <- list(
  xaxis = so_xaxis_sf,
  yaxis = so_yaxis_sf,
  zaxis = so_zaxis_sf,
  camera = so_camera_sf,
  domain = so_dom_left_sf
)
so_scene_right_sf <- list(
  xaxis = so_xaxis_sf,
  yaxis = so_yaxis_sf,
  zaxis = so_zaxis_sf,
  camera = so_camera_sf,
  domain = so_dom_right_sf
)
so_stops_sf <- c(0, 1)
so_cols_sf <- c("#CCE0F0", "#0072B2")
so_scale_sf <- list(so_stops_sf, so_cols_sf)
plotly::plot_ly() |>
  plotly::add_surface(
    x = so_x_sf,
    y = so_y_sf,
    z = so_bowl_sf,
    colorscale = so_scale_sf,
    showscale = FALSE,
    opacity = 0.8,
    scene = "scene"
  ) |>
  plotly::add_surface(
    x = so_x_sf,
    y = so_y_sf,
    z = so_saddle_sf,
    colorscale = so_scale_sf,
    showscale = FALSE,
    opacity = 0.8,
    scene = "scene2"
  ) |>
  plotly::add_markers(
    x = 1,
    y = 0,
    z = -1,
    marker = so_min_sf,
    scene = "scene"
  ) |>
  plotly::add_markers(
    x = 0,
    y = 0,
    z = 0,
    marker = so_pt_sf,
    scene = "scene2"
  ) |>
  plotly::layout(
    scene = so_scene_left_sf,
    scene2 = so_scene_right_sf,
    annotations = so_titles_sf,
    showlegend = FALSE
  )
Show code
import html
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots

fig_alt = (
    "Two surface plots side by side. The left plot, titled positive definite "
    "Hessian, shows x squared plus y squared minus 2x over x from -1.5 to 2.5 "
    "and y from -1.5 to 1.5, a bowl opening upward whose lowest point, at (1, "
    "0), is marked by a blue circle. The right plot, titled indefinite "
    "Hessian, shows x squared minus y squared over the same region, a saddle "
    "that rises along the x axis and falls along the y axis. The origin, at "
    "the middle of the saddle, is marked by a vermilion diamond."
)

so_x_3d = np.linspace(-1.5, 2.5, 101)
so_y_3d = np.linspace(-1.5, 1.5, 101)
so_xx_3d, so_yy_3d = np.meshgrid(so_x_3d, so_y_3d)
so_bowl_3d = so_xx_3d**2 + so_yy_3d**2 - 2 * so_xx_3d
so_saddle_3d = so_xx_3d**2 - so_yy_3d**2
so_scale_3d = [[0, "#CCE0F0"], [1, "#0072B2"]]
so_axes_3d = dict(
    xaxis_title="x",
    yaxis_title="y",
    zaxis_title="f",
    camera=dict(eye=dict(x=1.6, y=-1.6, z=0.9)),
)
so_fig_3d = make_subplots(
    rows=1,
    cols=2,
    specs=[[{"type": "scene"}, {"type": "scene"}]],
    subplot_titles=("positive definite Hessian", "indefinite Hessian"),
)
so_fig_3d.add_trace(
    go.Surface(
        x=so_x_3d,
        y=so_y_3d,
        z=so_bowl_3d,
        colorscale=so_scale_3d,
        showscale=False,
        opacity=0.8,
    ),
    row=1,
    col=1,
);
so_fig_3d.add_trace(
    go.Surface(
        x=so_x_3d,
        y=so_y_3d,
        z=so_saddle_3d,
        colorscale=so_scale_3d,
        showscale=False,
        opacity=0.8,
    ),
    row=1,
    col=2,
);
so_fig_3d.add_trace(
    go.Scatter3d(
        x=[1],
        y=[0],
        z=[-1],
        mode="markers",
        marker=dict(color="#0072B2", size=4, symbol="circle"),
    ),
    row=1,
    col=1,
);
so_fig_3d.add_trace(
    go.Scatter3d(
        x=[0],
        y=[0],
        z=[0],
        mode="markers",
        marker=dict(color="#D55E00", size=4, symbol="diamond"),
    ),
    row=1,
    col=2,
);
so_fig_3d.update_layout(scene=so_axes_3d, scene2=so_axes_3d, showlegend=False);
so_html_3d = so_fig_3d.to_html(full_html=False, include_plotlyjs="cdn")
print(
    "```{=html}\n"
    + f'<div role="img" aria-label="{html.escape(fig_alt)}">\n'
    + so_html_3d
    + "\n</div>\n```"
)
Figure 4: The graphs of the two functions in Example 10, the surfaces whose level curves are in Figure 3. The surface of \(x_1^2 + x_2^2 - 2 x_1\) is a bowl, and its stationary point \({(1, 0)}^{\top}\) (circle) is the bottom, a strict local minimizer. The surface of \(x_1^2 - x_2^2\) is a saddle: it rises along the first coordinate axis and falls along the second, so the stationary point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) (diamond) is not a local minimizer.
ExmExample 11 (The condition is sufficient, not necessary)

Example 11 (The condition is sufficient, not necessary) \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 + x_2^4\) and \(g(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 - x_2^4\) both have gradient \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) at \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) and the same Hessian there, \(\begin{bmatrix} 2 & 0 \\ 0 & 0 \end{bmatrix}\), since

\[ \begin{aligned} \frac{\partial}{\partial x_2} \mathopen{}\left(\frac{\partial}{\partial x_2} (\pm x_2^4)\right)\mathclose{} &= \pm 12 x_2^2 \\ &= 0 \end{aligned} \]

at \(x_2 = 0\). That Hessian is not positive definite (\({(0, 1)}^{\top}\) gives \(0\)), so Theorem 5 says nothing about either function. In fact \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\) is a strict local minimizer of \(f\), since \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) > 0 = f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}})\) for \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\ne \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}\), but not a local minimizer of \(g\), since

\[ \begin{aligned} g(0, t) &= -t^4 \\ &< 0 \\ &= g(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}) \end{aligned} \]

for \(t \ne 0\).

DefDefinition 3 (Local maximizer)

Definition 3 (Local maximizer) Let \(f : \mathbb{R}^p \to \mathbb{R}\). A point \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^* \in \mathbb{R}^p\) is a local maximizer of \(f\) if there is a number \(\delta> 0\) such that \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*) \ge f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}})\) for all \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}\in \mathbb{R}^p\) with \(\mathopen{}\left\lVert\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}- \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}^*\right\rVert\mathclose{} < \delta\).

ExmExample 12 (A local maximizer)

Example 12 (A local maximizer) Let \(f(x) = 1 - x^2\). For every \(x \in \mathbb{R}\),

\[ \begin{aligned} f(0) - f(x) &= 1 - (1 - x^2) && \text{(substitute)} \\ &= x^2 && \text{(simplify)} \\ &\ge 0, && \text{(a square)} \end{aligned} \]

so \(f(0) \ge f(x)\) for all \(x\), and \(0\) is a local maximizer of \(f\) with any \(\delta> 0\).

DefDefinition 4 (Saddle point)

Definition 4 (Saddle point) Let \(f : \mathbb{R}^p \to \mathbb{R}\). A stationary point of \(f\) that is neither a local minimizer nor a local maximizer of \(f\) is a saddle point of \(f\) [5].

ExmExample 13 (A saddle point)

Example 13 (A saddle point) Let \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 - x_2^2\). Its gradient is

\[ \nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = {\mathopen{}\left(2 x_1,\ -2 x_2\right)\mathclose{}}^{\top}. \]

At \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}= \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\), the gradient is \(\nabla f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}) = \mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\), so \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\) is a stationary point.

For every \(t \ne 0\),

\[ \begin{aligned} f(t, 0) &= t^2 && \text{(substitute)} \\ &> 0 && \text{(} t \ne 0 \text{)} \\ &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}), && \text{(substitute)} \\ f(0, t) &= -t^2 && \text{(substitute)} \\ &< 0 && \text{(} t \ne 0 \text{)} \\ &= f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}). && \text{(substitute)} \end{aligned} \]

So every ball around \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\) contains a point with a larger value of \(f\) and a point with a smaller one. Hence \(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{0}}\vphantom{0}}_{2 \times 1}\) is neither a local minimizer nor a local maximizer, and it is a saddle point. Figure 5 shows the surface: the curve \(t \mapsto f(t, 0)\) rises from the origin along the \(x_1\) axis, and the curve \(t \mapsto f(0, t)\) falls from the origin along the \(x_2\) axis.

Show code
sp_x_sf <- seq(-1, 1, length.out = 61)
sp_grid_sf <- tidyr::expand_grid(x1 = sp_x_sf, x2 = sp_x_sf)
sp_value_sf <- sp_grid_sf$x1^2 - sp_grid_sf$x2^2
sp_n_sf <- length(sp_x_sf)
sp_z_sf <- matrix(sp_value_sf, nrow = sp_n_sf)
sp_up_sf <- tibble::tibble(x1 = sp_x_sf, x2 = 0, z = sp_x_sf^2)
sp_down_sf <- tibble::tibble(x1 = 0, x2 = sp_x_sf, z = -sp_x_sf^2)
sp_origin_sf <- tibble::tibble(x1 = 0, x2 = 0, z = 0)
sp_solid_sf <- list(color = "#D55E00", width = 5)
sp_dash_sf <- list(color = "#D55E00", dash = "dash", width = 5)
sp_marker_sf <- list(color = "#000000", size = 5)
sp_stops_sf <- c(0, 1)
sp_cols_sf <- c("#CCE0F0", "#0072B2")
sp_scale_sf <- list(sp_stops_sf, sp_cols_sf)
sp_eye_sf <- list(x = 1.6, y = -1.6, z = 0.9)
sp_camera_sf <- list(eye = sp_eye_sf)
sp_xaxis_sf <- list(title = "x1")
sp_yaxis_sf <- list(title = "x2")
sp_zaxis_sf <- list(title = "f(x)")
sp_scene_sf <- list(
  xaxis = sp_xaxis_sf,
  yaxis = sp_yaxis_sf,
  zaxis = sp_zaxis_sf,
  camera = sp_camera_sf
)
sp_legend_sf <- list(orientation = "h")
plotly::plot_ly() |>
  plotly::add_surface(
    x = sp_x_sf,
    y = sp_x_sf,
    z = sp_z_sf,
    colorscale = sp_scale_sf,
    showscale = FALSE,
    opacity = 0.8
  ) |>
  plotly::add_trace(
    data = sp_up_sf,
    x = ~x1,
    y = ~x2,
    z = ~z,
    type = "scatter3d",
    mode = "lines",
    line = sp_solid_sf,
    name = "f(t, 0) = t^2"
  ) |>
  plotly::add_trace(
    data = sp_down_sf,
    x = ~x1,
    y = ~x2,
    z = ~z,
    type = "scatter3d",
    mode = "lines",
    line = sp_dash_sf,
    name = "f(0, t) = -t^2"
  ) |>
  plotly::add_trace(
    data = sp_origin_sf,
    x = ~x1,
    y = ~x2,
    z = ~z,
    type = "scatter3d",
    mode = "markers",
    marker = sp_marker_sf,
    name = "saddle point"
  ) |>
  plotly::layout(scene = sp_scene_sf, legend = sp_legend_sf)
Show code
import html
import numpy as np
import plotly.graph_objects as go

fig_alt = (
    "Surface plot of f(x) = x1^2 - x2^2 for x1 and x2 from -1 to 1. The surface "
    "is shaped like a saddle: it curves upward along the x1 axis and downward "
    "along the x2 axis. A solid vermilion curve along the x1 axis rises away "
    "from the origin, a dashed vermilion curve along the x2 axis falls away "
    "from it, and a point marks the saddle point at the origin."
)

sp_t_3d = np.linspace(-1, 1, 61)
sp_x1_3d, sp_x2_3d = np.meshgrid(sp_t_3d, sp_t_3d)
sp_z_3d = sp_x1_3d**2 - sp_x2_3d**2
sp_zero_3d = np.zeros_like(sp_t_3d)
fig = go.Figure(data=[
    go.Surface(
        x=sp_t_3d,
        y=sp_t_3d,
        z=sp_z_3d,
        colorscale=[[0, "#CCE0F0"], [1, "#0072B2"]],
        showscale=False,
        opacity=0.6,
        showlegend=False,
    ),
    go.Scatter3d(x=sp_t_3d, y=sp_zero_3d, z=sp_t_3d**2, mode="lines",
                 line=dict(color="#D55E00", width=5),
                 name="f(t, 0) = t^2"),
    go.Scatter3d(x=sp_zero_3d, y=sp_t_3d, z=-sp_t_3d**2, mode="lines",
                 line=dict(color="#D55E00", width=5, dash="dash"),
                 name="f(0, t) = -t^2"),
    go.Scatter3d(x=[0], y=[0], z=[0], mode="markers",
                 marker=dict(color="black", size=4),
                 name="saddle point"),
])
fig.update_layout(
    scene=dict(
        xaxis_title="x1",
        yaxis_title="x2",
        zaxis_title="f(x)",
        camera=dict(eye=dict(x=1.6, y=-1.6, z=0.9)),
    ),
    legend=dict(orientation="h"),
);
print(
    "```{=html}\n"
    + f'<div role="img" aria-label="{html.escape(fig_alt)}">\n'
    + fig.to_html(full_html=False, include_plotlyjs="cdn")
    + "\n</div>\n```"
)
Figure 5: The graph of \(f(\mathord{\smash[b]{\underset{\raise.3ex\hbox{$\scriptstyle\sim$}}{x}}\vphantom{x}}) = x_1^2 - x_2^2\). Along the \(x_1\) axis (solid curve) the surface rises away from the origin, and along the \(x_2\) axis (dashed curve) it falls away, so the origin is neither the lowest nor the highest point nearby.

Definitions on this page

Back to top

References

[1]
H. Zhou, “Optimization and multivariate calculus.” Lecture notes for Biostat 216, Mathematical Methods for Biostatistics, University of California, Los Angeles, 2024. Accessed: Oct. 05, 2026. [Online]. Available: https://ucla-biostat-216.github.io/2024fall/slides/13-optim/13-optim.html
[2]
Wikipedia contributors, “Fermat’s theorem (stationary points) — Wikipedia, the free encyclopedia.” 2026. Available: https://en.wikipedia.org/wiki/Fermat%27s_theorem_(stationary_points)
[3]
Wikipedia contributors, “Taylor’s theorem — Wikipedia, the free encyclopedia.” 2026. Available: https://en.wikipedia.org/wiki/Taylor%27s_theorem
[4]
W. Rudin, Principles of mathematical analysis, 3rd ed. in International series in pure and applied mathematics. New York: McGraw-Hill, 1976.
[5]
Wikipedia contributors, “Saddle point — Wikipedia, the free encyclopedia.” 2026. Available: https://en.wikipedia.org/wiki/Saddle_point