Last active
October 18, 2021 11:54
-
-
Save sanket143/45f48721e4415c56ac1ca41398e3731b to your computer and use it in GitHub Desktop.
To get magnitude of complex number(r) using javascript .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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