Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

   1  <?php
   2  
   3  namespace Complex;
   4  
   5  include ('../classes/Bootstrap.php');
   6  
   7  echo 'Function Examples', PHP_EOL;
   8  
   9  $functions = array(
  10      'abs',
  11      'acos',
  12      'acosh',
  13      'acsc',
  14      'acsch',
  15      'argument',
  16      'asec',
  17      'asech',
  18      'asin',
  19      'asinh',
  20      'conjugate',
  21      'cos',
  22      'cosh',
  23      'csc',
  24      'csch',
  25      'exp',
  26      'inverse',
  27      'ln',
  28      'log2',
  29      'log10',
  30      'rho',
  31      'sec',
  32      'sech',
  33      'sin',
  34      'sinh',
  35      'sqrt',
  36      'theta'
  37  );
  38  
  39  for ($real = -3.5; $real <= 3.5; $real += 0.5) {
  40      for ($imaginary = -3.5; $imaginary <= 3.5; $imaginary += 0.5) {
  41          foreach ($functions as $function) {
  42              $complexFunction = __NAMESPACE__ . '\\' . $function;
  43              $complex = new Complex($real, $imaginary);
  44              try {
  45                  echo $function, '(', $complex, ') = ', $complexFunction($complex), PHP_EOL;
  46              } catch (\Exception $e) {
  47                  echo $function, '(', $complex, ') ERROR: ', $e->getMessage(), PHP_EOL;
  48              }
  49          }
  50          echo PHP_EOL;
  51      }
  52  }