#include <complex.h> int main () { double x1, x2, x3, x4; int n1, n2, num; double theta_or_r1, theta_or_r2; complex z3, error; /* problem (1) n1 = 3, n2 = 4 */ theta_or_r1 = 3; theta_or_r2 = 4; z3 = complex(1,2); n1 = 3, n2 = 4; num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4); printf("For n1=3, n2=4, the number of solution is = %d\n", num); printf("R2 = %f phi2 = %f\n", x1, x2); printf("R2 = %f phi2 = %f\n", x3, x4); /* problem (2), n1 = 2, n2 = 4 */ n1 = 2, n2 = 4; num = complexsolve(n1, n2, theta_or_r1, theta_or_r2, z3, x1, x2, x3, x4); printf("For n1=2, n2=4, the number of solution is = %d\n", num); printf("phi1 = %f phi2 = %f\n", x1, x2); printf("phi1 = %f phi2 = %f\n", x3, x4); }
For n1=3, n2=4, the number of solution is = 1 R2 = 5.196488 phi2 = 0.964540 R2 = NaN phi2 = NaN For n1=2, n2=4, the number of solution is = 2 phi1 = -0.613277 phi2 = 1.942631 phi1 = 2.827574 phi2 = 0.271667