IGLib  1.7.2
The IGLib base library EXTENDED - with other lilbraries and applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
IG.Num.ZeroFinderNewton Class Reference

Solver for single variable nonlinear exuations by the Newton method. More...

+ Inheritance diagram for IG.Num.ZeroFinderNewton:
+ Collaboration diagram for IG.Num.ZeroFinderNewton:

Public Member Functions

 ZeroFinderNewton (IRealFunction function, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (IRealFunction function, double initialGuess, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (IRealFunction function, double initialGuess, double toleranceFunctionValue, int maxIterations)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (IRealFunction function)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (DlgFunctionValue function, DlgFunctionValue functionDerivative, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (DlgFunctionValue function, DlgFunctionValue functionDerivative, double initialGuess, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (DlgFunctionValue function, DlgFunctionValue functionDerivative, double initialGuess, double toleranceFunctionValue, int maxIterations)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (DlgFunctionValue function, DlgFunctionValue functionDerivative)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderNewton (DlgFunctionValue function)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
override void Solve ()
 Tries to find problem solution (function zero) by the Newton's method according to settings and solution data. More...
 
- Public Member Functions inherited from IG.Num.ZeroFinderBase
 ZeroFinderBase (IRealFunction function, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (IRealFunction function, double initialGuess, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (IRealFunction function, double initialGuess, double toleranceFunctionValue, int maxIterations)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (IRealFunction function)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (DlgFunctionValue function, DlgFunctionValue functionDerivative, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (DlgFunctionValue function, DlgFunctionValue functionDerivative, double initialGuess, double toleranceFunctionValue, int maxIterations, double maxStepSize, double numericalDifferentiationStep)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (DlgFunctionValue function, DlgFunctionValue functionDerivative, double initialGuess, double toleranceFunctionValue, int maxIterations)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (DlgFunctionValue function, DlgFunctionValue functionDerivative)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
 ZeroFinderBase (DlgFunctionValue function)
 Constructs a new solver for finding zeros of nonlinear functions. More...
 
void SetFunction (DlgFunctionValue valueDelegate, DlgFunctionValue derivativeDelegate)
 Sets definition of the function whose zeros are searched for. More...
 
virtual double FunctionValue (double x)
 calculates and returns value of the function whose zeros are searched for at the specified value of independent variable. More...
 
virtual double FunctionDerivative (double x)
 calculates and returns derivative of the function whose zeros are searched for at the specified value of independent variable. More...
 
virtual double NumericalFunctionDerivative (double x)
 Calculates and returns numerical derivative of the function whose zero is searched for. More...
 

Protected Attributes

int _maxIterationsNewton = DefaultMaxIterations
 
double _maxStepSizeNewton = DefauleMaxStepSizeNewton
 
- Protected Attributes inherited from IG.Num.ZeroFinderBase
int _outputLevel = DefaultOutputLevel
 
int _maxIterations = DefaultMaxIterations
 
double _toleranceFunctionValue = DefaultToleranceFunctionValue
 
double _initialGuess = DefaultInitialGuess
 
double _maxStepSize = DefaultMaxStepSize
 
double _stepReductionFactor = DefaultStepReductionFactor
 
int _maxStepReductions = DefaultMaxStepReductions
 
double _numericalDifferentiationStep = DefaultNumericalDifferentiationStep
 
IRealFunction _function
 
int _numIterations = 0
 
int _numFunctionEvaluations = 0
 
int _numDerivativeEvaluations = 0
 
double _solution = double.NaN
 
double _functionValueInSolution = double.NaN
 
bool _isSolutionObtained = false
 
bool _recordLastFunctionValue = true
 
double _lastFunctionArgument = double.NaN
 

Static Protected Attributes

static int _defaultMaxIterationsNewton = 100
 
static double _defaultMaxStepSizeNewton = 1.0e50
 
- Static Protected Attributes inherited from IG.Num.ZeroFinderBase
static int _defaultOutputLevel = 0
 
static int _defaultMaxiIterations = 1000
 
static double _defaultInitialGuess = 0
 
static double _defaultToleranceFunctionValue = 1.0e-6
 
static double _defaultMaxStepSize = double.MaxValue
 
static double _defaultStepReductionFactor = 4.0
 
static int _defaultMaxStepReductions = 20
 
static double _defaultNumericalDifferentiationStep = 1.0e-4
 

Properties

static int DefaultMaxIterationsNewton [get, set]
 Default value for the maximal number of iterations for the Newton's method. More...
 
static double DefauleMaxStepSizeNewton [get, set]
 Default value for the maximal step size in the Newton's method. More...
 
override int MaxIterations [get, set]
 Maximal number of iterations. More...
 
override double MaxStepSize [get, set]
 Maximal step size for zefo finding by teh Newton method. More...
 
- Properties inherited from IG.Num.ZeroFinderBase
static int DefaultOutputLevel [get, set]
 Default output level for nonlinear equation solvers. More...
 
static int DefaultMaxIterations [get, set]
 Default value for the maximal number of iterations. More...
 
static double DefaultInitialGuess [get, set]
 Default value for the initial guess in solvers for finding zeros of nonlinear functions. More...
 
static double DefaultToleranceFunctionValue [get, set]
 Default tolerance on absolute value of the function in solution. More...
 
static double DefaultMaxStepSize [get, set]
 Default value for maximal step size. More...
 
static double DefaultStepReductionFactor [get, set]
 Default value for step reduction factor. More...
 
static int DefaultMaxStepReductions [get, set]
 Default value for maximal number of step reductions. More...
 
static double DefaultNumericalDifferentiationStep [get, set]
 Default value for the step size for numerical differentiation. More...
 
virtual int OutputLevel [get, set]
 Level of console output for nonlinear equation solvers. More...
 
virtual int MaxIterations [get, set]
 Maximal number of iterations. More...
 
virtual double ToleranceFunctionValue [get, set]
 Tolerance on absolute value of the function in solution. More...
 
double InitialGuess [get, set]
 Initial guess for finding function zero. More...
 
virtual double MaxStepSize [get, set]
 Default value maximal step size. More...
 
virtual double StepReductionFactor [get, set]
 Step reduction factor. More...
 
virtual int MaxStepReductions [get, set]
 Maximal number of step reductions. More...
 
virtual double NumericalDifferentiationStep [get, set]
 Step size for numerical differentiation. More...
 
IRealFunction Function [get, set]
 
virtual int NumIterations [get, protected set]
 Number of iterations performed up to the current point. More...
 
virtual int NumFunctionEvaluations [get, protected set]
 Number of function evaluations performed by the solution algorithm up to the current point. More...
 
virtual int NumDerivativeEvaluations [get, protected set]
 Number of function derivative evaluations performed by the solution algorithm up to the current point. More...
 
virtual double Solution [get, protected set]
 Calculated solution of the problem (i.e. zero of the function whose value is calculated by the FunctionValue method). More...
 
double FunctionValueInSolution [get, protected set]
 Value of the function whose zero is searched for in the calculated approximate solution. More...
 
bool IsSolutionObtained [get, protected set]
 Flag specifying whether the problem has been successfully solved. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from IG.Num.ZeroFinderBase
static void ExampleNewton ()
 Example where a nonlinear equation equation is solved by a solver class for finding zeros of a function by the Newton's method. More...
 
static void ExampleNewton (DlgFunctionValue function, DlgFunctionValue functionDerivative)
 Example where a nonlinear equation equation is solved by a solver class for finding zeros of a function by the Newton's method. More...
 
static double ExampleFunction (double x)
 Example function whose zero is searched for in the example. More...
 
static double ExampleFunctionDerivative (double x)
 Derivative of the example function whose zero is searched for in the example. More...
 
- Protected Member Functions inherited from IG.Num.ZeroFinderBase
virtual void ResetSolutionData ()
 Resets output data that contains information about the solution and solution procedure. More...
 
virtual void ResetProblemDependentData ()
 Resets data that is not valid any more when problem changes. More...
 
virtual void ResetSolutionAndProblemDependentData ()
 Resets the following data: More...
 

Detailed Description

Solver for single variable nonlinear exuations by the Newton method.

Constructor & Destructor Documentation

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( IRealFunction  function,
double  toleranceFunctionValue,
int  maxIterations,
double  maxStepSize,
double  numericalDifferentiationStep 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for. May also contain method for derivative calculation.
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

Parameters
maxStepSizeMaximal step size.

If less or equal to 0 then default value is taken.

Parameters
numericalDifferentiationStepStep size for numerical differentiation (when used internally).

If less or equal to 0 then the default value is used.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( IRealFunction  function,
double  initialGuess,
double  toleranceFunctionValue,
int  maxIterations,
double  maxStepSize,
double  numericalDifferentiationStep 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for. May also contain method for derivative calculation.
initialGuessInitial guess.
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

Parameters
maxStepSizeMaximal step size.

If less or equal to 0 then default value is taken.

Parameters
numericalDifferentiationStepStep size for numerical differentiation (when used internally).

If less or equal to 0 then the default value is used.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( IRealFunction  function,
double  initialGuess,
double  toleranceFunctionValue,
int  maxIterations 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for. May also contain method for derivative calculation.
initialGuessInitial guess.
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( IRealFunction  function)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for. May also contain method for derivative calculation.
IG.Num.ZeroFinderNewton.ZeroFinderNewton ( DlgFunctionValue  function,
DlgFunctionValue  functionDerivative,
double  toleranceFunctionValue,
int  maxIterations,
double  maxStepSize,
double  numericalDifferentiationStep 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for.
functionDerivativeDerivative of the function whose zeros are searched for.

If null then derivatives will be calculated by numerical differentiation when necessary.

Parameters
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

Parameters
maxStepSizeMaximal step size.

If less or equal to 0 then default value is taken.

Parameters
numericalDifferentiationStepStep size for numerical differentiation (when used internally).

If less or equal to 0 then the default value is used.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( DlgFunctionValue  function,
DlgFunctionValue  functionDerivative,
double  initialGuess,
double  toleranceFunctionValue,
int  maxIterations,
double  maxStepSize,
double  numericalDifferentiationStep 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for.
functionDerivativeDerivative of the function whose zeros are searched for.

If null then derivatives will be calculated by numerical differentiation when necessary.

Parameters
initialGuessInitial guess.
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

Parameters
maxStepSizeMaximal step size.

If less or equal to 0 then default value is taken.

Parameters
numericalDifferentiationStepStep size for numerical differentiation (when used internally).

If less or equal to 0 then the default value is used.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( DlgFunctionValue  function,
DlgFunctionValue  functionDerivative,
double  initialGuess,
double  toleranceFunctionValue,
int  maxIterations 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for.
functionDerivativeDerivative of the function whose zeros are searched for.

If null then derivatives will be calculated by numerical differentiation when necessary.

Parameters
initialGuessInitial guess.
toleranceFunctionValueTolerance on absolute function value in solution.

If less or equal to 0 then the default value is taken.

Parameters
maxIterationsMaximal number of iteratioins.

If less or equal to 0 then the default value is taken.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( DlgFunctionValue  function,
DlgFunctionValue  functionDerivative 
)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Parameters
functionFunction whose zeros are searched for.
functionDerivativeDerivative of the function whose zeros are searched for.

If null then derivatives will be calculated by numerical differentiation when necessary.

IG.Num.ZeroFinderNewton.ZeroFinderNewton ( DlgFunctionValue  function)
inline

Constructs a new solver for finding zeros of nonlinear functions.

Since function for calculation of function derivatives is not set, derivatives will be calculated numerically if needed.

Parameters
functionFunction whose zeros are searched for.

Member Function Documentation

override void IG.Num.ZeroFinderNewton.Solve ( )
inlinevirtual

Tries to find problem solution (function zero) by the Newton's method according to settings and solution data.

Implements IG.Num.ZeroFinderBase.

Referenced by IG.Num.ZeroFinderBase.ExampleNewton().

Member Data Documentation

int IG.Num.ZeroFinderNewton._defaultMaxIterationsNewton = 100
staticprotected
double IG.Num.ZeroFinderNewton._defaultMaxStepSizeNewton = 1.0e50
staticprotected
int IG.Num.ZeroFinderNewton._maxIterationsNewton = DefaultMaxIterations
protected
double IG.Num.ZeroFinderNewton._maxStepSizeNewton = DefauleMaxStepSizeNewton
protected

Property Documentation

int IG.Num.ZeroFinderNewton.DefaultMaxIterationsNewton
staticgetset

Default value for the maximal number of iterations for the Newton's method.

Must be greater or equal to 1.

double IG.Num.ZeroFinderNewton.DefauleMaxStepSizeNewton
staticgetset

Default value for the maximal step size in the Newton's method.

override int IG.Num.ZeroFinderNewton.MaxIterations
getset

Maximal number of iterations.

Must be greater or equal to 1.

Default value is defined by the ZeroFinderNewton.DefaultMaxIterationsNewton property.

Referenced by IG.Num.ZeroFinderBase.ExampleNewton().

override double IG.Num.ZeroFinderNewton.MaxStepSize
getset

Maximal step size for zefo finding by teh Newton method.

Must be greater than 0.

Default value is defined by the ZeroFinderNewton.DefauleMaxStepSizeNewton property.

Referenced by IG.Num.ZeroFinderBase.ExampleNewton().


The documentation for this class was generated from the following file: