module GSL::Min
Overview
This module implements One Dimensional Minimization
Usage example:
result, xm, fm = GSL::Min.find_min(0, 6, 1e-6) do |x|
Math.cos(x)
end
result.success?.should be_true
xm.should be_close Math::PI, 1e-6
Defined in:
gsl/maths/optimization/find_bracket.crgsl/maths/optimization/min.cr
Class Method Summary
-
.find_min(f : GSL::Function, x_lower : Float64, x_upper : Float64, x_eps : Float64 = 1e-9, f_eps : Float64 = 1e-9, *, algorithm : GSL::Min::Type | Nil = nil, max_iter = 10000, guess = nil) : Tuple(Result, Float64, Float64)
High-level interface to minimizer.
- .find_min(x_lower : Float64, x_upper : Float64, x_eps : Float64 = 1e-9, f_eps : Float64 = 1e-9, *, algorithm : GSL::Min::Type | Nil = nil, max_iter = 10000, guess = nil, &f : GSL::Function) : Tuple(Result, Float64, Float64)
-
.min_find_bracket(f : GSL::Function, x_minimum : Pointer(LibC::Double), f_minimum : Pointer(LibC::Double), x_lower : Pointer(LibC::Double), f_lower : Pointer(LibC::Double), x_upper : Pointer(LibC::Double), f_upper : Pointer(LibC::Double), eval_max : Int32) : LibGSL::Code
this is a Crystal translation of gsl/min/bracketing.c with patch proposed in http://savannah.gnu.org/bugs/?45053
Class Method Detail
def self.find_min(f : GSL::Function, x_lower : Float64, x_upper : Float64, x_eps : Float64 = 1e-9, f_eps : Float64 = 1e-9, *, algorithm : GSL::Min::Type | Nil = nil, max_iter = 10000, guess = nil) : Tuple(Result, Float64, Float64)
#
High-level interface to minimizer. Finds minimum of function f between x_lower
and x_upper
.
eps
- required absolute precisionalgorithm
- minimization algorithm to be used. By default eitherBrent
(ifguess
is present) orQuadGolden
(othrwise) is used.max_iter
- maximum number of function evaluations, used to stop iterating when solution doesn't convergeguess
- initial guess of a root value that can speed up search. If present, f(guess) < f(x_lower) and f(guess) < f(x_upper) should hold.
returns {result, x_min, f_min}
result
(typeGSL::Result
) represents result of minimizationx_min
- value of x on last iterationf_min
- value of f on last iteration
def self.find_min(x_lower : Float64, x_upper : Float64, x_eps : Float64 = 1e-9, f_eps : Float64 = 1e-9, *, algorithm : GSL::Min::Type | Nil = nil, max_iter = 10000, guess = nil, &f : GSL::Function) : Tuple(Result, Float64, Float64)
#
def self.min_find_bracket(f : GSL::Function, x_minimum : Pointer(LibC::Double), f_minimum : Pointer(LibC::Double), x_lower : Pointer(LibC::Double), f_lower : Pointer(LibC::Double), x_upper : Pointer(LibC::Double), f_upper : Pointer(LibC::Double), eval_max : Int32) : LibGSL::Code
#
this is a Crystal translation of gsl/min/bracketing.c with patch proposed in http://savannah.gnu.org/bugs/?45053