---
title: "Conjugate gradient numerical (2,-1 system)"
subject: "Computational Techniques in Civil Engineering"
chapter: 2
key: "semester_8/computational_techniques_in_civil_engineering:cg-numerical-three-unknowns-a"
source: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/cg-numerical-three-unknowns-a
site: BCT Engineering
---

# Conjugate gradient numerical (2,-1 system)

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

- Asked in: 2078 Chaitra, 5 marks
- 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-three-unknowns-a
- Whole chapter: https://www.bctengineer.com/md/semester_8/computational_techniques_in_civil_engineering/chapter-2

## Question

Solve the given system of equations using the conjugate gradient method.

$2x_1 - x_2 = 4$

$-x_1 + 2x_2 - x_3 = 0$

$-x_2 + 2x_3 = 0$

## Short answer

Starting from x0=0, compute residuals, step lengths, and direction updates. After three iterations, the exact solution is x1=3, x2=2, x3=1.

## Answer

Matrix form: $A=\begin{bmatrix}2&-1&0\\-1&2&-1\\0&-1&2\end{bmatrix}$, $b=\{4,0,0\}^T$. $A$ is symmetric and positive definite. Start with $x_0=\{0,0,0\}^T$.

$r_0=b-Ax_0=\{4,0,0\}^T$, $d_0=r_0$.

#### Iteration 1
$$
\begin{aligned}
Ad_0&=\{8,-4,0\}^T\\
\alpha_0&=\frac{r_0^Tr_0}{d_0^TAd_0}=\frac{16}{32}=0.5\\
x_1&=\{2,0,0\}^T\\
r_1&=r_0-\alpha_0Ad_0=\{0,2,0\}^T\\
\beta_0&=\frac{4}{16}=0.25,\quad d_1=r_1+\beta_0d_0=\{1,2,0\}^T
\end{aligned}
$$

#### Iteration 2
$$
\begin{aligned}
Ad_1&=\{0,3,-2\}^T\\
\alpha_1&=\frac{4}{6}=0.6667\\
x_2&=\{2.6667,\,1.3333,\,0\}^T\\
r_2&=\{0,0,1.3333\}^T\\
\beta_1&=\frac{1.7778}{4}=0.4444,\quad d_2=\{0.4444,\,0.8889,\,1.3333\}^T
\end{aligned}
$$

#### Iteration 3
$$
\begin{aligned}
Ad_2&=\{0,0,1.7778\}^T\\
\alpha_2&=\frac{1.7778}{2.3704}=0.75\\
x_3&=\{3,\,2,\,1\}^T\\
r_3&=\{0,0,0\}^T
\end{aligned}
$$

The residual is zero after $n=3$ iterations, as expected for CG.

**Answer: $x_1=3,\ x_2=2,\ x_3=1$.** (Check: $2(3)-2=4$, $-3+4-1=0$, $-2+2=0$.)

## Check yourself

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

1. With x0 = 0, what is r0?
   A. {0,0,0}
   B. {2,0,0}
   C. b = {4,0,0}
   D. {-4,0,0}
   Answer: C. r0 = b - A*0 = b. (Key point: Initial residual)

2. What is alpha_0?
   A. 0.25
   B. 0.5 = 16/32
   C. 2
   D. 1
   Answer: B. r0^T r0 = 16 and d0^T A d0 = 4*8 = 32. (Key point: First alpha)

3. After how many iterations does CG converge here?
   A. 3, equal to n
   B. 1
   C. 2
   D. 6
   Answer: A. Exact arithmetic gives the solution in n steps. (Key point: Termination)

4. What is the solution?
   A. x1 = 2, x2 = 3, x3 = 1
   B. x1 = 4, x2 = 0, x3 = 0
   C. x1 = 1, x2 = 2, x3 = 3
   D. x1 = 3, x2 = 2, x3 = 1
   Answer: D. Check: 2(3)-2 = 4; -3+4-1 = 0; -2+2 = 0. (Key point: Result)

## Close variants set in other exams

- [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×

## Related in Computational Techniques in Civil Engineering

- [Conjugate gradient numerical (5 iterations)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-numerical-3-0-1) — 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×
- [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
- [Why conjugate gradient over Gaussian methods](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Acg-vs-gaussian) — Computational Techniques in Civil Engineering, chapter 2

## Related in other subjects

- [Two-mass system equations, X2/F, F-I and F-V analogies](https://www.bctengineer.com/question.md?key=semester_3%2Fcontrol_systems%3Ade-tf-fi-fv-m1-m2) — Control Systems, chapter 2
