Skip to main content

Conjugate gradient numerical (5 iterations)

Short answer

Although A is symmetric but not positive definite, CG recurrences still solve the system in three iterations from zero: x1=1.6538, x2=0.1154, x3=-3.9615, residual zero; alpha may be negative because d^T A d can be negative.

Solve the following equation by using the conjugate gradient method (maximum 5 iterations).

[3010−13130]{x1x2x3}={1−122}\begin{bmatrix} 3 & 0 & 1 \\ 0 & -1 & 3 \\ 1 & 3 & 0 \end{bmatrix}\begin{Bmatrix} x_1 \\ x_2 \\ x_3 \end{Bmatrix} = \begin{Bmatrix} 1 \\ -12 \\ 2 \end{Bmatrix}

A=[3010−13130]A=\begin{bmatrix}3&0&1\\0&-1&3\\1&3&0\end{bmatrix}, b={1,−12,2}Tb=\{1,-12,2\}^T. AA is symmetric but not positive definite (its eigenvalues are 3.61, 2, −3.613.61,\,2,\,-3.61). The CG recurrences can still be applied as long as no denominator dTAdd^TAd is zero, but α\alpha may then become negative. Take x0=0x_0=0, so r0=br_0=b and d0=r0={1,−12,2}Td_0=r_0=\{1,-12,2\}^T.

Iteration 1

Ad0={5, 18, −35}Tα0=149−281=−0.53025x1={−0.5302, 6.3630, −1.0605}Tr1={3.6512, −2.4555, −16.5587}Tβ0=293.55149=1.97015,d1={5.6214, −26.0973, −12.6184}T\begin{aligned} Ad_0&=\{5,\,18,\,-35\}^T\\ \alpha_0&=\frac{149}{-281}=-0.53025\\ x_1&=\{-0.5302,\,6.3630,\,-1.0605\}^T\\ r_1&=\{3.6512,\,-2.4555,\,-16.5587\}^T\\ \beta_0&=\frac{293.55}{149}=1.97015,\quad d_1=\{5.6214,\,-26.0973,\,-12.6184\}^T \end{aligned}

Iteration 2

Ad1={4.2458, −11.7579, −72.6706}Tα1=293.551247.7=0.23527x2={0.7923, 0.2230, −4.0293}Tr2={2.6523, 0.3108, 0.5388}Tβ1=7.4217293.55=0.025282,d2={2.7944, −0.3490, 0.2197}T\begin{aligned} Ad_1&=\{4.2458,\,-11.7579,\,-72.6706\}^T\\ \alpha_1&=\frac{293.55}{1247.7}=0.23527\\ x_2&=\{0.7923,\,0.2230,\,-4.0293\}^T\\ r_2&=\{2.6523,\,0.3108,\,0.5388\}^T\\ \beta_1&=\frac{7.4217}{293.55}=0.025282,\quad d_2=\{2.7944,\,-0.3490,\,0.2197\}^T \end{aligned}

Iteration 3

Ad2={8.6031, 1.0082, 1.7475}Tα2=7.421724.073=0.30830x3={1.6538, 0.1154, −3.9615}Tr3≈{0, 0, 0}T\begin{aligned} Ad_2&=\{8.6031,\,1.0082,\,1.7475\}^T\\ \alpha_2&=\frac{7.4217}{24.073}=0.30830\\ x_3&=\{1.6538,\,0.1154,\,-3.9615\}^T\\ r_3&\approx\{0,\,0,\,0\}^T \end{aligned}

The residual is zero after three iterations, so iterations 4 and 5 are not needed.

Answer: x1=1.6538 (43/26), x2=0.1154 (3/26), x3=−3.9615 (−103/26)x_1=1.6538\ (43/26),\ x_2=0.1154\ (3/26),\ x_3=-3.9615\ (-103/26). Check: 3(1.6538)−3.9615=1.03(1.6538)-3.9615=1.0, −0.1154−11.8846=−12-0.1154-11.8846=-12, 1.6538+0.3462=21.6538+0.3462=2.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computational Techniques in Civil Engineering chapter 2 questions →