You are not logged in.
Pages: 1
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.
Thanks
David
Can feel it coming together.. Slowly but Surely
Offline
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
Pages: 1