Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ! x^3 - 8 = 0 (1 --- 4)
- function f(x) result(y)
- real(16), intent(in)::x
- real(16)::y
- y = x*x*x - 8
- end function
- function df(x) result(y)
- real(16), intent(in)::x
- real(16)::y
- y = 3*x*x
- end function
- program hello
- real(16)::f
- real(16)::df
- real(16)::a, b, c, d, e
- a = 1
- b = 4
- do while ((b - a) > 0.000000000001)
- c = f(a)
- d = f(b)
- e = df(b)
- a = -f(a)*(b-a)/(f(b)-f(a))+a
- b = -f(b)/df(b) + b
- end do
- Print *, a
- Print *, b
- end program Hello
- ! SECONDS EXAMPLE
- program hello
- real(8)::x
- real(8)::y
- x = .75
- y = dsqrt(x)
- do while (dabs(y-x) > 0.00000000000001)
- x = y
- y = dsqrt(x)
- end do
- Print *, y
- end program Hello
Add Comment
Please, Sign In to add comment