# NAG Library Routine Document

## 1Purpose

d02mzf interpolates components of the solution of a system of first-order differential equations from information provided by those integrators in Sub-chapter D02M–N using methods set up by calls to d02mvf, d02nvf or d02nwf.

## 2Specification

Fortran Interface
 Subroutine d02mzf ( tsol, sol, m, neq, ysav,
 Integer, Intent (In) :: m, ldysav, neq, sdysav Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: tsol, ysav(ldysav,sdysav), rwork(50+4*neq) Real (Kind=nag_wp), Intent (Out) :: sol(m)
#include nagmk26.h
 void d02mzf_ (const double *tsol, double sol[], const Integer *m, const Integer *ldysav, const Integer *neq, const double ysav[], const Integer *sdysav, const double rwork[], Integer *ifail)

## 3Description

d02mzf evaluates the first m components of the solution of a system of ordinary differential equations at any point using natural polynomial interpolation based on information generated by the integrator. This information must be passed unchanged to d02mzf. d02mzf should not normally be used to extrapolate outside the range of values obtained from the above routine.

## 4References

See the D02M–N Sub-chapter Introduction.

## 5Arguments

1:     $\mathbf{tsol}$ – Real (Kind=nag_wp)Input
On entry: the point at which the first m components of the solution are to be evaluated. tsol should not normally be an extrapolation point. Extrapolation is permitted but not recommended.
2:     $\mathbf{sol}\left({\mathbf{m}}\right)$ – Real (Kind=nag_wp) arrayOutput
On exit: the calculated value of the solution at tsol.
3:     $\mathbf{m}$ – IntegerInput
On entry: the number of components of the solution whose values are required.
Constraint: $1\le {\mathbf{m}}\le {\mathbf{neq}}$.
4:     $\mathbf{ldysav}$ – IntegerInput
On entry: the value used for the argument ldysav when calling the integrator.
Constraint: ${\mathbf{ldysav}}\ge 1$.
5:     $\mathbf{neq}$ – IntegerInput
On entry: the value used for the argument neq when calling the integrator.
Constraint: $1\le {\mathbf{neq}}\le {\mathbf{ldysav}}$.
6:     $\mathbf{ysav}\left({\mathbf{ldysav}},{\mathbf{sdysav}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the values provided in the array ysav on return from the integrator.
7:     $\mathbf{sdysav}$ – IntegerInput
On entry: the value used for the argument sdysav when calling the integrator.
8:     $\mathbf{rwork}\left(50+4×{\mathbf{neq}}\right)$ – Real (Kind=nag_wp) arrayInput
On entry: the values provided in the array rwork on return from the integrator.
9:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
 On entry, ${\mathbf{m}}<1$, or ${\mathbf{ldysav}}<1$, or ${\mathbf{neq}}<1$, or ${\mathbf{m}}>{\mathbf{neq}}$, or ${\mathbf{neq}}>{\mathbf{ldysav}}$.
${\mathbf{ifail}}=2$
On entry, when accessing an element of the array rwork an unexpected quantity was found. You have not passed the correct array to d02mzf or has overwritten elements of this array.
${\mathbf{ifail}}=3$
On entry, d02mzf has been called for extrapolation. Before returning with this error exit, the value of the solution at tsol is calculated and placed in sol.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

## 7Accuracy

The solution values returned will be of a similar accuracy to those computed by the integrator.

## 8Parallelism and Performance

d02mzf is not thread safe and should not be called from a multithreaded user program. Please see Section 3.12.1 in How to Use the NAG Library and its Documentation for more information on thread safety.
d02mzf is not threaded in any implementation.

None.

## 10Example

This example solves the well-known stiff Robertson problem written in implicit form
 $r1 = -0.04a + 1.0E4bc - a′ r2 = 0.04a - 1.0E4bc - 3.0E7⁢b2 - b′ r3 = 3.0E7⁢b2 - c′$
with initial conditions $a=1.0$ and $b=c=0.0$ over the range $\left[0,0.1\right]$ with vector error control (${\mathbf{itol}}=4$), the BDF method (setup routine d02nvf) and functional iteration. The Jacobian is calculated numerically if the functional iteration encounters difficulty and the integration is in one-step mode (${\mathbf{itask}}=2$), with natural interpolation to calculate the solution at intervals of $0.02$ using d02mzf externally. d02nby is used for monitr.

### 10.1Program Text

Program Text (d02mzfe.f90)

### 10.2Program Data

Program Data (d02mzfe.d)

### 10.3Program Results

Program Results (d02mzfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017