Skip to content

Instantly share code, notes, and snippets.

@sanket143
Last active October 18, 2021 11:54
Show Gist options
  • Save sanket143/45f48721e4415c56ac1ca41398e3731b to your computer and use it in GitHub Desktop.
Save sanket143/45f48721e4415c56ac1ca41398e3731b to your computer and use it in GitHub Desktop.
To get magnitude of complex number(r) using javascript .
// complex number is usually in the form z = a + ib ;
//and here we are going to return the magnitude of this complex number by using Javascript ;
// As we know that, magnitude of complex number (r)= (a^2 + b^2)^1/2
var complex = [a,b];
var r = 0;
function valueR(complex) {
var rvalue = r + Math.pow(complex[0],2) + Math.pow(complex[1],2);
rvalue = Math.sqrt(rvalue);
return rvalue;
}
valueR([3,4]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment