NAG Library Manual, Mark 30
Interfaces:  FL   CL   CPP   AD 

NAG CL Interface Introduction
Example description
/* nag_specfun_psi_deriv_real (s14aec) Example Program.
 *
 * Copyright 2024 Numerical Algorithms Group.
 *
 * NAG C Library
 *
 * Mark 30.0, 2024.
 */

#include <nag.h>
#include <stdio.h>

int main(void) {
  Integer exit_status = 0, k;
  NagError fail;
  double x, y;

  INIT_FAIL(fail);

  /* Skip heading in data file */
  scanf("%*[^\n]");
  printf("nag_specfun_psi_deriv_real (s14aec) Example Program Results\n\n");
  printf("   x      k    (d^k/dx^k)psi(x)\n");
  while (scanf("%lf %" NAG_IFMT "%*[^\n]", &x, &k) != EOF)
  {
    /* nag_specfun_psi_deriv_real (s14aec).
     * Derivative of the psi function psi(x)
     */
    y = nag_specfun_psi_deriv_real(x, k, &fail);
    if (fail.code == NE_NOERROR)
      printf("%5.1f %5" NAG_IFMT "     %13.4e\n", x, k, y);
    else {
      printf("Error from nag_specfun_psi_deriv_real (s14aec).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
  }
END:
  return exit_status;
}