Pure Programmer
Blue Matrix


Cluster Map

Project: Complex Number Class

[[Complex_number|Complex numbers]] is a number that can be expressed in the form `a + bi` where `a` and `b` are real numbers and `i` represents the imaginary quantity `sqrt(-1)`. Define a complex number class that can perform multiplication, division, reciprocal, addition, subtraction, absolute value (magnitude), argument (phase), square root, exponential, and natural logarithm functions.

Output
$ g++ -std=c++17 ComplexNumberClass.cpp -o ComplexNumberClass -lfmt $ ./ComplexNumberClass a: 1.000000+1.000000i b: 3.000000+4.000000i a + b: 4.000000+5.000000i a - b: -2.000000-3.000000i a * b: -1.000000+7.000000i 1 / a: 0.500000-0.500000i 1 / b: 0.120000-0.160000i a / b: 0.280000-0.040000i |a|: 1.41421 |b|: 5 φ(a): 0.785398 φ(b): 0.927295 sqrt(a): 1.098684+0.455090i sqrt(b): 2.000000+1.000000i exp(a): 1.468694+2.287355i exp(b): -13.128783-15.200784i ln(a): 0.346574+0.785398i ln(b): 1.609438+0.927295i

Solution