# Biconjugate gradient stabilized method

In numerical linear algebra, the biconjugate gradient stabilized method, often abbreviated as BiCGSTAB, is an iterative method developed by H. A. van der Vorst for the numerical solution of nonsymmetric linear systems. It is a variant of the biconjugate gradient method (BiCG) and has faster and smoother convergence than the original BiCG as well as other variants such as the conjugate gradient squared method (CGS). It is a Krylov subspace method. Unlike the original BiCG method, it doesn't require multiplication by the transpose of the system matrix.

## Algorithmic steps
### Unpreconditioned BiCGSTAB

In the following sections, (x,y) = x$^T$ y denotes the dot product of vectors. To solve a linear system Ax = b, BiCGSTAB starts with an initial guess x$_0$ and proceeds as follows:
* r$_0$ = b − Ax$_0$
* Choose an arbitrary vector r̂$_0$ such that (r̂$_0$, r$_0$) ≠ 0, e.g., r̂$_0$ = r$_0$
* ρ$_0$ = (r̂$_0$, r$_0$)
* p$_0$ = r$_0$
* For i = 1, 2, 3, …
** v = Ap$_{i−1}$
** α = ρ$_{i−1}$/(r̂$_0$, v)
** h = x$_{i−1}$ + αp$_{i−1}$
** s = r$_{i−1}$ − αv
** If h is accurate enough, i.e., if s is small enough, then set x$_i$ = h and quit
** t = As
** ω = (t, s)/(t, t)
** x$_i$ = h + ωs
** r$_i$ = s − ωt
** If x$_i$ is accurate enough, i.e., if r$_i$ is small enough, then quit
** ρ$_i$ = (r̂$_0$, r$_i$)
** β = (ρ$_i$/ρ$_{i−1}$)(α/ω)
** p$_i$ = r$_i$ + β(p$_{i−1}$ − ωv)
In some cases, choosing the vector r̂$_0$ randomly improves numerical stability.

### Preconditioned BiCGSTAB

Preconditioners are usually used to accelerate convergence of iterative methods. To solve a linear system Ax = b with a preconditioner K = K$_1$K$_2$ ≈ A, preconditioned BiCGSTAB starts with an initial guess x$_0$ and proceeds as follows:
* r$_0$ = b − Ax$_0$
* Choose an arbitrary vector r̂$_0$ such that (r̂$_0$, r$_0$) ≠ 0, e.g., r̂$_0$ = r$_0$
* ρ$_0$ = (r̂$_0$, r$_0$)
* p$_0$ = r$_0$
* For i = 1, 2, 3, …
** y = K −1 2 K −1 1 p$_{i−1}$
** v = Ay
** α = ρ$_{i−1}$/(r̂$_0$, v)
** h = x$_{i−1}$ + αy
** s = r$_{i−1}$ − αv
** If h is accurate enough then x$_i$ = h and quit
** z = K −1 2 K −1 1 s
** t = Az
** ω = (K −1 1 t, K −1 1 s)/(K −1 1 t, K −1 1 t)
** x$_i$ = h + ωz
** r$_i$ = s − ωt
** If x$_i$ is accurate enough then quit
** ρ$_i$ = (r̂$_0$, r$_i$)
** β = (ρ$_i$/ρ$_{i−1}$)(α/ω)
** p$_i$ = r$_i$ + β(p$_{i−1}$ − ωv)
This formulation is equivalent to applying unpreconditioned BiCGSTAB to the explicitly preconditioned system
    Ãx̃ = b̃
with Ã = K −1 1 AK −1 2 , x̃ = K$_2$x and b̃ = K −1 1 b. In other words, both left- and right-preconditioning are possible with this formulation.

## Derivation
### BiCG in polynomial form

In BiCG, the search directions p$_i$ and p̂$_i$ and the residuals r$_i$ and r̂$_i$ are updated using the following recurrence relations:
    p$_i$ = r$_{i−1}$ + β$_i$p$_{i−1}$,
    p̂$_i$ = r̂$_{i−1}$ + β$_i$p̂$_{i−1}$,
    r$_i$ = r$_{i−1}$ − α$_i$Ap$_i$,
    r̂$_i$ = r̂$_{i−1}$ − α$_i$A$^T$p̂$_i$.
The constants α$_i$ and β$_i$ are chosen to be
    α$_i$ = ρ$_i$/(p̂$_i$, Ap$_i$),
    β$_i$ = ρ$_i$/ρ$_{i−1}$
where ρ$_i$ = (r̂$_{i−1}$, r$_{i−1}$) so that the residuals and the search directions satisfy biorthogonality and biconjugacy, respectively, i.e., for i ≠ j,
    (r̂$_i$, r$_j$) = 0,
    (p̂$_i$, Ap$_j$) = 0.
It is straightforward to show that
    r$_i$ = P$_i$(A)r$_0$,
    r̂$_i$ = P$_i$(A$^T$)r̂$_0$,
    p$_{i+1}$ = T$_i$(A)r$_0$,
    p̂$_{i+1}$ = T$_i$(A$^T$)r̂$_0$
where P$_i$(A) and T$_i$(A) are ith-degree polynomials in A. These polynomials satisfy the following recurrence relations:
    P$_i$(A) = P$_{i−1}$(A) − α$_i$AT$_{i−1}$(A),
    T$_i$(A) = P$_i$(A) + β$_{i+1}$T$_{i−1}$(A).

### Derivation of BiCGSTAB from BiCG

It is unnecessary to explicitly keep track of the residuals and search directions of BiCG. In other words, the BiCG iterations can be performed implicitly. In BiCGSTAB, one wishes to have recurrence relations for
    r̃$_i$ = Q$_i$(A)P$_i$(A)r$_0$
where Q$_i$(A) = (I − ω$_1$A)(I − ω$_2$A)⋯(I − ω$_i$A) with suitable constants ω$_j$ instead of r$_i$ = P$_i$(A)r$_0$ in the hope that Q$_i$(A) will enable faster and smoother convergence in r̃$_i$ than r$_i$.
It follows from the recurrence relations for P$_i$(A) and T$_i$(A) and the definition of Q$_i$(A) that
    Q$_i$(A)P$_i$(A)r$_0$ = (I − ω$_i$A)(Q$_{i−1}$(A)P$_{i−1}$(A)r$_0$ − α$_i$AQ$_{i−1}$(A)T$_{i−1}$(A)r$_0$),
which entails the necessity of a recurrence relation for Q$_i$(A)T$_i$(A)r$_0$. This can also be derived from the BiCG relations:
    Q$_i$(A)T$_i$(A)r$_0$ = Q$_i$(A)P$_i$(A)r$_0$ + β$_{i+1}$(I − ω$_i$A)Q$_{i−1}$(A)P$_{i−1}$(A)r$_0$.
Similarly to defining r̃$_i$, BiCGSTAB defines
    p̃$_{i+1}$ = Q$_i$(A)T$_i$(A)r$_0$.
Written in vector form, the recurrence relations for p̃$_i$ and r̃$_i$ are
    p̃$_i$ = r̃$_{i−1}$ + β$_i$(I − ω$_{i−1}$A)p̃$_{i−1}$,
    r̃$_i$ = (I − ω$_i$A)(r̃$_{i−1}$ − α$_i$Ap̃$_i$).
To derive a recurrence relation for x$_i$, define
    s$_i$ = r̃$_{i−1}$ − α$_i$Ap̃$_i$.
The recurrence relation for r̃$_i$ can then be written as
    r̃$_i$ = r̃$_{i−1}$ − α$_i$Ap̃$_i$ − ω$_i$As$_i$,
which corresponds to
    x$_i$ = x$_{i−1}$ + α$_i$p̃$_i$ + ω$_i$s$_i$.

### Determination of BiCGSTAB constants

Now it remains to determine the BiCG constants α$_i$ and β$_i$ and choose a suitable ω$_i$.
In BiCG, β$_i$ = ρ$_i$/ρ$_{i−1}$ with
    ρ$_i$ = (r̂$_{i−1}$, r$_{i−1}$) = (P$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$).
Since BiCGSTAB does not explicitly keep track of r̂$_i$ or r$_i$, ρ$_i$ is not immediately computable from this formula. However, it can be related to the scalar
    ρ̃$_i$ = (Q$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$) = (r̂$_0$, Q$_{i−1}$(A)P$_{i−1}$(A)r$_0$) = (r̂$_0$, r$_{i−1}$).
Due to biorthogonality, r$_{i−1}$ = P$_{i−1}$(A)r$_0$ is orthogonal to U$_{i−2}$(A$^T$)r̂$_0$ where U$_{i−2}$(A$^T$) is any polynomial of degree i − 2 in A$^T$. Hence, only the highest-order terms of P$_{i−1}$(A$^T$) and Q$_{i−1}$(A$^T$) matter in the dot products (P$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$) and (Q$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$). The leading coefficients of P$_{i−1}$(A$^T$) and Q$_{i−1}$(A$^T$) are (−1)$^{i−1}$α$_1$α$_2$⋯α$_{i−1}$ and (−1)$^{i−1}$ω$_1$ω$_2$⋯ω$_{i−1}$, respectively. It follows that
    ρ$_i$ = (α$_1$/ω$_1$)(α$_2$/ω$_2$)⋯(α$_{i−1}$/ω$_{i−1}$)ρ̃$_i$,
and thus
    β$_i$ = ρ$_i$/ρ$_{i−1}$ = (ρ̃$_i$/ρ̃$_{i−1}$)(α$_{i−1}$/ω$_{i−1}$).
A simple formula for α$_i$ can be similarly derived. In BiCG,
    α$_i$ = ρ$_i$/(p̂$_i$, Ap$_i$) = (P$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$)/(T$_{i−1}$(A$^T$)r̂$_0$, AT$_{i−1}$(A)r$_0$).
Similarly to the case above, only the highest-order terms of P$_{i−1}$(A$^T$) and T$_{i−1}$(A$^T$) matter in the dot products thanks to biorthogonality and biconjugacy. It happens that P$_{i−1}$(A$^T$) and T$_{i−1}$(A$^T$) have the same leading coefficient. Thus, they can be replaced simultaneously with Q$_{i−1}$(A$^T$) in the formula, which leads to
    α$_i$ = (Q$_{i−1}$(A$^T$)r̂$_0$, P$_{i−1}$(A)r$_0$)/(Q$_{i−1}$(A$^T$)r̂$_0$, AT$_{i−1}$(A)r$_0$) = ρ̃$_i$/(r̂$_0$, AQ$_{i−1}$(A)T$_{i−1}$(A)r$_0$) = ρ̃$_i$/(r̂$_0$, Ap̃$_i$).
Finally, BiCGSTAB selects ω$_i$ to minimize r̃$_i$ = (I − ω$_i$A)s$_i$ in 2-norm as a function of ω$_i$. This is achieved when
    ((I − ω$_i$A)s$_i$, As$_i$) = 0,
giving the optimal value
    ω$_i$ = (As$_i$, s$_i$)/(As$_i$, As$_i$).

## Generalization

BiCGSTAB can be viewed as a combination of BiCG and GMRES where each BiCG step is followed by a GMRES(1) (i.e., GMRES restarted at each step) step to repair the irregular convergence behavior of CGS, as an improvement of which BiCGSTAB was developed. However, due to the use of degree-one minimum residual polynomials, such repair may not be effective if the matrix A has large complex eigenpairs. In such cases, BiCGSTAB is likely to stagnate, as confirmed by numerical experiments.
One may expect that higher-degree minimum residual polynomials may better handle this situation. This gives rise to algorithms including BiCGSTAB2 and the more general BiCGSTAB(l). In BiCGSTAB(l), a GMRES(l) step follows every l BiCG steps. BiCGSTAB2 is equivalent to BiCGSTAB(l) with l = 2.