Initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
program testnewton
|
||||
implicit none
|
||||
integer i
|
||||
double precision x,f0,f1,func,recider
|
||||
x=-1.5d0
|
||||
do i=1,200
|
||||
f0=func(x)
|
||||
write(*,*)i,x,f0
|
||||
pause
|
||||
|
||||
f1=func(x+f0)
|
||||
recider=f0/(f1-f0)
|
||||
x=x-recider*f0
|
||||
enddo
|
||||
|
||||
end
|
||||
|
||||
double precision function func(x)
|
||||
double precision x
|
||||
func=x-(x*x+1.0d0)/2.0d0
|
||||
!x^2-2*x+1=0
|
||||
return
|
||||
end
|
||||
Reference in New Issue
Block a user