Complex.Abs(Complex) Methode

Definitie

Hiermee haalt u de absolute waarde (of grootte) van een complex getal op.

public:
 static double Abs(System::Numerics::Complex value);
public static double Abs(System.Numerics.Complex value);
static member Abs : System.Numerics.Complex -> double
Public Shared Function Abs (value As Complex) As Double

Parameters

value
Complex

Een complex getal.

Retouren

De absolute waarde van value.

Voorbeelden

In het volgende voorbeeld wordt de absolute waarde van een complex getal berekend en wordt gedemonstreert dat het gelijk is aan de waarde van de Magnitude eigenschap.

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

Opmerkingen

De absolute waarde van een complex getal is gelijk aan de Magnitude eigenschap. De absolute waarde van een complex getal a + bi wordt als volgt berekend:

  • Als b = 0, het resultaat is a.
  • Als a > bhet resultaat is $a \times \sqrt{1 + \frac{b^2}{a^2}}$.
  • Als b > a, het resultaat is $b \times \sqrt{1 + \frac{a^2}{b^2}}$.

Als de berekening van de absolute waarde resulteert in een overloop, retourneert Double.PositiveInfinity de methode of Double.NegativeInfinity. Als de eigenschap of Real de Imaginary eigenschap is Double.NaN en de andere eigenschap noch Double.PositiveInfinityDouble.NegativeInfinitynoch, retourneert Double.NaNde methode .

Van toepassing op

Zie ook