Multiplying complex numbers

This section is about multiplying complex numbers. This section may be expanded to other operations with complex number or the complex number as an object.

Constructor function

function complexnumber(real,imag) {
if (isNaN(real) || isNaN(imag)) {
alert("Error. Complex number is undefined.");
this.real = undefined;
this.imag = undefined;
this.polangle = undefined;
this.polrad = undefined;
else {
this.real = real;
this.imag = imag;
this.polangle = Math.atan(imag/real);
this.polrad = Math.pow(Math.pow(real,2)+Math.pow(imag,2),1/2);



\begin{equation} (a+bi)(c+di)=(ac-bd)+(bc+ad)i \end{equation}
function complexmult(a,b,c,d) {
var real = ac-bd;
var imag = bc+ad;
alert("The answer is "+real+"+"+imag+"i." );

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License