How can you show that k(x,z)=(1+x⊤z)2 on R2 is a valid kernel by finding a feature map ϕ with k(x,z)=ϕ(x)⊤ϕ(z)? What is Mercer's condition, and why does it show that k(x,z)=x⊤z−1 is not a valid kernel?

Supervised learning, Kernel methods
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you understand that a kernel is an inner product in some feature space, and how to test whether a function can be a kernel.

Key idea

A kernel computes an inner product ϕ(x)⊤ϕ(z) without computing ϕ. A symmetric k is a valid (Mercer) kernel exactly when every Gram matrix Kij=k(xi,xj), built on any finite set of points, is positive semidefinite (PSD), meaning c⊤Kc≥0 for every vector c. Expanding (1+x⊤z)2 gives a 6-dimensional ϕ. For x⊤z−1, k(0,0)=−1<0, so even a 1×1 Gram matrix fails.

Steps

  1. Expand with x=(x1,x2) and z=(z1,z2): (1+x1z1+x2z2)2=1+2x1z1+2x2z2+x12z12+x22z22+2x1x2z1z2.
  2. Read off one feature per term: ϕ(x)=(1,2x1,2x2,x12,x22,2x1x2). The 2 factors are needed so that each product of matching entries gives the coefficient 2. Check that ϕ(x)⊤ϕ(z) reproduces every term.
  3. Explain the trick. Methods that use data only through inner products (the SVM dual, kernel ridge regression, kernel PCA) can replace xi⊤xj with k(xi,xj) and never build ϕ. This matters when ϕ is huge or infinite-dimensional, as for the RBF kernel exp⁡(−∥x−z∥2/2σ2).
  4. State Mercer's condition: k is symmetric and ∑i,jcicjk(xi,xj)≥0 for every finite set of points x1,…,xn and all real numbers c1,…,cn.
  5. Counterexample: for k(x,z)=x⊤z−1, take the single point x=0. Then K=[k(0,0)]=[−1], which is not PSD. No feature map can exist, because ϕ(0)⊤ϕ(0)=∥ϕ(0)∥2 can never be negative.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: Why does the lasso give coefficients that are exactly zero while ridge does not? When the design is orthonormal (X⊤X=I), what is the lasso solution and how does it compare with ridge?
Next in Supervised learning: A linear support vector regression (SVR) with an ε-insensitive loss, ε=0.5 and C=2, is trained on five points (x,y) and learns f(x)=x (so w=1, b=0). The points are A=(0,0.1), B=(1,1.5), C=(2,1.5), D=(3,1.8) and E=(4,5.0). Using the dual variables, which points are support vectors, and which have zero training loss?