るりまサーチ

最速Rubyリファレンスマニュアル検索!
28件ヒット [1-28件を表示] (0.056秒)
トップページ > クエリ:|[x] > クエリ:-[x] > クエリ:sqrt[x]

別のキーワード

  1. _builtin |
  2. set |
  3. ipaddr |
  4. array |
  5. integer |

ライブラリ

モジュール

検索結果

CMath.#sqrt(z) -> Float | Complex (18320.0)

z の平方根を返します。

...z の平方根を返します。

@param z 数値

@raise TypeError z に数値以外を指定した場合に発生します。

//emlist[例][ruby]{
require "cmath"
CMath.sqrt(-1) # => (0+1.0i)
CMath.sqrt(1)# => 1.0
CMath.sqrt(Complex(0, 8))# => (2.0+2.0i)
//}...

Math.#sqrt(x) -> Float (18225.0)

x の非負の平方根(principal square root)を返します。

...ます。

@raise RangeError xに実数以外の数値を指定した場合に発生します。

//emlist[例][ruby]{
0.upto(10) {|x|
p [x, Math.sqrt(x), Math.sqrt(x)**2]
}
# => [0, 0.0, 0.0]
# [1, 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...

Math.#cbrt(x) -> Float (226.0)

x の立方根(cubic root)を返します。

...uby]{
-
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, -1.7099759466767, -5.0]
# [-4, -1.5874010519682, -4.0]
# [-3, -1.44224957030741, -3.0]
# [-2, -1.25...
...992104989487, -2.0]
# [-1, -1.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.08008382305...
...19, 9.0]
//}

@see Math.#sqrt...