Solution (source code)

= Solution

\b[The claim is true], with
$$
\boxed{M=A^TA}.
$$
It is a <symmetric positive-definite matrix>: for every nonzero <vector> $z$, the fact that $A$ is an <invertible matrix> gives $z^TMz=\|Az\|_2^2>0$. Since $Ax_*=b$, every candidate $x$ satisfies
$$
\|Ax-b\|_2^2=\|A(x-x_*)\|_2^2
=(x-x_*)^TA^TA(x-x_*)=\|x-x_*\|_M^2.
$$
The <generalized minimal residual method> therefore minimizes precisely this <weighted norm> of the error over the <linear span> of $Q_k$. The same <matrix> $M$ works for every $k$ and does not depend on $b$.