るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

クラス

モジュール

キーワード

検索結果

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

非負整数 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)...
...ger.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 (24319.0)

z の平方根を返します。

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

@param z 数値

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

//emlist[例][ruby]{
r
equire "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 (24319.0)

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

...負の平方根(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, 1.0]
# [2, 1.4142135623731, 2.0]
# [3, 1.73205080756888, 3.0]
# [4, 2.0, 4.0]
# [5, 2.23606797749979, 5.0]
# [6, 2.449489742783...
...18, 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 (24307.0)

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

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

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

@param prec 計算結果の精度。

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

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

//emlist[][ruby]{
r
equire "bigdecimal/math"

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

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

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

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

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

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

絞り込み条件を変える

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

@todo

...@todo

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

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

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

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

@param x 正の実数

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

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

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

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

@see Math.#sqrt...

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

@todo

...do

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

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

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

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

...c 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.81712059283214, -6.0]
# [-5, -1.7099759466767, -5.0]
# [-4, -1.5874010519682, -4.0]
# [-3, -1.44224957030741, -3.0]
# [-2, -1.25992104989487, -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.0800838230519, 9.0]
//}

@see Math.#sqrt...

NEWS for Ruby 2.5.0 (3120.0)

NEWS for Ruby 2.5.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...NEWS for Ruby 2.5.0
このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

それぞれのエントリーは参照情報があるため短いです。
十分な情報と共に書かれた全ての変更のリス...
...トは ChangeLog ファイルか bugs.ruby-lang.org の issue を参照してください。

== 2.4.0 以降の変更

=== 言語仕様の変更

* トップレベルの定数参照を削除しました 11547
* do/end ブロック内部で rescue/else/ensure を書けるようになりまし...
...nteger
* Integer#round, Integer#floor, Integer#ceil, Integer#truncate は常に Integer を返すようになりました
13420
* Integer#pow を追加 12508 11003
* Integer#allbits?, Integer#anybits?, Integer#nobits? を追加 12753
* Integer.sqrt を追加 13219

* Kernel...

絞り込み条件を変える

Complex#abs -> Numeric (206.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 (206.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...