Complex Math Q:z.pow(2) != z*z - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Complex Math Q:z.pow(2) != z*z

Posts: 1,784Member
I've done a Complex Number class and I get some errors.
If I try to multiply a complex number by itself it doesn't equals when I use my pow function.
z*z != z.Pow(2);

[code]
public ComplexNumber Pow(double n)
{
double ra = Math.Pow(modulus, n),
th = argument * n;
return new ComplexNumber(ra * Math.Cos(th),
ra * Math.Sin(th));
}
public static ComplexNumber operator *(ComplexNumber a,
ComplexNumber b)
{
double r = a.r * b.r - a.i * b.i;
double i = a.r * b.i + a.i * b.r;
return new ComplexNumber(r, i);
}
[/code]
[hr]