求助,只能求出f(0;k)再往下算就出现错误
我的代码如下
[Fortran] 纯文本查看 复制代码 program romberg
integer k,m
real h,i,n,a,b,e
real T(0:5,0:5),c(0:5,0:5)
a=0.0
b=1.0
do k=0,5
h=(b-a)/2**k
n=2**k
T(0,k)=0.0
do i=1,n-1
x=a+i*h
f=sqrt(x**3)
T(0,k)=T(0,k)+f
end do
T(0,k)=2*T(0,k)+1.0
T(0,k)=T(0,k)*h/2
write(*,*) T(0,k)
end do
do m=1,5
do j=1,m
T(j,m)=(4.0**m)/(4.0**m-1)*T(j,m-1)-1.0/(4.0**m-1)*T(j-1,m-1)
write(*,*) T(j,m)
end do
end do
end |