View source code Display the source code in std/math.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.math.sin - multiple declarations

Function sin

Returns sine for complex and imaginary arguments.

sin(z) = sin(z.re)*cosh(z.im) + cos(z.re)*sinh(z.im)i

If both sin(θ) and cos(θ) are required, it is most efficient to use expi(θ).

Prototypes

creal sin(
  creal z
) pure nothrow @nogc @safe;

ireal sin(
  ireal y
) pure nothrow @nogc @safe;

Example

assert(sin(0.0+0.0i) == 0.0);
assert(sin(2.0+0.0i) == sin(2.0L) );

Function sin

Returns sine of x. x is in radians.

x , sin(x) , invalid? , , yes ±0.0, ±0.0, no , yes

Prototypes

real sin(
  real x
) pure nothrow @nogc @safe;

double sin(
  double x
) pure nothrow @nogc @safe;

float sin(
  float x
) pure nothrow @nogc @safe;

Parameters

NameDescription
x angle in radians (not degrees)

Returns

sine of x

See Also

cos, tan, asin

Bugs

Results are undefined if |x| >= 2,64.

Example

import std.math : sin, PI;
import std.stdio : writefln;

void someFunc()
{
  real x = 30.0;
  auto result = sin(x * (PI / 180)); // convert degrees to radians
  writefln("The sine of %s degrees is %s", x, result);
}

Authors

Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw

License

Boost License 1.0.

Comments