#include #include #include "complexes.h" using namespace std; struct complexe saisir_complexe() { struct complexe z; cout << "Saisir la partie réele" << endl; cin >> z.Re; cout << "Saisir la partie imaginaire" << endl; cin >> z.Im; return z; } void affiche_complexe(struct complexe z) { cout << z.Re << " + (" << z.Im << ")i" << endl; } struct complexe conjuge(struct complexe z) { return {z.Re, -z.Im}; } struct complexe oppose(struct complexe z) { return {-z.Re, -z.Im}; } struct complexe inverse(struct complexe z) { struct complexe z_inv; if (z.Im == 0) { z_inv.Im = -z.Im/(z.Re*z.Re + z.Im*z.Im); } if (z.Re == 0) { z_inv.Re = z.Re/(z.Re*z.Re + z.Im*z.Im); } return z_inv; } float module(struct complexe z) { float mod = sqrt(pow(z.Re, 2)+pow(z.Im, 2)); return mod; } float argument(struct complexe z) { float mod = module(z); float arg_abs; float arg_sign; arg_abs = acos(z.Re/mod); arg_sign = asin(z.Im/mod); if (arg_sign < 0) { return -arg_abs; } return arg_abs; } struct complexe add_complexe( struct complexe z, struct complexe zp ) { return {z.Re + zp.Re, z.Im + zp.Im}; } struct complexe mult_complexe( struct complexe z, struct complexe zp ) { return {z.Re * zp.Re - z.Im * zp.Im, z.Re * zp.Im + z.Im * zp.Re}; } struct complexe div_complexe( struct complexe z, struct complexe zp ) { return mult_complexe(z, inverse(zp)); }