Anonymous user
Arithmetic/Complex: Difference between revisions
Added a solution for MATLAB
(added Go) |
(Added a solution for MATLAB) |
||
Line 1,163:
''Mathematica has fundamental support for both explicit complex numbers and symbolic complex variables. All applicable mathematical functions support arbitrary-precision evaluation for complex values of all parameters, and symbolic operations automatically treat complex variables with full generality.''
=={{header|MATLAB}}==
Complex numbers are a primitive data type in MATLAB. All the typical complex operations can be performed. There are two keywords that specify a number as complex: "i" and "j".
<lang MATLAB>>> a = 1+i
a =
1.000000000000000 + 1.000000000000000i
>> b = 3+7i
b =
3.000000000000000 + 7.000000000000000i
>> a+b
ans =
4.000000000000000 + 8.000000000000000i
>> a-b
ans =
-2.000000000000000 - 6.000000000000000i
>> a*b
ans =
-4.000000000000000 +10.000000000000000i
>> a/b
ans =
0.172413793103448 - 0.068965517241379i
>> -a
ans =
-1.000000000000000 - 1.000000000000000i
>> a'
ans =
1.000000000000000 - 1.000000000000000i
>> a^b
ans =
0.000808197112874 - 0.011556516327187i
>> norm(a)
ans =
1.414213562373095</lang>
=={{header|OCaml}}==
|