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