FunctionMath.FindZero Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.4

Overload List

FindZero(Func<Vector<Double>, Double>[], Vector<Double>) Solves a system of nonlinear equations starting from an initial guess.
FindZero(Func<Double, Double>, Double) Finds a zero of a function starting from an initial guess.
FindZero(Func<Vector<Double>, Vector<Double>, Vector<Double>>, Vector<Double>) Solves a system of nonlinear equations starting from an initial guess.
FindZero(Func<Vector<Double>, Double>[], Func<Vector<Double>, Vector<Double>, Vector<Double>>[], Vector<Double>) Finds a zero of a function starting from an initial guess.
FindZero(Func<Double, Double>, Double, Double) Finds a zero of a function when the solution is known to lie within a specified interval.
FindZero(Func<Double, Double>, Func<Double, Double>, Double) Finds a zero of a function starting from an initial guess.
FindZero(Func<Vector<Double>, Vector<Double>, Vector<Double>>, Func<Vector<Double>, Matrix<Double>, Matrix<Double>>, Vector<Double>) Finds a zero of a function starting from an initial guess.
FindZero(Func<Double, Double>, Func<Double, Double>, Double, Double, Double) Finds a zero of a function starting from an initial guess.
FindZero(Func<Double, ValueTuple<Double, Double, Double>>, Double, ConvergenceCriterion, Double, Double, Double) Finds a zero of a function starting from an initial guess.
FindZero(Func<Double, ValueTuple<Double, Double>>, Double, ConvergenceCriterion, Double, Double, Double) Finds a zero of a function starting from an initial guess.
FindZero(Func<Double, Double>, Func<Double, Double>, Func<Double, Double>, Double, ConvergenceCriterion, Double, Double, Double) Finds a zero of a function starting from an initial guess.

FindZero(Func<Vector<Double>, Double>[], Vector<Double>)

Solves a system of nonlinear equations starting from an initial guess.
C#
public static Vector<double> FindZero(
	this Func<Vector<double>, double>[] targetFunctions,
	Vector<double> initialGuess
)

Parameters

targetFunctions  Func<Vector<Double>, Double>[]
An array of delegates that represent a multivariate function that specify the left-hand sides of the equation.
initialGuess  Vector<Double>
An initial guess for the solution.

Return Value

Vector<Double>
The best approximation to a zero of targetFunctions.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Vector<Double>, Double>[]. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, Double>, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, double> targetFunction,
	double initialGuess
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation.
initialGuess  Double
An initial guess for ther zero.

Return Value

Double
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Vector<Double>, Vector<Double>, Vector<Double>>, Vector<Double>)

Solves a system of nonlinear equations starting from an initial guess.
C#
public static Vector<double> FindZero(
	this Func<Vector<double>, Vector<double>?, Vector<double>> targetFunction,
	Vector<double> initialGuess
)

Parameters

targetFunction  Func<Vector<Double>, Vector<Double>, Vector<Double>>
A delegate that represents a multivariate function returning a vector in its second argument that calculates the left-hand sides of the equation.
initialGuess  Vector<Double>
An initial guess for the solution.

Return Value

Vector<Double>
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Vector<Double>, Vector<Double>, Vector<Double>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Vector<Double>, Double>[], Func<Vector<Double>, Vector<Double>, Vector<Double>>[], Vector<Double>)

Finds a zero of a function starting from an initial guess.
C#
public static Vector<double> FindZero(
	this Func<Vector<double>, double>[] targetFunctions,
	Func<Vector<double>, Vector<double>?, Vector<double>>[] gradientOfTargetFunctions,
	Vector<double> initialGuess
)

Parameters

targetFunctions  Func<Vector<Double>, Double>[]
A delegate that represents a multivariate function that specifies the function on the left-hand side of the equation.
gradientOfTargetFunctions  Func<Vector<Double>, Vector<Double>, Vector<Double>>[]
A delegate that represents a multivariate function that specifies the gradient function of targetFunctions.
initialGuess  Vector<Double>
An initial guess for ther zero.

Return Value

Vector<Double>
The best approximation to a zero of targetFunctions.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Vector<Double>, Double>[]. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, Double>, Double, Double)

Finds a zero of a function when the solution is known to lie within a specified interval.
C#
public static double FindZero(
	this Func<double, double> targetFunction,
	double lowerBound,
	double upperBound
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation.
lowerBound  Double
The lower bound of the interval that contains the root.
upperBound  Double
The upper bound of the interval that contains the root.

Return Value

Double
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, Double>, Func<Double, Double>, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, double> targetFunction,
	Func<double, double> derivativeOfTargetFunction,
	double initialGuess
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation.
derivativeOfTargetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the derivative function of targetFunction.
initialGuess  Double
An initial guess for ther zero.

Return Value

Double
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Vector<Double>, Vector<Double>, Vector<Double>>, Func<Vector<Double>, Matrix<Double>, Matrix<Double>>, Vector<Double>)

Finds a zero of a function starting from an initial guess.
C#
public static Vector<double> FindZero(
	this Func<Vector<double>, Vector<double>?, Vector<double>> targetFunction,
	Func<Vector<double>, Matrix<double>?, Matrix<double>> jacobianFunction,
	Vector<double> initialGuess
)

Parameters

targetFunction  Func<Vector<Double>, Vector<Double>, Vector<Double>>
A delegate that represents a multivariate function that specifies the functions on the left-hand side of the equations.
jacobianFunction  Func<Vector<Double>, Matrix<Double>, Matrix<Double>>
A delegate that represents a multivariate function that specifies the Jacobian function of targetFunction.
initialGuess  Vector<Double>
An initial guess for ther zero.

Return Value

Vector<Double>
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Vector<Double>, Vector<Double>, Vector<Double>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, Double>, Func<Double, Double>, Double, Double, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, double> targetFunction,
	Func<double, double> derivativeOfTargetFunction,
	double initialGuess,
	double lowerBound,
	double upperBound
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation.
derivativeOfTargetFunction  Func<Double, Double>
A delegate that represents the derivative function of targetFunction.
initialGuess  Double
An initial guess for ther zero.
lowerBound  Double
The lower bound of the interval that contains the root.
upperBound  Double
The upper bound of the interval that contains the root.

Return Value

Double
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, ValueTuple<Double, Double, Double>>, Double, ConvergenceCriterion, Double, Double, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, (double , double , double )> targetFunctionWithDerivatives,
	double initialGuess,
	ConvergenceCriterion convergenceCriterion = ConvergenceCriterion.WithinRelativeTolerance,
	double tolerance = 6.05545445239334E-06,
	double lowerBound = -∞,
	double upperBound = ∞
)

Parameters

targetFunctionWithDerivatives  Func<Double, ValueTuple<Double, Double, Double>>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation and returns the function value, the first derivative, and the second derivative as a tuple.
initialGuess  Double
An initial guess for ther zero.
convergenceCriterion  ConvergenceCriterion  (Optional)
Optional. The convergence criterion to use. The default is to be within the relative tolerance.
tolerance  Double  (Optional)
Optional. The tolerance that is used in the convergence test. The default is the cube root of the machine precision.
lowerBound  Double  (Optional)
Optional. The lower bound of the interval that contains the root. The default value is NegativeInfinity.
upperBound  Double  (Optional)
Optional. The upper bound of the interval that contains the root. The default value is PositiveInfinity.

Return Value

Double
The best approximation to a zero of targetFunctionWithDerivatives.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, ValueTuple<Double, Double, Double>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method uses Halley's third order algorithm.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, ValueTuple<Double, Double>>, Double, ConvergenceCriterion, Double, Double, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, (double , double )> targetFunctionWithDerivative,
	double initialGuess,
	ConvergenceCriterion convergenceCriterion = ConvergenceCriterion.WithinRelativeTolerance,
	double tolerance = 6.05545445239334E-06,
	double lowerBound = -∞,
	double upperBound = ∞
)

Parameters

targetFunctionWithDerivative  Func<Double, ValueTuple<Double, Double>>
A delegate that returns a function of one variable that specifies the function on the left-hand side of the equation, and its derivative.
initialGuess  Double
An initial guess for ther zero.
convergenceCriterion  ConvergenceCriterion  (Optional)
Optional. The convergence criterion to use. The default is to be within the relative tolerance.
tolerance  Double  (Optional)
Optional. The tolerance that is used in the convergence test. The default is the cube root of the machine precision.
lowerBound  Double  (Optional)
The lower bound of the interval that contains the root.
upperBound  Double  (Optional)
The upper bound of the interval that contains the root.

Return Value

Double
The best approximation to a zero of the first item of targetFunctionWithDerivative.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, ValueTuple<Double, Double>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

Use this method when you have very little information about the location of the zero.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

FindZero(Func<Double, Double>, Func<Double, Double>, Func<Double, Double>, Double, ConvergenceCriterion, Double, Double, Double)

Finds a zero of a function starting from an initial guess.
C#
public static double FindZero(
	this Func<double, double> targetFunction,
	Func<double, double> derivativeOfTargetFunction,
	Func<double, double> secondDerivativeOfTargetFunction,
	double initialGuess,
	ConvergenceCriterion convergenceCriterion = ConvergenceCriterion.WithinRelativeTolerance,
	double tolerance = 6.05545445239334E-06,
	double lowerBound = -∞,
	double upperBound = ∞
)

Parameters

targetFunction  Func<Double, Double>
A delegate that represents a function of one variable that specifies the function on the left-hand side of the equation.
derivativeOfTargetFunction  Func<Double, Double>
A delegate that represents the derivative function of targetFunction.
secondDerivativeOfTargetFunction  Func<Double, Double>
A delegate that represents the second derivative function of targetFunction.
initialGuess  Double
An initial guess for ther zero.
convergenceCriterion  ConvergenceCriterion  (Optional)
Optional. The convergence criterion to use. The default is to be within the relative tolerance.
tolerance  Double  (Optional)
Optional. The tolerance that is used in the convergence test. The default is the cube root of the machine precision.
lowerBound  Double  (Optional)
Optional. The lower bound of the interval that contains the root. The default value is NegativeInfinity.
upperBound  Double  (Optional)
Optional. The upper bound of the interval that contains the root. The default value is PositiveInfinity.

Return Value

Double
The best approximation to a zero of targetFunction.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Func<Double, Double>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method uses Halley's third order algorithm.

Exceptions

ConvergenceException

The algorithm failed to converge to a solution.

See Also