Skip to content
Glacius
CalculusConcept reference

Linear-Form Gradients

A linear form f(x)=a^Tx multiplies each input coordinate by a fixed coefficient and sums.

On this page 7 sections
  1. Overview
  2. Each coefficient is a sensitivity
  3. The gradient is not the value
  4. Read a weighted score
  5. Key takeaway
  6. Sources & further reading
  7. Concept connections

01Each coefficient is a sensitivity#

A linear form f(x)=aTxf(x)=a^Tx multiplies each input coordinate by a fixed coefficient and sums. Its gradient records how that scalar changes when each input coordinate changes independently.

For a=(2,3)a=(2,-3), the function is f(x)=2x13x2f(x)=2x_1-3x_2. Differentiating with respect to x1x_1 gives 22; differentiating with respect to x2x_2 gives 3-3.

x(aTx)=a.\nabla_x(a^Tx)=a.

02The gradient is not the value#

At x=(4,1)x=(4,1), the function value is 83=58-3=5. Its gradient is still (2,3)(2,-3). The value depends on the input; this gradient does not, because the coefficients are constant.

The column gradient has the same shape as the column input xx. The expression aTxa^Tx is a scalar even though its gradient has several entries.

Check your reasoning

Find the column gradient of f(x)=4x₁−2x₂.

  1. A(4,−2)
  2. B(4x₁,−2x₂)
  3. C2
Show answer and explanation
(4,−2)

Each coordinate derivative is its fixed coefficient.

03Read a weighted score#

For a supplied score s(w)=3w1+w22w3s(w)=3w_1+w_2-2w_3, the gradient with respect to the weights is (3,1,2)(3,1,-2). Here the feature values are the fixed coefficients. Variable names do not change the rule; the chosen differentiation variable does matter.

A constant offset adds no derivative. For s(w)=3w1+w22w3+7s(w)=3w_1+w_2-2w_3+7, the gradient is unchanged. This follows from the constant derivative rule.

Check your reasoning

A draft uses ∇ₓ(aᵀx)=a when a=x, for f=xᵀx. What assumption failed?

  1. Ax needed to be a scalar
  2. Ba was not constant with respect to x
  3. CThe dot product was undefined
Show answer and explanation
a was not constant with respect to x

Both copies of x vary, so there are additional derivative contributions.

The coefficient vector must be constant with respect to the variable. If it also depends on that variable, its derivative contributes additional terms. Checking what is held fixed is part of applying the rule correctly.

Key takeaway

Compute the gradient of aᵀx with respect to x for a constant real vector a.

  • Compute the gradient of aᵀx with respect to x for a constant real vector a.

Sources & further reading

  1. [1]
  2. [2]

Reference this concept

Link to this page, a section, or an individual figure.

Glacius. “Linear-Form Gradients.” Math behind ML. /learn/c-linear-gradient