ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
tanh.php
Go to the documentation of this file.
1<?php
2
10namespace Complex;
11
20if (!function_exists(__NAMESPACE__ . '\\tanh')) {
21 function tanh($complex): Complex
22 {
23 $complex = Complex::validateComplexArgument($complex);
24 $real = $complex->getReal();
25 $imaginary = $complex->getImaginary();
26 $divisor = \cos($imaginary) * \cos($imaginary) + \sinh($real) * \sinh($real);
27 if ($divisor == 0.0) {
28 throw new \InvalidArgumentException('Division by zero');
29 }
30
31 return new Complex(
32 \sinh($real) * \cosh($real) / $divisor,
33 0.5 * \sin(2 * $imaginary) / $divisor,
34 $complex->getSuffix()
35 );
36 }
37}
An exception for terminatinating execution or to throw for unit testing.