/* nag_elliptic_integral_rd (s21bcc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 2 revised, 1992.
 */

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

int main(void)
{
  Integer  exit_status = 0;
  double   rd, x, y, z;
  Integer  ix, iy;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_elliptic_integral_rd (s21bcc) Example Program Results\n");
  printf(
          "      x      y      z       nag_elliptic_integral_rd (s21bcc)  \n");
  for (ix = 1; ix <= 3; ix++)
    {
      x = ix*0.5;
      for (iy = ix; iy <= 3; iy++)
        {
          y = iy*0.5;
          z = 1.0;
          /* nag_elliptic_integral_rd (s21bcc).
           * Symmetrised elliptic integral of 2nd kind R_D(xyz)
           */
          rd = nag_elliptic_integral_rd(x, y, z, &fail);
          if (fail.code != NE_NOERROR)
            {
              printf(
                      "Error from nag_elliptic_integral_rd (s21bcc).\n%s\n",
                      fail.message);
              exit_status = 1;
              goto END;
            }
          printf(" %7.2f%7.2f%7.2f%12.4f\n", x, y, z, rd);
        }
    }

 END:
  return exit_status;
}