# Solver ARITHMETIC on Complex Numbers

Algebra ->  Algebra  -> Complex Numbers Imaginary Numbers Solvers and Lesson -> Solver ARITHMETIC on Complex Numbers      Log On

 Ad: Algebrator™ solves your algebra problems and provides step-by-step explanations! Ad: Algebra Solved!™: algebra software solves algebra homework problems with step-by-step help!

 Algebra: Complex Numbers Solvers Lessons Answers archive Quiz In Depth

### Source code of 'ARITHMETIC on Complex Numbers'

This Solver (ARITHMETIC on Complex Numbers) was created by by ichudov(499)  : View Source, Show, Put on YOUR site
About ichudov: I am not a paid tutor, I am the owner of this web site.

 ==section input Evaluate *[input a_real=2] + *[input a_imag=1]i *[choice operation + - * /] *[input b_real=2] + *[input b_imag=1]i. ==section solution perl my \$result; sub signed { my \$a = shift @_; return \$a if \$a < 0; \$a =~ s/^(\d)/+\$1/; return \$a; } if ( \$operation eq '+' ) { \$r_real = \$a_real + \$b_real; \$r_imag = \$a_imag + \$b_imag; print "\$r_real ".signed( \$r_imag)."i.

Solution:Addition of two complex numbers a + bi and c+di is done according to formula:

(a + bi) + (c+di) = (a+c) + (b+d)i.
In our case, {{{ (\$a_real + \$a_imag*i) + (\$b_real + \$b_imag*i) = (\$a_real+\$b_real) + (\$a_imag+\$b_imag)*i = \$r_real+\$r_imag*i}}}."; } elsif ( \$operation eq '-' ) { \$r_real = \$a_real - \$b_real; \$r_imag = \$a_imag - \$b_imag; print " Solution:Subtraction of two complex numbers a + bi and c+di is done according to formula:

(a + bi) - (c+di) = (a+c) - (b+d)i.
In our case, {{{(\$a_real + \$a_imag*i) - (\$b_real + \$b_imag*i) = (\$a_real - \$b_real) + (\$a_imag-\$b_imag)i = \$r_real + \$r_imag*i}}}"; } elsif ( \$operation eq '*' ) { \$r_real = \$a_real * \$b_real - \$a_imag * \$b_imag; \$r_imag = \$a_real * \$b_imag + \$a_imag * \$b_real; print " Solution:Multiplication of two complex numbers a + bi and c+di is done according to formula:

(a + bi) * (c+di) = (ac-bd) + (ad+bc)i.
In our case, {{{(\$a_real + \$a_imag*i) * (\$b_real + \$b_imag*i) = (\$a_real*\$b_real - \$a_imag*\$b_imag) + (\$a_real*\$b_imag + \$a_imag*\$b_real)*i = \$r_real + \$r_imag*i}}}"; } elsif ( \$operation eq '/' ) { my \$d = \$b_real*\$b_real + \$b_imag*\$b_imag; \$r_real = (\$b_imag*\$a_imag+\$b_real*\$a_real)/\$d; \$r_imag = (\$b_real*\$a_imag-\$b_imag*\$a_real)/\$d; print " Solution:Division of two complex numbers a + bi and c+di is done according to formula:

{{{(a + bi) / (c+di) = (db+ca)/(c^2+d^2) + i*((cb-da)/(c^2+d^2))}}}
In our case, {{{(\$a_real + \$a_imag*i) / (\$b_real + \$b_imag*i) = \$r_real + \$r_imag*i}}}"; } ==section output r_real r_imag ==section check z=1 ==section practice perl \$a_real = randint( -5, 5 ); \$a_imag = randint( -5, 5 ); \$b_real = randint( -5, 5 ); \$b_imag = randint( -5, 5 );