Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Gold Section 2D

program probniy
        real a, b, e, m, Smin
          a=-7.
          b=20.
          e=0.01
          
           call minn(a,b,e,m,Smin)

             print *, "Точка минимума:"
             print *, m
             print *, "Значение функции в точке минимума:"
             print *, Smin

         end

       subroutine minn(a,b,e,m,Smin)
        real a, b, e, x1, x2, m, Ymin, f, x, G, k, S(4), Smin
          f(x)=x**2.+6.*x-16.
          G=1.618
          x1=b-(b-a)/G
          x2=a+(b-a)/G
             do while ((b-a)>e)
               S=(/f(a), f(x1), f(x2), f(b)/)
                i=1
                Smin=S(1)
                 do i=2,4
                  if(S(i)<Smin) Smin=S(i)
                 end do
               if( (Smin==S(1)).or.(Smin==S(2))) then
                  m=x1
                  b=x2
                  x2=x1
                  x1=b-(b-a)/G
                 else
                  m=x2
                  a=x1
                  x1=x2
                  x2=a+(b-a)/G
                end if
               end do
         end

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.