/* nag_elliptic_integral_pi (s21bgc) Example Program.
 *
 * Copyright 2017 Numerical Algorithms Group.
 *
 * Mark 26.1, 2017.
 */
/* Pre-processor includes */
#include <stdio.h>
#include <math.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nags.h>
#include <nagx01.h>

int main(void)
{
  /*Integer scalar and array declarations */
  Integer exit_status = 0;
  Integer ix;
  /*Double scalar and array declarations */
  double dm, dn, p, phi, pi;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_elliptic_integral_pi (s21bgc) Example Program Results\n");
  printf("\n    dn     phi    dm       nag_elliptic_integral_pi\n\n");
  /*
   * nag_pi (x01aac)
   */
  pi = nag_pi;
  for (ix = 1; ix <= 3; ix++) {
    phi = ix * pi / 6.00e0;
    dm = ix * 0.250e0;
    dn = (pow(((-(1.00e0))), (ix + 1))) * ix * 0.10e0;
    /*
     * nag_elliptic_integral_pi (s21bgc)
     * Elliptic integral of 3rd kind, Legendre form, Pi (n; phi |m)
     */
    p = nag_elliptic_integral_pi(dn, phi, dm, &fail);
    if (fail.code != NE_NOERROR) {
      printf("Error from nag_elliptic_integral_pi (s21bgc).\n%s\n",
             fail.message);
      exit_status = 1;
      goto END;
    }
    printf("%7.2f%7.2f%7.2f%12.4f\n", dn, phi, dm, p);
  }

END:

  return exit_status;
}