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.cr
gsl/maths/optimization/min.cr

Class Method Summary

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 precision
  • algorithm - minimization algorithm to be used. By default either Brent (if guess is present) or QuadGolden (othrwise) is used.
  • max_iter - maximum number of function evaluations, used to stop iterating when solution doesn't converge
  • guess - 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 (type GSL::Result) represents result of minimization
  • x_min - value of x on last iteration
  • f_min - value of f on last iteration

[View source]
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) #

[View source]
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


[View source]