错误的未分类语句在(1)的fortran代码中的Archimedes Pi问题

发布于 2025-01-21 22:18:33 字数 498 浏览 2 评论 0原文

我正在为pi的阿基米德(Archimedes aproximation)做一个代码。 当我在终端中编译代码时,发送未分类的语句错误。

这是代码。

implicit none

real*8 n,P0,P,F,G,H,I,J,pi,L,x

open(10,file='valordepi.out',status='unknown')

P0=2.d0*(2.d0**(0.5d0))
P=P0

do



n=1,100

pi=acos(x)

x=-1



P(n)=P/2.d0**n

F=-P(n)**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n

P=J

L=(J-pi)/pi

write(10,*) n,J,L
end do

close(10)

这个想法是检查Archimedes解决方案的近似值,并获取数据进行图形。 当我写n = 1,100问候时,该错误是在线中,

并感谢您的帮助。

i'm doing a code in Fortran for the Archimedes aproximation of Pi.
When I compile the code in the Terminal send the Unclassifiable statement error.

This is the code.

implicit none

real*8 n,P0,P,F,G,H,I,J,pi,L,x

open(10,file='valordepi.out',status='unknown')

P0=2.d0*(2.d0**(0.5d0))
P=P0

do



n=1,100

pi=acos(x)

x=-1



P(n)=P/2.d0**n

F=-P(n)**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n

P=J

L=(J-pi)/pi

write(10,*) n,J,L
end do

close(10)

The idea is check the approximation of the Archimedes solution and get the data to do the graphic.
The error is in the line when i wrote n=1,100

Greetings and thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恬淡成诗 2025-01-28 22:18:33

我几次检查代码,现在我明白了。

implicit none
integer n
real*8 P0,P,F,G,H,I,J,pi,L,x

open(10,file='valordepi.out',status='unknown')

P0=2.d0*(2.d0**(0.5d0))
P=P0
x=-1.d0
pi=acos(x)

do n=2,50

P=P/2.d0**n
F=P**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n
P=J
L=abs(J-pi)

write(10,*) n,J,L 
write(*,*) n,J,L
end do

close(10)

此代码没有错误,只做我问的事情。
感谢大家的答复。
我遇到的错误是n = 2,50不在do行中。

I check the code several times, and now i got it like this.

implicit none
integer n
real*8 P0,P,F,G,H,I,J,pi,L,x

open(10,file='valordepi.out',status='unknown')

P0=2.d0*(2.d0**(0.5d0))
P=P0
x=-1.d0
pi=acos(x)

do n=2,50

P=P/2.d0**n
F=P**2.d0
G=(1.d0-F)**0.5d0
H=1.d0-G
I=(2.d0*H)**0.5d0
J=I*2.d0**n
P=J
L=abs(J-pi)

write(10,*) n,J,L 
write(*,*) n,J,L
end do

close(10)

This code don't have errors, and do just what i asked.
Thanks to everyone for the reply.
The error I did was that the n=2,50 wasn't in the do line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文