Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program minimum
- real :: a, b, e, x1, x2, fx1, fx2, c, q, fc
- e=0.00001
- q=0.00001
- a=-2.0
- b=2.0
- do while (abs(b-a)>q)
- c=(a+b)/2
- x1=c-e
- x2=c+e
- fx1=F(x1)
- fx2=F(x2)
- if (fx1<fx2) then
- b=c
- else
- a=c
- end if
- end do
- fc=F(c)
- print*, "x=", c
- print*, "fx=", fc
- end program
- real function F(x)
- real :: x
- F = (10*x**3+3*x**2+x+5)**2
- return
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement