Επεξεργασία

Κοινή χρήση μέσω


Complex.Subtract Method

Definition

Subtracts a specified number from another specified number, where at least one of them is a complex number, and the other could be a double-precision real number, and returns the result.

Overloads

Subtract(Complex, Double)

Subtracts one double-precision real number from a complex number and returns the result.

Subtract(Complex, Complex)

Subtracts one complex number from another and returns the result.

Subtract(Double, Complex)

Subtracts one complex number from a double-precision real number and returns the result.

Examples

The following example subtracts each complex number in an array from a complex number:

using System;
using System.Numerics;

public class Example
{
   public static void Main()
   {
      Complex c1 = new Complex(4.93, 6.87);
      Complex[] values = { new Complex(12.5, 9.6),
                           new Complex(4.3, -8.1),
                           new Complex(-1.9, 7.4),
                           new Complex(-5.3, -6.6) };

      foreach (var c2 in values)
         Console.WriteLine("{0} - {1} = {2}", c1, c2,
                           Complex.Subtract(c1, c2));
   }
}
// The example displays the following output:
//       (4.93, 6.87) - (12.5, 9.6) = (-7.57, -2.73)
//       (4.93, 6.87) - (4.3, -8.1) = (0.63, 14.97)
//       (4.93, 6.87) - (-1.9, 7.4) = (6.83, -0.53)
//       (4.93, 6.87) - (-5.3, -6.6) = (10.23, 13.47)
open System.Numerics

let c1 = Complex(4.93, 6.87)

let values =
    [ Complex(12.5, 9.6)
      Complex(4.3, -8.1)
      Complex(-1.9, 7.4)
      Complex(-5.3, -6.6) ]

for c2 in values do
    printfn $"{c1} - {c2} = {Complex.Subtract(c1, c2)}"
// The example displays the following output:
//       (4.93, 6.87) - (12.5, 9.6) = (-7.57, -2.73)
//       (4.93, 6.87) - (4.3, -8.1) = (0.63, 14.97)
//       (4.93, 6.87) - (-1.9, 7.4) = (6.83, -0.53)
//       (4.93, 6.87) - (-5.3, -6.6) = (10.23, 13.47)
Imports System.Numerics

Module Example
   Public Sub Main()
      Dim c1 As New Complex(4.93, 6.87)
      Dim values() As Complex = { New Complex(12.5, 9.6), 
                                  New Complex(4.3, -8.1), 
                                  New Complex(-1.9, 7.4), 
                                  New Complex(-5.3, -6.6) }

      For Each c2 In values
         Console.WriteLine("{0} - {1} = {2}", c1, c2, 
                           Complex.Subtract(c1, c2))
      Next
   End Sub
End Module
' The example displays the following output:
'       (4.93, 6.87) - (12.5, 9.6) = (-7.57, -2.73)
'       (4.93, 6.87) - (4.3, -8.1) = (0.63, 14.97)
'       (4.93, 6.87) - (-1.9, 7.4) = (6.83, -0.53)
'       (4.93, 6.87) - (-5.3, -6.6) = (10.23, 13.47)

Remarks

The Subtract method allows subtraction operations that involve complex numbers.

If the subtraction results in an overflow in either the real or imaginary component, the value of that component is either Double.PositiveInfinity or Double.NegativeInfinity.

Languages that support custom operators can use the Subtraction equivalent group of operators too.

The Subtract methods that receive one double are more efficient than the method that receive two Complex numbers.

Subtract(Complex, Double)

Source:
Complex.cs
Source:
Complex.cs
Source:
Complex.cs

Subtracts one double-precision real number from a complex number and returns the result.

public:
 static System::Numerics::Complex Subtract(System::Numerics::Complex left, double right);
public static System.Numerics.Complex Subtract (System.Numerics.Complex left, double right);
static member Subtract : System.Numerics.Complex * double -> System.Numerics.Complex
Public Shared Function Subtract (left As Complex, right As Double) As Complex

Parameters

left
Complex

The complex value to subtract from (the minuend).

right
Double

The double-precision real value to subtract (the subtrahend).

Returns

The result of subtracting right from left, as a complex number.

Remarks

The subtraction of a real number (which can be regarded as the complex number c + 0i) from a complex number (a + bi) takes the following form:

$(a - c) + bi$

Languages that support custom operators can use the Complex.Subtraction(Complex, Double) equivalent operator too.

See also

Applies to

Subtract(Complex, Complex)

Source:
Complex.cs
Source:
Complex.cs
Source:
Complex.cs

Subtracts one complex number from another and returns the result.

public:
 static System::Numerics::Complex Subtract(System::Numerics::Complex left, System::Numerics::Complex right);
public static System.Numerics.Complex Subtract (System.Numerics.Complex left, System.Numerics.Complex right);
static member Subtract : System.Numerics.Complex * System.Numerics.Complex -> System.Numerics.Complex
Public Shared Function Subtract (left As Complex, right As Complex) As Complex

Parameters

left
Complex

The value to subtract from (the minuend).

right
Complex

The value to subtract (the subtrahend).

Returns

The result of subtracting right from left.

Remarks

The subtraction of a complex number, c + di, from another complex number, a + bi, takes the following form:

$(a - c) + (b - d)i$

Languages that support custom operators can use the Complex.Subtraction(Complex, Complex) equivalent operator too.

See also

Applies to

Subtract(Double, Complex)

Source:
Complex.cs
Source:
Complex.cs
Source:
Complex.cs

Subtracts one complex number from a double-precision real number and returns the result.

public:
 static System::Numerics::Complex Subtract(double left, System::Numerics::Complex right);
public static System.Numerics.Complex Subtract (double left, System.Numerics.Complex right);
static member Subtract : double * System.Numerics.Complex -> System.Numerics.Complex
Public Shared Function Subtract (left As Double, right As Complex) As Complex

Parameters

left
Double

The double-precision real value to subtract from (the minuend).

right
Complex

The complex value to subtract (the subtrahend).

Returns

The result of subtracting right from left, as a complex number.

Remarks

The subtraction of a complex number (c + di) from a real number (which can be regarded as the complex number a + 0i) takes the following form:

$(a - c) - di$

Languages that support custom operators can use the Complex.Subtraction(Double, Complex) equivalent operator too.

See also

Applies to