// // Complex Multiplication and Division using Polar representations // 2008-05-23 Tomonori Kouya // #include #include using namespace std; main() { complex c, d; double c_radius, d_radius, c_arg, d_arg; // Input c & d // cout << "Input c like \"(c_real, c_image)\" -> "; cin >> c; // cout << "Input d like \"(d_real, d_image)\" -> "; cin >> d; c.real() = -sqrt(3.0) ; c.imag() = -2.0 ; d.real() = -sqrt(3.0) / 2.0; d.imag() = -3.0 / 2.0; // Confirm values cout << "c = " << c << ", d = " << d << endl; // To polar form c_radius = abs(c); c_arg = arg(c); d_radius = abs(d); d_arg = arg(d); // Confirm polar forms cout << "c (r, theta): " << c_radius << ", " << c_arg << endl; cout << "d (r, theta): " << d_radius << ", " << d_arg << endl; // c * d, c / d cout << "c * d (r, theta): " << c_radius * d_radius << ", " << c_arg + d_arg << endl; cout << "c / d (r, theta): " << c_radius / d_radius << ", " << c_arg - d_arg << endl; // Canonical Form cout << "c * d(polar) : " << polar(c_radius * d_radius, c_arg + d_arg) << endl; cout << "c * d(standard) : " << c * d << endl; cout << "c / d(polar) : " << polar(c_radius / d_radius, c_arg - d_arg) << endl; cout << "c / d(standard) : " << c / d << endl; return 0; }