Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Task1_2 where
- newtonMethod :: (Double -> Double) -> (Double -> Double) -> Double -> Double -> Double
- newtonMethod f df x eps
- | abs (xNext - x) < eps = f xNext
- | otherwise = newtonMethod f df xNext eps
- where xNext = x - (f x) / (df x)
- goldenSection :: (Double -> Double) -> Double -> Double -> Double -> Double
- goldenSection f a b eps
- | abs (b - a) < eps = f ((a + b) /2)
- | f xFirst >= f xSecond = goldenSection f xFirst b eps
- | otherwise = goldenSection f a xSecond eps
- where xFirst = b - ((b - a) / psi)
- xSecond = a + ((b - a) / psi)
- psi = (1 + sqrt 5) / 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement