基于牛顿-拉夫森迭代算法的开方程序设计.doc基于牛顿-拉夫森迭代算法的开方程序设计一:C语言主函数程序#include""#include""intcon_buf=0;inthtime=0;clock_tstart,stop,substraction;inta_in;inttemp1;inttemp2;intbeta=0;floatinput0=;floatinput1=0;shortintx;intx_temp;intflag1=0;intflag2=0;intflag=0;intq=0;//constfloata0=;shortinta0=21845;//q15//constfloata1=;shortconstinta1=11605;//q15//constinta2=;shortconstinta2=21528;//q14//constinta3=;shortconstinta3=25001;//q15//constinta4=;shortconstinta4=25703;//q14inta_out1=0;inta_out2=0;inttemp=0;floatoutput=0;main(){start=clock();input1=input0;while(input1>1){input1=input1/4;flag1+=1;}while(input1<){input1=input1*4;flag2+=1;}x=(int)(input1*32768);//q15//x_temp=(int)(input1*16384);//q14//a_in=a0*x+a1;temp=a0*x;//q30//a_in=a0*x+a1;////+a11a_in=(temp>>15)+a1;//q15//////+a1//beta=*x*x-*x+;////*x*xtemp=x*x;//q30temp1=temp>>15;//q15temp=temp1*a3;//30temp1=temp>>15;//q15////*x*x//*xtemp=a4*x;//q29temp2=temp>>14;//q15//*x//qiubetabeta=(temp1>>1)+a2-(temp2>>1);//q14//qiubeta//a_out1=beta*(x-a_in*a_in)+a_in;temp=a_in*a_in;//q30temp1=temp>>15;//q15temp2=x-temp1;temp=temp2*beta;//q30temp2=temp>>15;//q15a_out1=temp2+a_in;//q15//a_out2=beta*(x-a_out1*a_out1)+a_out1;temp=a_out1*
基于牛顿-拉夫森迭代算法的开方程序设计 来自淘豆网www.taodocs.com转载请标明出处.