るりまサーチ (Ruby 2.7.0)

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

別のキーワード

  1. math log
  2. _builtin math
  3. bigdecimal/math sqrt
  4. bigdecimal/math sin

ライブラリ

クラス

モジュール

キーワード

検索結果

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

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

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

@param x 0または正の実数

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

@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, 1.0, ...

BigMath.#sqrt(x, prec) -> BigDecimal (63340.0)

x の平方根を prec で指定した精度で計算します。

x の平方根を prec で指定した精度で計算します。

@param x 平方根を求める数。

@param prec 計算結果の精度。

@raise FloatDomainError x に 0 以下、もしくは NaN が指定された場合に発生します。

@raise ArgumentError prec に 0 未満が指定された場合に発生します。

//emlist[][ruby]{
require "bigdecimal/math"

puts BigMath::sqrt(BigDecimal('2'), 10) #=> 0.1414213562373095048666666667e...

Integer.sqrt(n) -> Integer (54538.0)

非負整数 n の整数の平方根を返します。すなわち n の平方根以下の 最大の非負整数を返します。

非負整数 n の整数の平方根を返します。すなわち n の平方根以下の
最大の非負整数を返します。

@param n 非負整数。Integer ではない場合は、最初に Integer に変換されます。
@raise Math::DomainError n が負の整数の時に発生します。

//emlist[][ruby]{
Integer.sqrt(0) # => 0
Integer.sqrt(1) # => 1
Integer.sqrt(24) # => 4
Integer.sqrt(25) # => 5
Integer.sqrt(10**...

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

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

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

@param x 実数

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

@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.8...

Math.#hypot(x, y) -> Float (27067.0)

sqrt(x*x + y*y) を返します。

sqrt(x*x + y*y) を返します。

この値は x, y を直交する 2 辺とする直角三角形の斜辺(hypotenuse)の長さです。

@param x 実数
@param y 実数

@raise TypeError 引数のどちらかに数値以外を指定した場合に発生します。

@raise RangeError 引数のどちらかに実数以外の数値を指定した場合に発生します。

//emlist[例][ruby]{
Math.hypot(3, 4) #=> 5.0
//}

絞り込み条件を変える

Math.#acosh(x) -> Float (27055.0)

x の逆双曲線余弦関数(area hyperbolic cosine)の値を返します。

x の逆双曲線余弦関数(area hyperbolic cosine)の値を返します。

=== 定義

acosh(x) = log(x + sqrt(x * x - 1)) [x >= 1]

@param x x >= 1 の範囲の実数

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

@raise Math::DomainError x に範囲外の実数を指定した場合に発生します。

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

@see Math.#cosh

Math.#asinh(x) -> Float (27037.0)

x の逆双曲線正弦関数(area hyperbolic sine)の値を返します。

x の逆双曲線正弦関数(area hyperbolic sine)の値を返します。

=== 定義

asinh(x) = log(x + sqrt(x * x + 1))

@param x 実数

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

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

@see Math.#sinh

bigdecimal/math (18037.0)

BigDecimalを使った数学的な機能を提供します。

BigDecimalを使った数学的な機能を提供します。

以下の計算が行えます。

* sqrt(x, prec)
* sin (x, prec)
* cos (x, prec)
* atan(x, prec)
* PI (prec)
* E (prec)

引数:

: x

計算対象の BigDecimal オブジェクト。

: prec

計算結果の精度。

//emlist[例][ruby]{
require "bigdecimal"
require "bigdecimal/math"

include BigMath

a = BigDecimal((PI(...