Howdy, Stranger!

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


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

IDKIDK Member Posts: 1,784
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);

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);
El PROgrammador Niklas Ulvinge
(who doesn't know how to spell in inglish)
Sign In or Register to comment.