Share via


Complex.Reciprocal Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns the multiplicative inverse of a complex number.

Namespace:  System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

Syntax

'Declaration
Public Shared Function Reciprocal ( _
    value As Complex _
) As Complex
public static Complex Reciprocal(
    Complex value
)

Parameters

Return Value

Type: System.Numerics.Complex
The reciprocal of value.

Remarks

The reciprocal, or multiplicative inverse, of a number x is a number y where x multiplied by y yields 1. The reciprocal of a complex number is the complex number that produces Complex.One when the two numbers are multiplied. If a complex number is represented by a +bi, its reciprocal is represented by the expression a/(a2+b2) + -b/(a2 + b2).

If value is Complex.Zero, the method returns Complex.Zero. Otherwise, it returns the result of the expression Complex.One/value.

Examples

The following example uses the Reciprocal method to calculate the reciprocal values of several complex numbers. It also demonstrates that the result of multiplying a complex number by its reciprocal is Complex.One.

Imports System.Numerics

Module Example
   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim values() As Complex = { New Complex(1, 1), 
                                  New Complex(-1, 1), 
                                  New Complex(10, -1),
                                  New Complex(3, 5) }
      For Each value As Complex In values
         Dim r1 As Complex = Complex.Reciprocal(value)
         outputBlock.Text += String.Format("{0:N0} x {1:N2} = {2:N2}",  
                           value, r1, value * r1) + vbCrLf
      Next
   End Sub
End Module
' The example displays the following output:
'       (1, 1) x (0.50, -0.50) = (1.00, 0.00)
'       (-1, 1) x (-0.50, -0.50) = (1.00, 0.00)
'       (10, -1) x (0.10, 0.01) = (1.00, 0.00)
'       (3, 5) x (0.09, -0.15) = (1.00, 0.00)
using System;
using System.Numerics;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Complex[] values = { new Complex(1, 1), 
                           new Complex(-1, 1), 
                           new Complex(10, -1),
                           new Complex(3, 5) };
      foreach (Complex value in values)
      {
         Complex r1 = Complex.Reciprocal(value);
         outputBlock.Text += String.Format("{0:N0} x {1:N2} = {2:N2}",
                           value, r1, value * r1) + "\n";
      }
   }
}
// The example displays the following output:
//       (1, 1) x (0.50, -0.50) = (1.00, 0.00)
//       (-1, 1) x (-0.50, -0.50) = (1.00, 0.00)
//       (10, -1) x (0.10, 0.01) = (1.00, 0.00)
//       (3, 5) x (0.09, -0.15) = (1.00, 0.00)

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.