计算机简单应用.docxVIP

  • 4
  • 0
  • 约1.69千字
  • 约 8页
  • 2018-06-10 发布于上海
  • 举报
1. 用迭代法就算x3-x-1=0program mainimplicit noneinteger stepreal(8):: x,yn,yn1,awrite(*,*) 输入初值 x=read(*,*) x yn=x yn1=(yn+1)**(1.0/3) a=abs((yn1-yn)/yn)if(a=1e-6) thenwrite(*,*) 方程的解为 x=,yn1else step=0do while(a1e-6)yn=yn1yn1=(yn+1)**(1.0/3)a=abs((yn1-yn)/yn) step=step+1 end doend ifwrite(*,*) 方程的解为 x=,yn1pausewrite(*,*) 循环次数为,steppausestop end计算结果为1.3247,迭代次数为92. 用Monte Carlo 的方法求 program mainimplicit nonereal:: a1=0.0,b1=1.0integer:: n=1e9write(*,*)积分结果是:, mentekarol(a1,b1,n)pausecontainsfunction mentekarol(a,b,n)result(s)real a,b,s,preal ::sum=0,randnum,x,yinteger i,ndo i=1,ncall random

文档评论(0)

1亿VIP精品文档

相关文档