iota-0.1.0.0
Safe HaskellSafe-Inferred
LanguageGHC2021

Algorithm.GoldenSectionSearch

Synopsis

Documentation

phi :: Double Source #

phi = (1+sqrt 5) / 2

resphi :: Double Source #

resphi = 2-phi = 1/(1+phi)

mid1 :: Double -> Double -> Double Source #

mid1 (mid1 low high) high = mid2 low high

mid2 :: Double -> Double -> Double Source #

mid2 low (mid2 low high) = mid1 low high

goldenSectionSearchMin :: Ord a => Double -> Double -> (Double -> a) -> ArgMin a Double Source #

f should be unimodal

>>> goldenSectionSearchMin 0.0 10.0 (\x -> (x-1)^2)
Min {getMin = Arg 9.802089785436835e-28 0.9999999999999687}

goldenSectionSearchMax :: Ord a => Double -> Double -> (Double -> a) -> ArgMax a Double Source #

>>> goldenSectionSearchMax 0.0 10.0 (\x -> log x/x)
Max {getMax = Arg 0.36787944117144233 2.7182818604248506}