るりまサーチ

最速Rubyリファレンスマニュアル検索!
154件ヒット [1-100件を表示] (0.015秒)

別のキーワード

  1. bigdecimal sqrt
  2. _builtin sqrt
  3. math sqrt
  4. bigdecimal/math sqrt
  5. bigmath sqrt

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

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

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

...の整数の時に発生します。

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

Math.sqrt(n).floor と同等ですが、後者は浮動小数点数の精度...
...の限界によって
真の値とは違う結果になることがあります。

//emlist[][ruby]{
Integer.sqrt(10**46) #=> 100000000000000000000000
Math.sqrt(10**46).floor #=> 99999999999999991611392 (!)
//}


@see Math.#sqrt...

CMath.#sqrt(z) -> Float | Complex (18119.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 (18119.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.2360679...
...7749979, 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...

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

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

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

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

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

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

BigDecimal#sqrt(n) -> BigDecimal (18101.0)

self の有効桁 n 桁の平方根 (n の平方根ではありません) をニュートン法で 計算します。

self の有効桁 n 桁の平方根 (n の平方根ではありません) をニュートン法で
計算します。

@param n 有効桁数を整数で指定します。

@raise ArgumentError n に負の数を指定した場合に発生します。

絞り込み条件を変える

Math.#sqrt(a) -> Numeric (18101.0)

@todo

...@todo

a の正の平方根を返します。
a が Complex の時は、Complex を返します。
a が負の時は、a を正にして、その平方根を Complex の虚数部に入れて返します。
それ以外は、Math.rsqrt の結果を返します。...

CMath.#sqrt!(x) -> Float (6135.0)

実数 x の平方根を返します。Math.#sqrt のエイリアスです。

...実数 x の平方根を返します。Math.#sqrt のエイリアスです。

@param x 正の実数

@raise Math::DomainError x が負の数である場合に発生します。

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

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

//emlist[例][ruby]{
require "cmath"
CMath.sqrt!(4.0) # => 2.0
CMath.sqrt!(9.0) # => 3.0
//}

@see Math.#sqrt...

Math.#rsqrt(a) -> Numeric (6100.0)

@todo

@todo

複素数を考慮しないので、負の数や Complex をあたえないでください。

a が Float の時は、Float を返します。
それ以外の時、平方根が有理数であれば、Rational または Integer を返します。
無理数であれば、Float を返します。

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

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

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

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

@param x 実数
@param y 実数

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

@raise RangeError 引数...

mathn (12.0)

Rational と Complex をよりシームレスに利用できるようにするライブラリです。数値ライブラリの挙動をグローバルに変更します。

...Complex オブジェクトを返す場合もあります。

例:
Complex(0,-1)**2 #=> Complex(-1,0)
Math.sqrt(-1) #=> NaN

require 'mathn'
Complex(0,-1)**2 #=> -1
Math.sqrt(-1) #=> Complex(0,1)

=== 使用上の注意
なお、この挙動は、グローバルに影響を与えま...

絞り込み条件を変える

CMath.#exp!(x) -> Float (6.0)

実数 x の指数関数(Math::E の x 乗)の値を返します。 Math.#exp のエイリアスです。

...た場合に発生します。

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

//emlist[例][ruby]{
require "cmath"
CMath.exp!(0) # => 1
CMath.exp!(0.5) # => Math.sqrt(Math::E)
CMath.exp!(1) # => Math::E
CMath.exp!(2) # => Math::E ** 2
//}

@see Math.#exp...

Complex#abs -> Numeric (6.0)

自身の絶対値を返します。

...自身の絶対値を返します。

以下の計算の結果を Float オブジェクトで返します。

sqrt
(self.real ** 2 + self.imag ** 2)

//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.70710678118...

Complex#magnitude -> Numeric (6.0)

自身の絶対値を返します。

...自身の絶対値を返します。

以下の計算の結果を Float オブジェクトで返します。

sqrt
(self.real ** 2 + self.imag ** 2)

//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.70710678118...
<< 1 2 > >>