!Finding the minimum of a given external nonlinear function with dimension n using !the Downhill Simplex method. program NONLIN_EQUATIONS_min use MY_STUFF use FUNCTION_TEST Implicit none integer, parameter :: n=2 !Dim. of problem integer :: M real(KIND=dbl) :: tolf, tolx real(KIND=dbl), dimension(n) :: x_final real(KIND=dbl), dimension(n+1,n) ::sim !Tolerance on f(x1,x2) and simplex: tolf = 0.0000001 ; tolx = 0.00001 !Initial simplex: sim(1,1) = 37.0 ; sim(1,2) = -15.0 sim(2,1) = 20.0 ; sim(2,2) = 27.0 sim(3,1) = 43.0 ; sim(3,2) = -25.0 call SIMPLEX(sim, n, tolf, tolx, x_final, M) print '("Minimum at (x,y) = ", f12.6, " ,", f9.6)', x_final(1), x_final(2) print '("Function value of final point:", f12.6)', f(x_final(1)) print *, "Total number of iterations:", M print "(/)" print '("Tolerance on function value:", e10.2)', tolf print '("Tolerance on Simplex size: ", e10.2)', tolx end program NONLIN_EQUATIONS_min