/* nag_specfun_erfcx_real (s15agc) Example Program.
*
* Copyright 2022 Numerical Algorithms Group.
*
* Mark 28.3, 2022.
*/
/* Pre-processor includes */
#include <nag.h>
#include <stdio.h>
int main(void) {
/*Integer scalar and array declarations */
Integer exit_status = 0;
/*Double scalar and array declarations */
double x, y;
NagError fail;
const char *str_fail;
INIT_FAIL(fail);
printf("nag_specfun_erfcx_real (s15agc) Example Program Results\n");
/* Skip heading in data file */
scanf("%*[^\n] ");
printf("\n%s\n\n", " x erfcx(x) fail");
while (scanf("%lf%*[^\n] ", &x) != EOF)
{
/*
* nag_specfun_erfcx_real (s15agc)
* Scaled complement of error function, erfcx(x)
*/
y = nag_specfun_erfcx_real(x, &fail);
if (fail.code != NE_NOERROR) {
if (fail.code == NW_HI || fail.code == NW_NEG || fail.code == NW_REAL) {
/* nag_code_to_error_name (x04ndc).
* Converts NAG error code to its string value
*/
str_fail = nag_code_to_error_name(fail.code);
printf("%14.5e %-14.5e %s\n", x, y, str_fail);
} else {
printf("Error from nag_specfun_erfcx_real (s15agc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
} else {
printf("%14.5e %-14.5e\n", x, y);
}
}
END:
return exit_status;
}