kyosu v0.1.0
Complex Without Complexes
 
Loading...
Searching...
No Matches

◆ tanh

kyosu::tanh = eve::functor<tanh_t>
inlineconstexpr

Computes the hyperbolic tangent of the argument.

Header file

#include <kyosu/functions.hpp>

Callable Signatures

namespace kyosu
{
template<kyosu::concepts::cayley_dickson T> constexpr T tanh(T z) noexcept;
template<eve::floating_ordered_value T> constexpr T tanh(T z) noexcept;
}
constexpr auto tanh
Computes the hyperbolic tangent of the argument.
Definition: tanh.hpp:96
Main KYOSU namespace.
Definition: cinf.hpp:13

Parameters

  • z: Value to process.

Return value

  1. Returns eve::tanh(z).
  2. Returns elementwise the complex value of the hyperbolic tangent of the input.
    • for every z: tanh(conj(z)) == conj(tanh(z))
    • for every z: tanh(-z) == -tanh(z)
    • If z is \(+0\), the result is \(+0\)
    • If z is \(x+i \infty\) (for any non zero finite x), the result is \(\textrm{NaN}+i \textrm{NaN}\)
    • If z is \(i \infty\) the result is \(i \textrm{NaN}\)
    • If z is \(x,\textrm{NaN}\) (for any non zero finite x), the result is \(\textrm{NaN}+i \textrm{NaN}\)
    • If z is \(i \textrm{NaN}\) the result is \(i \textrm{NaN}\)
    • If z is \(+\infty,y\) (for any finite positive y), the result is \(1\)
    • If z is \(+\infty+i \infty\), the result is \(1,\pm 0\) (the sign of the imaginary part is unspecified)
    • If z is \(+\infty+i \textrm{NaN}\), the result is \(1\) (the sign of the imaginary part is unspecified)
    • If z is \(\textrm{NaN}\), the result is \(\textrm{NaN}\)
    • If z is \(\textrm{NaN}+i y\) (for any non-zero y), the result is \(\textrm{NaN}+i \textrm{NaN}\)
    • If z is \(\textrm{NaN}+i \textrm{NaN}\), the result is \(\textrm{NaN}+i \textrm{NaN}\)
  3. The call is semantically equivalent to sinh(z)/cosh(z);

Example

#include <kyosu/kyosu.hpp>
#include <eve/wide.hpp>
#include <iostream>
int main()
{
using kyosu::tanh;
std::cout << "Real: ";
std::cout << 72.9f << " -> " << tanh(72.9f) << "\n";
std::cout << "Complex: ";
std::cout << kyosu::complex_t<float>(3.5f,-2.9f) << " -> " << tanh(kyosu::complex_t<float>(3.5f,-2.9f)) << "\n";
std::cout << "Quaternion: ";
std::cout << kyosu::quaternion_t<double>(1.,2.,3.,4.) << " -> " << tanh(kyosu::quaternion_t<double>(1.,2.,3.,4.)) << "\n";
std::cout << "SIMD: ";
using wc_t = eve::wide<kyosu::complex_t<double>, eve::fixed<2>>;
std::cout << wc_t(kyosu::complex_t<double>(1.3,-3.7)) << " -> " << tanh(wc_t(kyosu::complex_t<double>(1.3,-3.7))) << "\n";
return 0;
}
as_cayley_dickson_n_t< 4, T > quaternion_t
Type alias for quaternion numbers.
Definition: quaternion.hpp:24
as_cayley_dickson_n_t< 2, T > complex_t
Type alias for complex numbers.
Definition: complex.hpp:27