Advertisement
Guest User

Untitled

a guest
Dec 7th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program minimum
  2. real :: a, b, e, x1, x2, fx1, fx2, c, q, fc
  3.     e=0.00001
  4.     q=0.00001
  5.     a=-2.0
  6.     b=2.0
  7.         do while (abs(b-a)>q)
  8.             c=(a+b)/2
  9.             x1=c-e
  10.             x2=c+e
  11.             fx1=F(x1)
  12.             fx2=F(x2)
  13.             if (fx1<fx2) then
  14.                 b=c
  15.             else
  16.                 a=c
  17.             end if
  18.         end do
  19.     fc=F(c)
  20. print*, "x=", c
  21. print*, "fx=", fc  
  22. end program
  23.    
  24. real function F(x)
  25. real :: x
  26. F = (10*x**3+3*x**2+x+5)**2
  27. return
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement