Difference between revisions of "cpp/numeric/complex/sin"
From cppreference.com
m (link to sinh) |
m (→Return value: ~) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{cpp/title|sin{{small|(std::complex)}}}} | {{cpp/title|sin{{small|(std::complex)}}}} | ||
{{cpp/numeric/complex/navbar}} | {{cpp/numeric/complex/navbar}} | ||
− | {{ddcl | header=complex | 1= | + | {{ddcl|header=complex|1= |
template< class T > | template< class T > | ||
complex<T> sin( const complex<T>& z ); | complex<T> sin( const complex<T>& z ); | ||
}} | }} | ||
− | Computes complex sine of a complex value {{ | + | Computes complex sine of a complex value {{c|z}}. |
===Parameters=== | ===Parameters=== | ||
{{par begin}} | {{par begin}} | ||
− | {{par | z | complex value}} | + | {{par|z|complex value}} |
{{par end}} | {{par end}} | ||
===Return value=== | ===Return value=== | ||
− | If no errors occur, the complex sine of {{ | + | If no errors occur, the complex sine of {{c|z}} is returned. |
− | Errors and special cases are handled as if the operation is implemented by {{ | + | Errors and special cases are handled as if the operation is implemented by {{box|{{c/core|-i *}}{{nbspt}}{{ltt std|cpp/numeric/complex/sinh}}{{c/core|(i * z)}}}}, where {{tt|i}} is the imaginary unit. |
===Notes=== | ===Notes=== | ||
The sine is an entire function on the complex plane, and has no branch cuts. | The sine is an entire function on the complex plane, and has no branch cuts. | ||
− | Mathematical definition of the sine is {{math|sin z {{=}} {{mfrac|e{{su|p=iz}}-e{{su|p=-iz}}|2i}}}} | + | Mathematical definition of the sine is {{math|sin z {{=}} {{mfrac|e{{su|p=iz}}-e{{su|p=-iz}}|2i}}}}. |
===Example=== | ===Example=== | ||
{{example| | {{example| | ||
|code= | |code= | ||
− | |||
#include <cmath> | #include <cmath> | ||
#include <complex> | #include <complex> | ||
+ | #include <iostream> | ||
int main() | int main() | ||
{ | { | ||
std::cout << std::fixed; | std::cout << std::fixed; | ||
− | std::complex<double> z(1, 0); // behaves like real sine along the real line | + | std::complex<double> z(1.0, 0.0); // behaves like real sine along the real line |
std::cout << "sin" << z << " = " << std::sin(z) | std::cout << "sin" << z << " = " << std::sin(z) | ||
<< " ( sin(1) = " << std::sin(1) << ")\n"; | << " ( sin(1) = " << std::sin(1) << ")\n"; | ||
− | std::complex<double> z2(0, 1); // behaves like sinh along the imaginary line | + | std::complex<double> z2(0.0, 1.0); // behaves like sinh along the imaginary line |
std::cout << "sin" << z2 << " = " << std::sin(z2) | std::cout << "sin" << z2 << " = " << std::sin(z2) | ||
<< " (sinh(1) = " << std::sinh(1) << ")\n"; | << " (sinh(1) = " << std::sinh(1) << ")\n"; | ||
Line 49: | Line 49: | ||
===See also=== | ===See also=== | ||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/numeric/complex/dsc cos}} | + | {{dsc inc|cpp/numeric/complex/dsc cos}} |
− | {{dsc inc | cpp/numeric/complex/dsc tan}} | + | {{dsc inc|cpp/numeric/complex/dsc tan}} |
− | {{dsc inc | cpp/numeric/complex/dsc asin}} | + | {{dsc inc|cpp/numeric/complex/dsc asin}} |
− | {{dsc inc | cpp/numeric/math/dsc sin}} | + | {{dsc inc|cpp/numeric/math/dsc sin}} |
− | {{dsc inc | cpp/numeric/valarray/dsc sin}} | + | {{dsc inc|cpp/numeric/valarray/dsc sin}} |
− | {{dsc see c | c/numeric/complex/csin}} | + | {{dsc see c|c/numeric/complex/csin}} |
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Latest revision as of 10:53, 22 April 2023
Defined in header <complex>
|
||
template< class T > complex<T> sin( const complex<T>& z ); |
||
Computes complex sine of a complex value z.
Contents |
[edit] Parameters
z | - | complex value |
[edit] Return value
If no errors occur, the complex sine of z is returned.
Errors and special cases are handled as if the operation is implemented by -i *
std::sinh(i * z), where i
is the imaginary unit.
[edit] Notes
The sine is an entire function on the complex plane, and has no branch cuts.
Mathematical definition of the sine is sin z =eiz-e-iz |
2i |
[edit] Example
Run this code
#include <cmath> #include <complex> #include <iostream> int main() { std::cout << std::fixed; std::complex<double> z(1.0, 0.0); // behaves like real sine along the real line std::cout << "sin" << z << " = " << std::sin(z) << " ( sin(1) = " << std::sin(1) << ")\n"; std::complex<double> z2(0.0, 1.0); // behaves like sinh along the imaginary line std::cout << "sin" << z2 << " = " << std::sin(z2) << " (sinh(1) = " << std::sinh(1) << ")\n"; }
Output:
sin(1.000000,0.000000) = (0.841471,0.000000) ( sin(1) = 0.841471) sin(0.000000,1.000000) = (0.000000,1.175201) (sinh(1) = 1.175201)
[edit] See also
computes cosine of a complex number (cos(z)) (function template) | |
computes tangent of a complex number (tan(z)) (function template) | |
(C++11) |
computes arc sine of a complex number (arcsin(z)) (function template) |
(C++11)(C++11) |
computes sine (sin(x)) (function) |
applies the function std::sin to each element of valarray (function template) | |
C documentation for csin
|