void main() { final complexNumber1 = Complex(2, 3); final complexNumber2 = Complex(4, -1); // Basic operations final additionResult = complexNumber1 + complexNumber2; final subtractionResult = complexNumber1 - complexNumber2; final multiplicationResult = complexNumber1 * complexNumber2; final divisionResult = complexNumber1 / complexNumber2; print('Complex Number 1: $complexNumber1'); print('Complex Number 2: $complexNumber2'); print('Addition Result: $additionResult'); print('Subtraction Result: $subtractionResult'); print('Multiplication Result: $multiplicationResult'); print('Division Result: $divisionResult'); // Other operations final conjugate = complexNumber1.conjugate(); final absoluteValue = complexNumber1.abs(); final phase = complexNumber1.arg(); print('Conjugate of Complex Number 1: $conjugate'); print('Absolute Value of Complex Number 1: $absoluteValue'); print('Phase of Complex Number 1: $phase'); } class Complex { final double real; final double imaginary; Complex(this.real, this.imaginary); Complex operator +(Complex other) { return Complex(real + other.real, imaginary + other.imaginary); } Complex operator -(Complex other) { return Complex(real - other.real, imaginary - other.imaginary); } Complex operator *(Complex other) { final newReal = real * other.real - imaginary * other.imaginary; final newImaginary = real * other.imaginary + imaginary * other.real; return Complex(newReal, newImaginary); } Complex operator /(Complex other) { final denominator = other.real * other.real + other.imaginary * other.imaginary; final newReal = (real * other.real + imaginary * other.imaginary) / denominator; final newImaginary = (imaginary * other.real - real * other.imaginary) / denominator; return Complex(newReal, newImaginary); } Complex conjugate() { return Complex(real, -imaginary); } double abs() { return sqrt(real * real + imaginary * imaginary); } double arg() { return atan2(imaginary, real); } @override String toString() { if (imaginary >= 0) { return '$real + ${imaginary}i'; } else { return '$real - ${-imaginary}i'; } } }