---
title: "Conjugate gradient numerical (5 iterations)"
subject: "Computational Techniques in Civil Engineering"
chapter: 2
key: "semester_8/computational_techniques_in_civil_engineering:cg-numerical-3-0-1"
source: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/cg-numerical-3-0-1
site: BCT Engineering
---

# Conjugate gradient numerical (5 iterations)

Computational Techniques in Civil Engineering · Chapter 2: Solutions of linear equations

- Asked in: 2070 Bhadra, 8 marks
- Video: [SOLUTION OF TWO VARIABLES EQUATIONS BY CONJUGATE GRADIENT METHOD](https://www.youtube.com/watch?v=qiTt6R9wbPw) — Civil Engineer
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/cg-numerical-3-0-1
- Whole chapter: https://www.bctengineer.com/md/semester_8/computational_techniques_in_civil_engineering/chapter-2

## Question

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

$$
\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}
$$

## 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.

## Answer

$A=\begin{bmatrix}3&0&1\\0&-1&3\\1&3&0\end{bmatrix}$, $b=\{1,-12,2\}^T$. $A$ is symmetric but not positive definite (its eigenvalues are $3.61,\,2,\,-3.61$). The CG recurrences can still be applied as long as no denominator $d^TAd$ is zero, but $\alpha$ may then become negative. Take $x_0=0$, so $r_0=b$ and $d_0=r_0=\{1,-12,2\}^T$.

#### Iteration 1
$$
\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
$$
\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
$$
\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: $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.0$, $-0.1154-11.8846=-12$, $1.6538+0.3462=2$.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. A = [3 0 1; 0 -1 3; 1 3 0] has eigenvalues 3.61, 2, -3.61. What does this mean for CG?
   A. It is positive definite, so CG is guaranteed to work
   B. It is symmetric but indefinite; the recurrences still work while no d^T A d is zero, and alpha may be negative
   C. CG cannot be started at all
   D. It is diagonally dominant so CG is replaced by Gauss-Seidel
   Answer: B. A has a negative eigenvalue so it is not positive definite, but CG formulas can be applied as long as no denominator d^T A d is zero. Alpha may then be negative. (Key point: Matrix property)

2. In iteration 1, why is alpha_0 = 149/(-281) negative?
   A. Because r0 was computed with the wrong sign
   B. Because x0 was not zero
   C. Because the energy in direction d0 is negative: d0^T A d0 = -281 (A is indefinite)
   D. Because beta is negative
   Answer: C. r0^T r0 = 149 is positive, while d0^T A d0 = -281 is negative for this indefinite matrix, so alpha_0 is negative. (Key point: First step)

3. How is beta_0 found in iteration 1 (value 1.97015)?
   A. beta_0 = 293.52/149 = r_1^T r_1 / (r_0^T r_0)
   B. beta_0 = 149/293.52
   C. beta_0 = alpha_0 x r_1
   D. beta_0 = d_0^T A d_0 / r_0^T r_0
   Answer: A. beta is the new squared residual norm over the old one: 293.52/149 = 1.97015. (Key point: Beta formula)

4. Why are iterations 4 and 5 not needed?
   A. The question limits to three iterations
   B. The step length became zero
   C. A became singular
   D. The residual r3 is zero after three iterations, so the solution is exact
   Answer: D. For a 3 x 3 system CG needs at most 3 steps, and r3 = 0 means x3 already satisfies Ax = b. (Key point: Stopping)

## Related in Computational Techniques in Civil Engineering

- [Conjugate gradient three iterations (10,-6,0)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-three-iterations-a) — Computational Techniques in Civil Engineering, chapter 2
- [Conjugate gradient numerical (3,0,2 system)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-numerical-3-0-2) — Computational Techniques in Civil Engineering, chapter 2, asked 2×
- [Conjugate gradient numerical (2,-1 system)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-numerical-three-unknowns-a) — Computational Techniques in Civil Engineering, chapter 2, asked 2×
- [Linear solution techniques; CG two iterations](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Asolution-techniques-cg-numerical-two-iter) — Computational Techniques in Civil Engineering, chapter 2
- [CG algorithm; Gauss-Seidel numerical](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-algorithm-gauss-seidel-numerical) — Computational Techniques in Civil Engineering, chapter 2
- [Conjugate gradient method and algorithm](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-method-algorithm) — Computational Techniques in Civil Engineering, chapter 2, asked 2×

## Related in other subjects

- [Conjugate beam: slope and deflection at free end C](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aconjugate-udl-15-3kn-2076b) — Theory of Structures I, chapter 4, asked 2×
- [Conjugate beam: slope and deflection at free end C](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aconjugate-udl-2knm-10kn-5kn-2068) — Theory of Structures I, chapter 4, asked 2×
- [Conjugate beam: slope and deflection at free end](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aconjugate-beam-24kn-10knm) — Theory of Structures I, chapter 4
- [Conjugate beam: overhanging beam free end](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aconjugate-overhang-300-150) — Theory of Structures I, chapter 4
