/* nag_elliptic_integral_rj (s21bdc) 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   r, rj, x, y, z;
  Integer  ix, iy, iz;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_elliptic_integral_rj (s21bdc) Example Program Results\n");
  printf(
          "      x      y      z      r       nag_elliptic_integral_rj\n");

  for (ix = 1; ix <= 3; ix++)
    {
      x = ix*0.5;
      for (iy = ix; iy <= 3; iy++)
        {
          y = iy*0.5;
          for (iz = iy; iz <= 3; iz++)
            {
              z = iz*0.5;
              r = 2.0;
              /* nag_elliptic_integral_rj (s21bdc).
               * Symmetrised elliptic integral of 3rd kind R_J(xyzr)
               */
              rj = nag_elliptic_integral_rj(x, y, z, r, &fail);
              if (fail.code != NE_NOERROR)
                {
                  printf("Error from "
                          "nag_elliptic_integral_rj (s21bdc).\n%s\n",
                          fail.message);
                  exit_status = 1;
                  goto END;
                }
              printf(" %7.2f%7.2f%7.2f%7.2f%12.4f\n", x, y, z, r, rj);
            }
        }
    }

 END:
  return exit_status;
}