vb已知π*2 6求π的近似值代码
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 13:04:40
公式:π/4=1-1/3+1/5-1/7+...求值n=0sn=0an=1dountilABS(an)
应该是Pi/4=1-1/3+1/5-1/7+…+(-1)^(n-1)/(2*n-1)吧,PrivateSubForm_Load()DimPiAsSingle,iAsLongForm1.AutoRedr
#include<stdio.h>main(){ longi,a=1,b=3; doublep=1,t=1,t1=0; while(t-t1>=1e-8
你给的公式不对!应该是π/2=2^2/1*3×4^2/3*5×.×(这个公式求的精度不高!代码如下:DimPI1AsDoubleDimPI2AsDoubleDimTempAsDoubleDimnAsD
clearclca=input('请输入a的值:');x=input('初值为:');n=0;fori=1:1000n=n+1;y=x;x=0.5*(x+a/x);ifabs(x-y)
PrivateSubForm_click()p1=1p2=1p3=p1i=1DoWhileAbs(p3)>0.0000001'p3要取绝对值p2=(-1)*p2p3=p2/(i+1)p1=p1+p3'
PrivateSubForm_Load()Fori=1To50n=1Forj=2Toin=n*jNexts=s+1/nNextMsgBoxsEndSu
Private Sub Command1_Click() '如果是题目要求用循环镶嵌个人觉得应该这样写
#include<stdio.h>void main (void){int i,j,k=-1;float p=0.0;for (i=
假设级数表达式为f(i),随i值的变化而减小,则可在循环时利用级数f(i)和f(i-1)的差值来与10^-6比较,当两次计算的结果满足dpp=Abs(dc)b=b*-1n=n+1mv=rad^(2*(
DimsignAsInteger,aAsLong,piAsDoublesign=-1Fori=1To100000a=2*i-1sign=-1*signpi=pi+(1/a)*signNextpi=pi
for(n=1;n
PrivateSubCommand1_Click()a=Val(InputBox("a="))x=0:y=aDoWhileAbs(y-x)>=0.00001x=yy=(x+a/x)/2LoopPrin
Privatefunctione()Dime1,n,jcn=0e1=1jc=1Don=n+1jc=n*jce1=e1+1/jcLoopUntil1/jc
PrivateSubCommand1_Click()a=1Don=n+1m=2*n-1s=s+a*1/ma=-aLoopUntilAbs(1/m)pi=4*sPrint"pi="&piEndSu
PrivateSubForm_Click()Dimi&,PI#Doi=i+1PI=PI+(-1)^(i-1)/(2*i-1)LoopUntil1/iPI=PI*4Print"π=";PIEndSu
num=m*(4/(2*n-1));改为num=m*(4.0/(2*n-1));试试再问:!!!!!哦哦,还要把m=pow((-1),(n+1));放到循环里面
PrivateSubCommand1_Click()DimNAsDouble,PiAsDoublePi=2ForN=1To1000Pi=Pi*(2*N)^2/((2*N-1)*(2*N+1))IfN=
PrivateSubCommand1_Click()Dimn,pi,ipi=2n=Val(InputBox("请输入一个数"))Fori=1Tonpi=pi*((2*i)^2/((2*i-1)*(2*