Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 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  }