英語版
このページの英語版を見る

std.math.trigonometry

これは std.math.
いくつかの三角関数を含んでいる。
Authors:
Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
pure nothrow @nogc @safe real cos(real x);

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

pure nothrow @nogc @safe float cos(float x);
x の余弦を返す。
特殊値
x cos(x) 無効か?
無効 無効 はい
±∞ 無効 はい
Bugs:
x| >=264 の場合、結果は未定義となる。
Examples:
import std.math.operations : isClose;

writeln(cos(0.0)); // 1.0
assert(cos(1.0).isClose(0.5403023059));
assert(cos(3.0).isClose(-0.9899924966));
pure nothrow @nogc @safe real sin(real x);

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

pure nothrow @nogc @safe float sin(float x);
x ラジアン単位である。
特殊値
x sin(x) 無効か?
無効 無効 はい
±0.0 ±0.0 なし
±∞ ナン あり
Parameters:
real x ラジアン単位の角度(度ではない)
Returns:
xの正弦
See Also:
Bugs:
x| >=264の場合、結果は未定義となる。
Examples:
import std.math.constants : PI;
import std.stdio : writefln;

void someFunc()
{
  real x = 30.0;
  auto result = sin(x * (PI / 180)); // 度数をラジアンに変換する
  writefln("The sine of %s degrees is %s", x, result);
}
pure nothrow @nogc @safe real tan(real x);

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

pure nothrow @nogc @safe float tan(float x);
x はラジアン単位である。
特殊な値
x tan(x) 無効か?
NAN 無効 はい
±0.0 ±0.0 なし
±∞ ナン あり
Examples:
import std.math.operations : isClose;
import std.math.traits : isIdentical;
import std.math.constants : PI;
import std.math.algebraic : sqrt;

assert(isIdentical(tan(0.0), 0.0));
assert(tan(PI).isClose(0, 0.0, 1e-10));
assert(tan(PI / 3).isClose(sqrt(3.0)));
pure nothrow @nogc @safe real acos(real x);

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

pure nothrow @nogc @safe float acos(float x);
xのアークコサインを計算する、 0からπまでの値を返す。
特殊な値
x acos(x) 無効か?
>1.0 NAN はい
<-1.0 無効 はい
NAN なし はい
Examples:
import std.math.operations : isClose;
import std.math.traits : isNaN;
import std.math.constants : PI;

assert(acos(0.0).isClose(1.570796327));
assert(acos(0.5).isClose(PI / 3));
assert(acos(PI).isNaN);
pure nothrow @nogc @safe real asin(real x);

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

pure nothrow @nogc @safe float asin(float x);
xのアークサインを計算する、 π/2からπ/2の範囲の値を返す。
特殊な値
x asin(x) 無効か?
±0.0 ±0.0 いいえ
>1.0 無効 あり
<-1.0 なし はい
Examples:
import std.math.operations : isClose;
import std.math.traits : isIdentical, isNaN;
import std.math.constants : PI;

assert(isIdentical(asin(0.0), 0.0));
assert(asin(0.5).isClose(PI / 6));
assert(asin(PI).isNaN);
pure nothrow @nogc @safe real atan(real x);

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

pure nothrow @nogc @safe float atan(float x);
xのアークタンジェントを計算する、 π/2からπ/2の範囲の値を返す。
特別な値
x atan(x) 無効か?
±0.0 ±0.0 無効
±∞ 無効 あり
Examples:
import std.math.operations : isClose;
import std.math.traits : isIdentical;
import std.math.constants : PI;
import std.math.algebraic : sqrt;

assert(isIdentical(atan(0.0), 0.0));
assert(atan(sqrt(3.0)).isClose(PI / 3));
pure nothrow @nogc @trusted real atan2(real y, real x);

pure nothrow @nogc @safe double atan2(double y, double x);

pure nothrow @nogc @safe float atan2(float y, float x);
y / x のアークタンジェントを計算する、 πからπまでの値を返す。
特別な値
y x atan(y, x)
ナン 何でも ナン
何でも ナン NAN
±0.0 >0.0 ±0.0
±0.0 +0.0 ±0.0
±0.0 <0.0 ±π
±0.0 -0.0 ±π
>0.0 ±0.0 π/2
<0.0 ±0.0 -π/2
>0.0 ±0.0
±∞ 何でも ±π/2
>0.0 -∞ ±π
±∞ ±π/4
±∞ -∞ ±3π/4
Examples:
import std.math.operations : isClose;
import std.math.constants : PI;
import std.math.algebraic : sqrt;

assert(atan2(1.0, sqrt(3.0)).isClose(PI / 6));
pure nothrow @nogc @safe real cosh(real x);

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

pure nothrow @nogc @safe float cosh(float x);
xの双曲余弦を計算する。
特別な値
x cosh(x) 無効か?
±∞ ±0.0 無効
Examples:
import std.math.constants : E;
import std.math.operations : isClose;

writeln(cosh(0.0)); // 1.0
assert(cosh(1.0).isClose((E + 1.0 / E) / 2));
pure nothrow @nogc @safe real sinh(real x);

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

pure nothrow @nogc @safe float sinh(float x);
xの双曲線正弦を計算する。
特別な値
x sinh(x) 無効か?
±0.0 ±0.0 無効か?
±∞ ±∞ no
Examples:
import std.math.constants : E;
import std.math.operations : isClose;
import std.math.traits : isIdentical;

enum sinh1 = (E - 1.0 / E) / 2;
import std.meta : AliasSeq;
static foreach (F; AliasSeq!(float, double, real))
{
    assert(isIdentical(sinh(F(0.0)), F(0.0)));
    assert(sinh(F(1.0)).isClose(F(sinh1)));
}
pure nothrow @nogc @safe real tanh(real x);

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

pure nothrow @nogc @safe float tanh(float x);
xの双曲線正接を計算する。
特別な値
x tanh(x) 無効か?
±0.0 ±0.0 無効か?
±∞ ±1.0 なし
Examples:
import std.math.operations : isClose;
import std.math.traits : isIdentical;

assert(isIdentical(tanh(0.0), 0.0));
assert(tanh(1.0).isClose(sinh(1.0) / cosh(1.0)));
pure nothrow @nogc @safe real acosh(real x);

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

pure nothrow @nogc @safe float acosh(float x);
xの逆ハイパーボリックコサインを計算する。
数学的には、acosh(x) = log(x + sqrt( x*x - 1)) となる。
範囲 X 範囲 Y
1..∞ 0..∞
特別な値
x acosh(x)
ナン NAN
<1 NAN
1 0
+∞ +∞
Examples:
import std.math.traits : isIdentical, isNaN;

assert(isNaN(acosh(0.9)));
assert(isNaN(acosh(real.nan)));
assert(isIdentical(acosh(1.0), 0.0));
writeln(acosh(real.infinity)); // real.infinity
assert(isNaN(acosh(0.5)));
pure nothrow @nogc @safe real asinh(real x);

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

pure nothrow @nogc @safe float asinh(float x);
xの逆ハイパーボリック正弦を計算する。
数学的に
asinh(x) =  log( x + sqrt( x*x + 1 )) // if x >= +0
asinh(x) = -log(-x + sqrt( x*x + 1 )) // if x <= -0
特別な値
x asinh(x)
NAN NAN
±0 ±0
±∞ ±∞
Examples:
import std.math.traits : isIdentical, isNaN;

assert(isIdentical(asinh(0.0), 0.0));
assert(isIdentical(asinh(-0.0), -0.0));
writeln(asinh(real.infinity)); // real.infinity
writeln(asinh(-real.infinity)); // -real.infinity
assert(isNaN(asinh(real.nan)));
pure nothrow @nogc @safe real atanh(real x);

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

pure nothrow @nogc @safe float atanh(float x);
xの逆双曲線上の正接を計算する、 から1までの値を返す。
数学的には、atanh(x) = log( (1+x)/(1-x) ) となる。/ 2
範囲 X 範囲 Y
-∞..∞ -1 .. 1

特別な値
x acosh(x)
ナン NAN
±0 ±0
-∞ -0
Examples:
import std.math.traits : isIdentical, isNaN;

assert(isIdentical(atanh(0.0), 0.0));
assert(isIdentical(atanh(-0.0),-0.0));
assert(isNaN(atanh(real.nan)));
assert(isNaN(atanh(-real.infinity)));
writeln(atanh(0.0)); // 0