Solution (source code)

= Solution

Use compatible dimensions $A\in\mathbb R^{d\times d}$ and $b,x\in\mathbb R^d$; the printed “b-by-b” size is read consistently with the displayed products and domain. Take <derivatives> as column <gradients>. <Symmetry> of $A$ gives
$$
\boxed{\nabla f(x)=2Ax+b,\qquad H_f(x)=2A.}
$$
For example, the directional <differential> of $x^TAx$ is $dx^TAx+x^TAdx=2(Ax)^Tdx$. The linear term contributes $b$ to the <gradient> and zero to the <Hessian matrix>.