40件ヒット
[1-40件を表示]
(0.015秒)
検索結果
先頭5件
-
Math
. # cbrt(x) -> Float (27131.0) -
x の立方根(cubic root)を返します。
...。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
-9.upto(9) {|x|
p [x, Math.cbrt(x), Math.cbrt(x)**3]
}
# => [-9, -2.0800838230519, -9.0]
# [-8, -2.0, -8.0]
# [-7, -1.91293118277239, -7.0]
# [-6, -1.81712059283214, -6.0]
# [-5.......0, -1.0]
# [0, 0.0, 0.0]
# [1, 1.0, 1.0]
# [2, 1.25992104989487, 2.0]
# [3, 1.44224957030741, 3.0]
# [4, 1.5874010519682, 4.0]
# [5, 1.7099759466767, 5.0]
# [6, 1.81712059283214, 6.0]
# [7, 1.91293118277239, 7.0]
# [8, 2.0, 8.0]
# [9, 2.0800838230519, 9.0]
//}
@see Math.#sqrt... -
CMath
. # cbrt(z) -> Float | Complex (21107.0) -
z の立方根の内、主値を返します。
...z の立方根の内、主値を返します。
@param z 数値
@raise TypeError z に数値以外を指定した場合に発生します。
//emlist[例][ruby]{
require "cmath"
CMath.cbrt(-8)# => (1.0000000000000002+1.7320508075688772i)
//}
@see Complex#**... -
CMath
. # cbrt!(x) -> Float (9157.0) -
実数 x の立方根を返します。Math.#cbrt のエイリアスです。
...。Math.#cbrt のエイリアスです。
@param x 実数
@raise TypeError x に数値以外を指定した場合に発生します。
@raise RangeError x に実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
require "cmath"
CMath.cbrt!(8.0)# => 2.0
CMath.cbrt!(......-8.0) # => -2.0
//}
@see Math.#cbrt... -
Math
. # sqrt(x) -> Float (9030.0) -
x の非負の平方根(principal square root)を返します。
...合に発生します。
@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。
@raise RangeError xに実数以外の数値を指定した場合に発生します。
//emlist[例][ruby]{
0.upto(10) {|x|
p [x, Math.sqrt(x), Math.sqrt(x)**2]
}
# => [0, 0.0, 0.0......1.0, 1.0]
# [2, 1.4142135623731, 2.0]
# [3, 1.73205080756888, 3.0]
# [4, 2.0, 4.0]
# [5, 2.23606797749979, 5.0]
# [6, 2.44948974278318, 6.0]
# [7, 2.64575131106459, 7.0]
# [8, 2.82842712474619, 8.0]
# [9, 3.0, 9.0]
# [10, 3.16227766016838, 10.0]
//}
@see Integer.sqrt, Math.#cbrt... -
CMath (6054.0)
-
複素数演算をサポートするモジュールです。
...トするモジュールです。
Math モジュールの複素数版です。同名のメソッドを複素数対応します。
従来の計算結果が必要な場合は、「メソッド名!」の形式で呼び出します。
//emlist[例][ruby]{
require "cmath"
# 複素数の範囲の立方......= exp(1/3 πi)
CMath.cbrt(-1) # => (0.5000000000000001+0.8660254037844386i)
# 実数の範囲の立方根
Math.cbrt(-1) # => -1.0
include CMath
# レシーバー無しで使える
cbrt(-1) # => (0.5000000000000001+0.8660254037844386i)
# cbrt! は Math.cbrt のエイリアス
cbrt!(-1) # => -1.0...