loading
open in
main.hs
1
2
3
4
5
6
7
8
9
10
descend gradF iterN gamma x0 = take iterN (iterate step x0)
  where
    step x = x - gamma * gradF(x)

gradF_test x = 2 * (x - 3)

main = print (descend gradF_test iterN gamma 0.0)
  where
    iterN = 10
    gamma = 0.4
GHCi, version 8.0.1