Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

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

DaveRobinsonUK
Member
Registered: 2010-04-24
Posts: 123

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

Offline

#2 2010-07-01 21:12:22

jk22
Member
Registered: 2010-06-14
Posts: 33

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.

Offline

Board footer

Powered by FluxBB