sinh.php 918 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. *
  4. * Function code for the complex sinh() function
  5. *
  6. * @copyright Copyright (c) 2013-2018 Mark Baker (https://github.com/MarkBaker/PHPComplex)
  7. * @license https://opensource.org/licenses/MIT MIT
  8. */
  9. namespace Complex;
  10. /**
  11. * Returns the hyperbolic sine of a complex number.
  12. *
  13. * @param Complex|mixed $complex Complex number or a numeric value.
  14. * @return Complex The hyperbolic sine of the complex argument.
  15. * @throws Exception If argument isn't a valid real or complex number.
  16. */
  17. function sinh($complex)
  18. {
  19. $complex = Complex::validateComplexArgument($complex);
  20. if ($complex->isReal()) {
  21. return new Complex(\sinh($complex->getReal()));
  22. }
  23. return new Complex(
  24. \sinh($complex->getReal()) * \cos($complex->getImaginary()),
  25. \cosh($complex->getReal()) * \sin($complex->getImaginary()),
  26. $complex->getSuffix()
  27. );
  28. }