/* nag_complex(a02bac) Example Program * * Copyright 1991 Numerical Algorithms Group. * * Mark 2, 1991. */ #include #include #include #include int main(void) { Complex v, w, z; double r, theta, x, y; Boolean equal, not_equal; Vprintf("a02bac Example Program Results\n"); x = 2.0; y = -3.0; z = a02bac(x, y); Vprintf("x = %7.4f, y = %7.4f\n", x, y); Vprintf("z = complex(x,y) = (%7.4f, %7.4f)\n", z.re, z.im); Vprintf("real(z) = %7.4f\n", a02bbc(z)); Vprintf("imag(z) = %7.4f\n\n", a02bcc(z)); v = a02bac(3.0, 1.25); w = a02bac(2.5, -1.75); Vprintf("v = (%7.4f, %7.4f)\n", v.re, v.im); Vprintf("w = (%7.4f, %7.4f)\n", w.re, w.im); z = a02cac(v, w); Vprintf("z = v+w = (%7.4f, %7.4f)\n", z.re, z.im); z = a02cbc(v, w); Vprintf("z = v-w = (%7.4f, %7.4f)\n", z.re, z.im); z = a02ccc(v, w); Vprintf("z = v*w = (%7.4f, %7.4f)\n", z.re, z.im); z = a02cdc(v, w); Vprintf("z = v/w = (%7.4f, %7.4f)\n", z.re, z.im); z = a02cec(w); Vprintf("z = -w = (%7.4f, %7.4f)\n", z.re, z.im); z = a02cfc(w); Vprintf("z = conjugate(w) = (%7.4f, %7.4f)\n", z.re, z.im); equal = a02cgc(v, w); if (equal) Vprintf("v == w\n"); else Vprintf("v != w\n"); not_equal = a02chc(w, z); if (not_equal) Vprintf("w != z\n\n"); else Vprintf("w == z\n\n"); theta = a02dac(z); Vprintf("theta = arg(z) = %7.4f\n", theta); r = a02dbc(z); Vprintf("r = abs(z) = %7.4f\n", r); v = a02dcc(z); Vprintf("v = sqrt(z) = (%7.4f, %7.4f)\n", v.re, v.im); v = a02ddc(z, (Integer)3); Vprintf("v = z**3 = (%7.4f, %7.4f)\n", v.re, v.im); v = a02dec(z, 2.5); Vprintf("v = z**2.5 = (%7.4f, %7.4f)\n", v.re, v.im); v = a02dfc(z, w); Vprintf("v = z**w = (%7.4f, %7.4f)\n", v.re, v.im); v = a02dgc(z); Vprintf("v = log(z) = (%7.4f, %7.4f)\n", v.re, v.im); z = a02dhc(v); Vprintf("z = exp(v) = (%7.4f, %7.4f)\n", z.re, z.im); v = a02djc(z); Vprintf("v = sin(z) = (%7.4f, %7.4f)\n", v.re, v.im); v = a02dkc(z); Vprintf("v = cos(z) = (%7.4f, %7.4f)\n", v.re, v.im); v = a02dlc(z); Vprintf("v = tan(z) = (%7.4f, %7.4f)\n", v.re, v.im); v = a02cdc(a02djc(z),a02dkc(z)); Vprintf("sin(z)/cos(z) = (%7.4f, %7.4f)\n", v.re, v.im); return EXIT_SUCCESS; }