std::atan(std::complex)(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::atan(std::complex) - std::atan(std::complex).

Okay so this is the complex arc tangent situation from the C++ Standard Libary, and bestie, it's giving main character energy. πŸ’… No cap, fr fr.

✨ Synopsis ✨

Defined in header <complex>:

template< class T >                      (since C++11)
complex<T> atan( const complex<T>& z );

This computes the complex arc tangent of a complex value z. Branch cut exists outside the interval [βˆ’i, +i] along the imaginary axis. iykyk πŸ¦‹

πŸŽ€ Parameters πŸŽ€

  • z β€” complex value. That's the input, bestie, and it's literally a complex value. Vibe check: passed. πŸ¦‹

🌸 Return value 🌸

If no errors occur, the complex arc tangent of z is returned, in the range of a strip unbounded along the imaginary axis and in the interval [βˆ’Ο€/2, +Ο€/2] along the real axis. Highkey slay. ✨

Errors and special cases are handled as if the operation is implemented by -i * std::atanh(i * z), where i is the imaginary unit. Periodt.

🧚 Notes 🧚

Inverse tangent (or arc tangent) is a multivalued function and requires a branch cut on the complex plane. The branch cut is conventionally placed at the line segments (-∞i,-i) and (+i,+∞i) of the imaginary axis. Don't @ me, that's the convention β€” lowkey iconic. πŸ’€

The mathematical definition of the principal value of inverse tangent is literally atan z = -1/2 i [ln(1 - iz) - ln (1 + iz)]. Math ate, no crumbs β€” I'm obsessed. πŸŽ€

πŸ”₯ Example πŸ”₯

Not me running this exact code to watch the output do its thing:

// Run this code

        #include <cmath>
        #include <complex>
        #include <iostream>

        int main()
        {
            std::cout << std::fixed;
            std::complex<double> z1(0.0, 2.0);
            std::cout << "atan" << z1 << " = " << std::atan(z1) << '\n';

            std::complex<double> z2(-0.0, 2.0);
            std::cout << "atan" << z2 << " (the other side of the cut) = "
                      << std::atan(z2) << '\n';

            std::complex<double> z3(0.0, INFINITY);
            std::cout << "2 * atan" << z3 << " = " << 2.0 * std::atan(z3) <<
       '\n';
        }

πŸ“ Output πŸ“

        atan(0.000000,2.000000) = (1.570796,0.549306)
        atan(-0.000000,2.000000) (the other side of the cut) =
       (-1.570796,0.549306)
        2 * atan(0.000000,inf) = (3.141593,0.000000)

🌈 See also 🌈

  • asin(std::complex) β€” computes arc sine of a complex number (C++11) (({\small\arcsin{z}})arcsin(z)) (function template).
  • acos(std::complex) β€” computes arc cosine of a complex number (C++11) (({\small\arccos{z}})arccos(z)) (function template).
  • tan(std::complex) β€” computes tangent of a complex number (({\small\tan{z}})tan(z)) (function template).
  • atan, atanf, atanl β€” computes arc tangent (({\small\arctan{x}})arctan(x)) (function) (C++11) (C++11).
  • atan(std::valarray) β€” applies the function std::atan to each element of valarray (function template).
  • C documentation for catan.

Made with πŸ’– from http://cppreference.com, version 2024.06.10, page std::atan(std::complex)(3). Bye bestie, go compute some complex arc tangents and slay. 🫢✨

πŸ“¦ where this page comes from