summaryrefslogtreecommitdiffstats
path: root/vendor/markbaker/complex/examples/testFunctions.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/markbaker/complex/examples/testFunctions.php')
-rw-r--r--vendor/markbaker/complex/examples/testFunctions.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/vendor/markbaker/complex/examples/testFunctions.php b/vendor/markbaker/complex/examples/testFunctions.php
new file mode 100644
index 0000000..69cc7dc
--- /dev/null
+++ b/vendor/markbaker/complex/examples/testFunctions.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Complex;
+
+include('../classes/Bootstrap.php');
+
+echo 'Function Examples', PHP_EOL;
+
+$functions = array(
+ 'abs',
+ 'acos',
+ 'acosh',
+ 'acsc',
+ 'acsch',
+ 'argument',
+ 'asec',
+ 'asech',
+ 'asin',
+ 'asinh',
+ 'conjugate',
+ 'cos',
+ 'cosh',
+ 'csc',
+ 'csch',
+ 'exp',
+ 'inverse',
+ 'ln',
+ 'log2',
+ 'log10',
+ 'rho',
+ 'sec',
+ 'sech',
+ 'sin',
+ 'sinh',
+ 'sqrt',
+ 'theta'
+);
+
+for ($real = -3.5; $real <= 3.5; $real += 0.5) {
+ for ($imaginary = -3.5; $imaginary <= 3.5; $imaginary += 0.5) {
+ foreach ($functions as $function) {
+ $complexFunction = __NAMESPACE__ . '\\' . $function;
+ $complex = new Complex($real, $imaginary);
+ try {
+ echo $function, '(', $complex, ') = ', $complexFunction($complex), PHP_EOL;
+ } catch (\Exception $e) {
+ echo $function, '(', $complex, ') ERROR: ', $e->getMessage(), PHP_EOL;
+ }
+ }
+ echo PHP_EOL;
+ }
+}