F07 Chapter Contents
F07 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF07JBF (DPTSVX)

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

F07JBF (DPTSVX) uses the factorization
 $A=LDLT$
to compute the solution to a real system of linear equations
 $AX=B ,$
where $A$ is an $n$ by $n$ symmetric positive definite tridiagonal matrix and $X$ and $B$ are $n$ by $r$ matrices. Error bounds on the solution and a condition estimate are also provided.

## 2  Specification

 SUBROUTINE F07JBF ( FACT, N, NRHS, D, E, DF, EF, B, LDB, X, LDX, RCOND, FERR, BERR, WORK, INFO)
 INTEGER N, NRHS, LDB, LDX, INFO REAL (KIND=nag_wp) D(*), E(*), DF(*), EF(*), B(LDB,*), X(LDX,*), RCOND, FERR(NRHS), BERR(NRHS), WORK(2*N) CHARACTER(1) FACT
The routine may be called by its LAPACK name dptsvx.

## 3  Description

F07JBF (DPTSVX) performs the following steps:
1. If ${\mathbf{FACT}}=\text{'N'}$, the matrix $A$ is factorized as $A=LD{L}^{\mathrm{T}}$, where $L$ is a unit lower bidiagonal matrix and $D$ is diagonal. The factorization can also be regarded as having the form $A={U}^{\mathrm{T}}DU$.
2. If the leading $i$ by $i$ principal minor is not positive definite, then the routine returns with ${\mathbf{INFO}}=i$. Otherwise, the factored form of $A$ is used to estimate the condition number of the matrix $A$. If the reciprocal of the condition number is less than machine precision, ${\mathbf{INFO}}=\mathbf{N}+{\mathbf{1}}$ is returned as a warning, but the routine still goes on to solve for $X$ and compute error bounds as described below.
3. The system of equations is solved for $X$ using the factored form of $A$.
4. Iterative refinement is applied to improve the computed solution matrix and to calculate error bounds and backward error estimates for it.

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore
Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia

## 5  Parameters

1:     FACT – CHARACTER(1)Input
On entry: specifies whether or not the factorized form of the matrix $A$ has been supplied.
${\mathbf{FACT}}=\text{'F'}$
DF and EF contain the factorized form of the matrix $A$. DF and EF will not be modified.
${\mathbf{FACT}}=\text{'N'}$
The matrix $A$ will be copied to DF and EF and factorized.
Constraint: ${\mathbf{FACT}}=\text{'F'}$ or $\text{'N'}$.
2:     N – INTEGERInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{N}}\ge 0$.
3:     NRHS – INTEGERInput
On entry: $r$, the number of right-hand sides, i.e., the number of columns of the matrix $B$.
Constraint: ${\mathbf{NRHS}}\ge 0$.
4:     D($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array D must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: the $n$ diagonal elements of the tridiagonal matrix $A$.
5:     E($*$) – REAL (KIND=nag_wp) arrayInput
Note: the dimension of the array E must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}-1\right)$.
On entry: the $\left(n-1\right)$ subdiagonal elements of the tridiagonal matrix $A$.
6:     DF($*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array DF must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
On entry: if ${\mathbf{FACT}}=\text{'F'}$, DF must contain the $n$ diagonal elements of the diagonal matrix $D$ from the $LD{L}^{\mathrm{T}}$ factorization of $A$.
On exit: if ${\mathbf{FACT}}=\text{'N'}$, DF contains the $n$ diagonal elements of the diagonal matrix $D$ from the $LD{L}^{\mathrm{T}}$ factorization of $A$.
7:     EF($*$) – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array EF must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}-1\right)$.
On entry: if ${\mathbf{FACT}}=\text{'F'}$, EF must contain the $\left(n-1\right)$ subdiagonal elements of the unit bidiagonal factor $L$ from the $LD{L}^{\mathrm{T}}$ factorization of $A$.
On exit: if ${\mathbf{FACT}}=\text{'N'}$, EF contains the $\left(n-1\right)$ subdiagonal elements of the unit bidiagonal factor $L$ from the $LD{L}^{\mathrm{T}}$ factorization of $A$.
8:     B(LDB,$*$) – REAL (KIND=nag_wp) arrayInput
Note: the second dimension of the array B must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NRHS}}\right)$.
On entry: the $n$ by $r$ right-hand side matrix $B$.
9:     LDB – INTEGERInput
On entry: the first dimension of the array B as declared in the (sub)program from which F07JBF (DPTSVX) is called.
Constraint: ${\mathbf{LDB}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
10:   X(LDX,$*$) – REAL (KIND=nag_wp) arrayOutput
Note: the second dimension of the array X must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NRHS}}\right)$.
On exit: if ${\mathbf{INFO}}={\mathbf{0}}$ or $\mathbf{N}+{\mathbf{1}}$, the $n$ by $r$ solution matrix $X$.
11:   LDX – INTEGERInput
On entry: the first dimension of the array X as declared in the (sub)program from which F07JBF (DPTSVX) is called.
Constraint: ${\mathbf{LDX}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{N}}\right)$.
12:   RCOND – REAL (KIND=nag_wp)Output
On exit: the reciprocal condition number of the matrix $A$. If RCOND is less than the machine precision (in particular, if ${\mathbf{RCOND}}=0.0$), the matrix is singular to working precision. This condition is indicated by a return code of ${\mathbf{INFO}}=\mathbf{N}+{\mathbf{1}}$.
13:   FERR(NRHS) – REAL (KIND=nag_wp) arrayOutput
On exit: the forward error bound for each solution vector ${\stackrel{^}{x}}_{j}$ (the $j$th column of the solution matrix $X$). If ${x}_{j}$ is the true solution corresponding to ${\stackrel{^}{x}}_{j}$, ${\mathbf{FERR}}\left(j\right)$ is an estimated upper bound for the magnitude of the largest element in (${\stackrel{^}{x}}_{j}-{x}_{j}$) divided by the magnitude of the largest element in ${\stackrel{^}{x}}_{j}$.
14:   BERR(NRHS) – REAL (KIND=nag_wp) arrayOutput
On exit: the component-wise relative backward error of each solution vector ${\stackrel{^}{x}}_{j}$ (i.e., the smallest relative change in any element of $A$ or $B$ that makes ${\stackrel{^}{x}}_{j}$ an exact solution).
15:   WORK($2×{\mathbf{N}}$) – REAL (KIND=nag_wp) arrayWorkspace
16:   INFO – INTEGEROutput
On exit: ${\mathbf{INFO}}=0$ unless the routine detects an error (see Section 6).

## 6  Error Indicators and Warnings

Errors or warnings detected by the routine:
${\mathbf{INFO}}<0$
If ${\mathbf{INFO}}=-i$, the $i$th argument had an illegal value. An explanatory message is output, and execution of the program is terminated.
If ${\mathbf{INFO}}=i$ and $i\le {\mathbf{N}}$, the leading minor of order $i$ of $A$ is not positive definite, so the factorization could not be completed, and the solution has not been computed. ${\mathbf{RCOND}}=0.0$ is returned.
${\mathbf{INFO}}={\mathbf{N}}+1$
The diagonal matrix $D$ is nonsingular, but RCOND is less than machine precision, meaning that the matrix is singular to working precision. Nevertheless, the solution and error bounds are computed because there are a number of situations where the computed solution can be more accurate than the value of RCOND would suggest.

## 7  Accuracy

For each right-hand side vector $b$, the computed solution $\stackrel{^}{x}$ is the exact solution of a perturbed system of equations $\left(A+E\right)\stackrel{^}{x}=b$, where
 $E ≤ c n ε R RT , where ​ R = L D12 ,$
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision. See Section 10.1 of Higham (2002) for further details.
If $x$ is the true solution, then the computed solution $\stackrel{^}{x}$ satisfies a forward error bound of the form
 $x-x^∞ x^∞ ≤ wc condA,x^,b$
where $\mathrm{cond}\left(A,\stackrel{^}{x},b\right)={‖\left|{A}^{-1}\right|\left(\left|A\right|\left|\stackrel{^}{x}\right|+\left|b\right|\right)‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }\le \mathrm{cond}\left(A\right)={‖\left|{A}^{-1}\right|\left|A\right|‖}_{\infty }\le {\kappa }_{\infty }\left(A\right)$. If $\stackrel{^}{x}$ is the $j$th column of $X$, then ${w}_{c}$ is returned in ${\mathbf{BERR}}\left(j\right)$ and a bound on ${‖x-\stackrel{^}{x}‖}_{\infty }/{‖\stackrel{^}{x}‖}_{\infty }$ is returned in ${\mathbf{FERR}}\left(j\right)$. See Section 4.4 of Anderson et al. (1999) for further details.

The number of floating point operations required for the factorization, and for the estimation of the condition number of $A$ is proportional to $n$. The number of floating point operations required for the solution of the equations, and for the estimation of the forward and backward error is proportional to $nr$, where $r$ is the number of right-hand sides.
The condition estimation is based upon Equation (15.11) of Higham (2002). For further details of the error estimation, see Section 4.4 of Anderson et al. (1999).
The complex analogue of this routine is F07JPF (ZPTSVX).

## 9  Example

This example solves the equations
 $AX=B ,$
where $A$ is the symmetric positive definite tridiagonal matrix
 $A = 4.0 -2.0 0 0 0 -2.0 10.0 -6.0 0 0 0 -6.0 29.0 15.0 0 0 0 15.0 25.0 8.0 0 0 0 8.0 5.0$
and
 $B = 6.0 10.0 9.0 4.0 2.0 9.0 14.0 65.0 7.0 23.0 .$
Error estimates for the solutions and an estimate of the reciprocal of the condition number of $A$ are also output.

### 9.1  Program Text

Program Text (f07jbfe.f90)

### 9.2  Program Data

Program Data (f07jbfe.d)

### 9.3  Program Results

Program Results (f07jbfe.r)