NAG Library Manual, Mark 27.2
```/* D02PE_T1W_F C++ Header Example Program.
*
* Copyright 2021 Numerical Algorithms Group.
*
* Mark 27.2, 2021.
*/

#include <dco.hpp>
#include <iostream>
#include <math.h>
#include <nag.h>
#include <stdio.h>
using namespace std;

#ifdef __cplusplus
extern "C"
{
#endif
static void NAG_CALL f(void *&                  ad_handle,
const Integer &          n,
Integer                  iuser[],
#ifdef __cplusplus
}
#endif

int main(void)
{
const Integer n = 2, npts = 8;
const Integer liwsav = 130;
const Integer lrwsav = 350 + 32 * n;

Integer exit_status = 0;

nagad_t1w_w_rtype *rwsav = 0, *thresh = 0, *ygot = 0, *yinit = 0, *ymax = 0;
nagad_t1w_w_rtype *ypgot = 0, *y = 0, ruser[1];
Integer *          iwsav = 0, iuser[1];
double *           dr    = 0;

cout << "D02PE_T1W_F C++ Header Example Program Results\n\n";

iwsav  = new Integer[liwsav];
dr     = new double[n];

// Set initial conditions for ODE and parameters for the integrator.
Integer           method = 1;
tstart    = 0.0;
tol       = 1.0e-4;
tend      = 2.0 * nag_math_pi;
yinit[0]  = 0.0;
yinit[1]  = 1.0;
hstart    = 0.0;
thresh[0] = 1.0e-8;
thresh[1] = 1.0e-8;

{
double tolr = dco::value(tol);
cout << "\n  Calculation with tol = " << tolr << endl;
}
cout.setf(ios::fixed);
cout.setf(ios::right);
cout.precision(3);
{
double t = dco::value(tstart);
cout << "\n    t         y1        y2" << endl;
cout.width(6);
cout << t;
}
for (int k = 0; k < n; k++)
{
double yr = dco::value(yinit[k]);
cout.width(10);
cout << yr;
}
cout << endl;

// Set control for output
double tinc = 2.0 * nag_math_pi / (double)(npts);

// Create AD configuration data object
Integer ifail     = 0;

for (int i = 0; i < n; ++i)
{

double inc                = 1.0;
dco::derivative(yinit[i]) = inc;

for (int j = 0; j < n; ++j)
{
y[j] = yinit[j];
}
// Initialize Runge-Kutta method for integrating ODE
ifail = 0;
iwsav, rwsav, ifail);

twant = tstart;
for (int j = 0; j < npts; ++j)
{
twant = twant + tinc;

ifail = 0;
iuser, -1, ruser, iwsav, rwsav, ifail);

if (i == 0)
{
cout.width(6);
cout << dco::value(tgot);
for (int k = 0; k < n; ++k)
{
cout.width(10);
cout << dco::value(ygot[k]);
}
cout << endl;
}
}

dr[i] = dco::derivative(ygot[0]);

double zero               = 0.0;
dco::derivative(yinit[i]) = zero;
}

Integer           fevals, stepcost, stepsok;
ifail = 0;
rwsav, ifail);
cout << "\n Cost of the integration in evaluations of f is " << fevals;
cout << endl;

cout << "\n Derivatives calculated: First order tangents\n";
cout << " Computational mode    : algorithmic\n";

cout << "\n Derivatives: (solution w.r.t. initial values)\n";

cout.setf(ios::scientific, ios::floatfield);
cout.precision(5);
cout << " dy(t)/dy0  = ";
cout.width(12);
cout << dr[0] << endl;
cout << " dy(t)/dy0' = ";
cout.width(12);
cout << dr[1] << endl;

delete[] thresh;
delete[] ygot;
delete[] y;
delete[] yinit;
delete[] ypgot;
delete[] ymax;
delete[] iwsav;
delete[] rwsav;
delete[] dr;
return exit_status;
}

static void NAG_CALL f(void *&                  ad_handle,