ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sqrt.php
Go to the documentation of this file.
1 <?php
2 
10 namespace Complex;
11 
19 if (!function_exists(__NAMESPACE__ . '\\sqrt')) {
20  function sqrt($complex): Complex
21  {
22  $complex = Complex::validateComplexArgument($complex);
23 
24  $theta = theta($complex);
25  $delta1 = \cos($theta / 2);
26  $delta2 = \sin($theta / 2);
27  $rho = \sqrt(rho($complex));
28 
29  return new Complex($delta1 * $rho, $delta2 * $rho, $complex->getSuffix());
30  }
31 }