るりまサーチ

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

別のキーワード

  1. _builtin complex
  2. complex rect
  3. complex polar
  4. complex rectangular
  5. complex rationalize

ライブラリ

クラス

モジュール

キーワード

検索結果

Complex#abs -> Numeric (21030.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.7071067811865476
//}

@see Complex#abs2...

Complex#magnitude -> Numeric (21030.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.7071067811865476
//}

@see Complex#abs2...

CMath.#sqrt(z) -> Float | Complex (18226.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(a) -> Numeric (18119.0)

@todo

...@todo

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

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

@todo

...@todo

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

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

絞り込み条件を変える

mathn (64.0)

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

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

なお、このライブラリはRuby 2.2から非推奨(deprecated)になり、Ruby 2.5で削除されました。
引き続...
...1,1)

require 'mathn'
1/2 #=> Rational(1,2)
2 * Rational(1,2) #=> 1

==== 実数と複素数の相互変換

同様にして Complex のインスタンスの虚部が 0 ならば、実部として含まれていた Rational, Float, または Integer オブジェクトに変換...
...例外を発生していたような演算が 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)

=== 使用上の注意
なお、この挙...