/* nag_elliptic_integral_E (s21bfc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 9, 2009.
 */
/* Pre-processor includes */
#include <stdio.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, e, phi, pi;
  NagError fail;

  INIT_FAIL(fail);

  printf("nag_elliptic_integral_E (s21bfc) Example Program Results\n");
  printf("\n    phi    dm       nag_elliptic_integral_E\n\n");
  pi = nag_pi;
  for (ix = 1; ix <= 3; ix++)
    {
      phi = ix*pi/6.00e0;
      dm = ix*0.250e0;
      /*
       * nag_elliptic_integral_E (s21bfc)
       * Elliptic integral of 2nd kind, Legendre form, E( phi |m)
       */
      e = nag_elliptic_integral_E(phi, dm, &fail);
      if (fail.code != NE_NOERROR)
        {
          printf("Error from nag_elliptic_integral_E (s21bfc).\n%s\n",
                  fail.message);
          exit_status = 1;
          goto END;
        }
      printf("%7.2f%7.2f%12.4f\n", phi, dm, e);
    }

 END:

  return exit_status;
}