diff --git a/README.md b/README.md index ed65083..741f5eb 100644 --- a/README.md +++ b/README.md @@ -58,4 +58,15 @@ Planned additional functionality, but still to implement * coth (hyperbolic cotangent) * acoth (inverse hyperbolic cotangent) * pow (power) - \ No newline at end of file + +--- +Functions added +- tanh (hyperbolic tangent) +- atanh (inverse hyperbolic tangent) +- coth (hyperbolic cotangent) +- acoth (inverse hyperbolic cotangent) +- gudermannian () Hyperbolic +- inversegudermannian () Hyperbolic +- haversine () Trigonometric +- inversehaversine () Trigonometric + diff --git a/classes/src/functions/acoth.php b/classes/src/functions/acoth.php new file mode 100644 index 0000000..ebd2f7e --- /dev/null +++ b/classes/src/functions/acoth.php @@ -0,0 +1,36 @@ +getImaginary() == 0.0 ) { + if ( ( $complex->getReal() == -1 ) || ( $complex->getReal() == 1 ) ) { + return INF; + } else { + $calc = clone $complex; + $complex = $complex->add( 1 ); + $calc = $calc->subtract( 1 ); + $complex = $complex->divideBy( $calc ); + $complex = ln( $complex ); + $complex = $complex->divideBy( 2 ); + return $complex; + } + } +} \ No newline at end of file diff --git a/classes/src/functions/atanh.php b/classes/src/functions/atanh.php new file mode 100644 index 0000000..b5e902a --- /dev/null +++ b/classes/src/functions/atanh.php @@ -0,0 +1,42 @@ +getImaginary() == 0.0 ) { + if ( ( $complex->getReal() == -1 ) || ( $complex->getReal() == 1 ) ){ + return INF; + } else { + $calc = clone $complex; + + $complex->add( 1 ); + $complex = ln( $complex ); + + $calc = $calc->multiply( -1 ); + $calc = $calc->add( 1 ); + $calc = ln( $calc ); + + $complex = $complex->subtract( $calc ); + $complex = $complex->divideBy( 2 ); + + return $complex; + } + } +} diff --git a/classes/src/functions/coth.php b/classes/src/functions/coth.php new file mode 100644 index 0000000..0e19b78 --- /dev/null +++ b/classes/src/functions/coth.php @@ -0,0 +1,35 @@ +getImaginary() == 0.0 ) { + $calc = clone $complex; + $complex = cosh( $complex ); + $calc = sinh( $calc ); + + if ( $calc->getReal() != 0 ) { + $complex = $complex->divideBy( $calc ); + return $complex; + } else { + return null; + } + } +} \ No newline at end of file diff --git a/classes/src/functions/gudermannian.php b/classes/src/functions/gudermannian.php new file mode 100644 index 0000000..415c27b --- /dev/null +++ b/classes/src/functions/gudermannian.php @@ -0,0 +1,30 @@ +getImaginary() == 0.0 ) { + $complex = exp( $complex ); + $complex = atan( $complex ); + $complex = $complex->multiply( 2 ); + $complex = $complex->add( -( M_PI/2 ) ); + return $complex; + } +} \ No newline at end of file diff --git a/classes/src/functions/haversine.php b/classes/src/functions/haversine.php new file mode 100644 index 0000000..42eae81 --- /dev/null +++ b/classes/src/functions/haversine.php @@ -0,0 +1,29 @@ +getImaginary() == 0.0 ) { + $complex = $complex->divideBy( 2 ); + $complex = sin( $complex ); + $complex = $complex->multiply( $complex ); + return $complex; + } +} \ No newline at end of file diff --git a/classes/src/functions/inversegudermannian.php b/classes/src/functions/inversegudermannian.php new file mode 100644 index 0000000..29da00b --- /dev/null +++ b/classes/src/functions/inversegudermannian.php @@ -0,0 +1,30 @@ +getImaginary() == 0.0 ) { + $complex = $complex->divideBy( 2 ); + $complex = $complex->add( M_PI/4 ); + $complex = tan( $complex ); + $complex = ln( $complex ); + return $complex; + } +} \ No newline at end of file diff --git a/classes/src/functions/inversehaversine.php b/classes/src/functions/inversehaversine.php new file mode 100644 index 0000000..c052479 --- /dev/null +++ b/classes/src/functions/inversehaversine.php @@ -0,0 +1,31 @@ +getImaginary() == 0.0 ) { + if ( ( $complex->getReal() >= 0.0 ) && ( $complex->getReal() <= 1.0 ) ) { + $complex = sqrt( $complex ); + $complex = asin( $complex ); + $complex = $complex->multiply( 2 ); + return $complex; + } + } +} \ No newline at end of file diff --git a/classes/src/functions/tanh.php b/classes/src/functions/tanh.php new file mode 100644 index 0000000..efbd79c --- /dev/null +++ b/classes/src/functions/tanh.php @@ -0,0 +1,28 @@ +getImaginary() == 0.0 ) { + $calc = clone $complex; + $complex = sinh( $complex ); + $calc = cosh( $calc ); + $complex = $complex->divideBy( $calc ); + return $complex; + } +} \ No newline at end of file diff --git a/examples/complexTest2.php b/examples/complexTest2.php index 91c827a..b9a88c7 100644 --- a/examples/complexTest2.php +++ b/examples/complexTest2.php @@ -4,7 +4,7 @@ include('../classes/Bootstrap.php'); -echo 'Function Examples', PHP_EOL; +echo "