次の方法で共有


Complex.Magnitude プロパティ

定義

複素数の大きさ (または絶対値) を取得します。

public:
 property double Magnitude { double get(); };
public double Magnitude { get; }
member this.Magnitude : double
Public ReadOnly Property Magnitude As Double

プロパティ値

現在のインスタンスの大きさ。

次の例では、複素数の絶対値を計算し、Magnitude プロパティの値と等価であることを示します。

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex complex1 = new Complex(2.0, 3.0);
      Console.WriteLine("|{0}| = {1:N2}", complex1, Complex.Abs(complex1));
      Console.WriteLine("Equal to Magnitude: {0}",
                        Complex.Abs(complex1).Equals(complex1.Magnitude));
   }
}
// The example displays the following output:
//       |(2, 3)| = 3.61
//       Equal to Magnitude: True
open System.Numerics

let complex1 = Complex(2., 3.)
printfn $"|{complex1}| = {Complex.Abs complex1:N2}"
printfn $"Equal to Magnitude: {Complex.Abs(complex1).Equals complex1.Magnitude}"
// The example displays the following output:
//       |(2, 3)| = 3.61
//       Equal to Magnitude: True

注釈

Magnitude プロパティは、複素数の絶対値に相当します。 原点 (デカルト座標系の x 軸と y 軸の積集合) から複素数で表される 2 次元点までの距離を指定します。 絶対値は次のように計算されます。

$|a + bi |= \sqrt{a \times a + b \times b}$

絶対値の計算でオーバーフローが発生した場合、このプロパティは Double.PositiveInfinity または Double.NegativeInfinityを返します。

Magnitude プロパティと Phase プロパティは、極座標系の複素数を表す点の位置を定義します。

FromPolarCoordinates メソッドを呼び出すことで、デカルト座標ではなく極座標に基づいて複素数をインスタンス化できます。

適用対象

こちらもご覧ください