Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

#1 2010-05-19 18:13:59

DaveRobinsonUK
Full Member

Offline

Complex Number Representation

Hi All

I am having a go at a small program to draw a fractal, though I am not sure on how to represent the
imaginary part of the complex number.

Most examples I have seen use a pair of doubles, though I can't see how they are representing i.

The one I am looking at now is coded in C++ as

// Function that multiplies two complex numbers
   // the result is a modified object of the class (this)

   void Multiply(Complex_Number comp_num)
   {
       double temp_a;
      double temp_b;
      temp_a = this->a * comp_num.a;
      temp_a += (this->b * comp_num.b)*(-1);

      temp_b = this->a * comp_num.b;
      temp_b += this->b * comp_num.a;

      this->a = temp_a;
      this->b = temp_b;
   }


then multiplying the b value by -1. I thought only

was equal to -1.

It's probably just me being thick, though if someone could explain how this is working
that would be cool. big_smile

Thanks

David


Can feel it coming together.. Slowly but Surely smile

#2 2010-07-02 19:12:22

jk22
Member

Offline

Re: Complex Number Representation

Hi, nice to meet you.

i think it works as distributing r1 i1 on comp2 :

comp1*comp2=(r1+i*i1)*(r2+i*i2)=r1*(r2+i*i2)+i*i1*(r2+i*i2)
=r1*r2+i*r1*i2+i*i1*r2+i*i1*i*i2=
=(r1*r2-i1*i2)+i(r1*i2+i1*r2)., since i*i=-1

or

realpart(comp1*comp2)=real1*real2-imag1*imag2
imagpart(comp1*comp2)=real1*imag2+imag2*real2

cya.

Board footer

Powered by FluxBB