/* nag_zeros_quartic_real (c02alc) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* NAG C Library
*
* Mark 30.0, 2024.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
double a, b, c, d, e;
double *errest = 0, *zeroi = 0, *zeror = 0;
Integer i;
Integer exit_status = 0;
NagError fail;
INIT_FAIL(fail);
printf("nag_zeros_quartic_real (c02alc) Example Program Results\n\n");
if (!(errest = NAG_ALLOC(4, double)) || !(zeroi = NAG_ALLOC(4, double)) ||
!(zeror = NAG_ALLOC(4, double))) {
printf("Allocation failure\n");
exit_status = -1;
goto END;
}
/* Skip heading in data file */
scanf("%*[^\n]");
scanf("%lf %lf %lf %lf %lf", &e, &a, &b, &c, &d);
/* nag_zeros_quartic_real (c02alc).
* Zeros of a real quartic polynomial with real coefficients
*/
nag_zeros_quartic_real(e, a, b, c, d, zeror, zeroi, errest, &fail);
if (fail.code == NE_NOERROR) {
printf(" Roots of quartic equation Error estimates\n");
printf(" (machine-dependent)\n\n");
for (i = 0; i <= 3; ++i) {
printf("%s %10.5f %10.5f%s %g\n", " z =", zeror[i], zeroi[i], "*i",
errest[i]);
}
} else {
printf("Error from nag_zeros_quartic_real (c02alc).\n%s\n", fail.message);
exit_status = 1;
goto END;
}
END:
NAG_FREE(errest);
NAG_FREE(zeroi);
NAG_FREE(zeror);
return exit_status;
}