NAG Library Manual, Mark 29.3
```/* D01RK_T1W_F C++ Header Example Program.
*
* Copyright 2023 Numerical Algorithms Group.
* Mark 29.3, 2023.
*/

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

int main()
{
// Scalars
int exit_status = 0;

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

Integer           key = 6;
double            pi  = X01AAC;
a      = 0.0;
b      = 2.0 * pi;
epsabs = 0.0;
epsrel = 1.0e-4;

Integer            maxsub = 20;
Integer            lrinfo = 80;
Integer            liinfo = 20;
Integer *          iinfo  = 0;

iinfo = new Integer[liinfo];

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

double            inc = 1.0, zero = 0.0;
Integer           iuser[1];
iuser[0]                 = 0;
ruser[0]                 = 30.0;
ruser[1]                 = 1.0;

const Integer &         nx,
Integer &               iflag)
{
// dco/c++ used here to perform AD of the following
for (int i = 0; i < nx; i++)
{
fv[i] = x[i] * sin(ruser[0] * x[i]) * cos(ruser[1] * x[i]);
}
};

// Call the AD routine with each active input derivative incremented in turn
dco::derivative(ruser[0]) = inc;
ifail                     = -1;
abserr, rinfo, iinfo, ifail);
dco::derivative(ruser[0]) = zero;
if (ifail < 0)
{
cout << "\n ** nag::ad::d01rk failed error exit ifail = " << ifail << endl;
goto END;
}
double dr1;
dr1 = dco::derivative(result);

dco::derivative(ruser[1]) = inc;
ifail                     = -1;
abserr, rinfo, iinfo, ifail);
double dr2;
dr2 = dco::derivative(result);

// Print inputs and primal outputs.
cout << "\n lower limit of integration (a) = " << dco::value(a) << endl;
cout << " upper limit of integration (b) = " << dco::value(b) << endl;
cout << " choice of Gaussian rule (key)  = " << key << endl;
cout << " absolute accuracy requested    = " << dco::value(epsabs) << endl;
cout << " relative accuracy requested    = " << dco::value(epsrel) << endl;
cout << " maximum number of subintervals = " << maxsub << endl;
cout.setf(ios::scientific, ios::floatfield);
cout.precision(4);
if (ifail >= 0)
{
cout << "\n approximation to the integral  : " << dco::value(result)
<< endl;
cout << " estimate of the absolute error : " << dco::value(abserr) << endl;
cout << " number of function evaluations : " << iinfo[0] << endl;
}

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

cout << "\n Derivative of solution w.r.t to parameter in ruser:\n";
cout << " dI/ruser[0] = " << dr1 << endl;
cout << " dI/druser[1] = " << dr2 << endl;

END:

delete[] rinfo;
delete[] iinfo;
return exit_status;
}
```