hesaplamak PI -e do�ru iste�e g�re taml�k ( �rnek Java �ifre)
�rnek Java �ifre -e do�ru hesaplamak PI -e do�ru iste�e g�re taml�k. bu uses makine form�l: pi/4 = 4arctan1*(/5) Kuzey Kutbuyla ilgili(/239).
not etmek:
1. ko�mak Pi ile a mutlak gerekli taml�k de�er. mesel� -e do�ru hesaplamak PI -e do�ru 10 ondal�k yer ko�mak:
java Pi 10
2. var di�er algoritma ve d�z daha iyi kendisi -e do�ru hesaplamak PI �ok. bu bkz. be adil an �rnek. I kullanma o -e do�ru y�k s�nav benim -e hizmet etmek.
3. denemek ko�ma ile 1 milyon (1000000) -e do�ru vermek senin -e hizmet etmek a iyi i�
ithal etmek java.math.BigDecimal;
halk i�in toplumsal s�n�f Pi { halk i�in de�i�meyen bo� mainString( args[]) atmak NumberFormatException { int digits = Integer.parseIntargs0([]); sicim pi = computePidigits.toString()(); int freq[] = yeni int10[]; for(int i = 0;i <10;i++) freq[i]="0;" int="" c;="" for(int="" i="" <="" pi.length();i++)="" {="" c="" if(c="." )="" continue;="" -="" ;="" freq[c]++;="" }="" 10;i++)="" system.out.println(="" +="" freq[i]);="" /**="" constants="" used="" in="" pi="arctan1_5.multiply(FOUR).subtract(" computation="" */="" private="" static="" final="" bigdecimal="" four="BigDecimal.valueOf(4);" rounding="" mode="" to="" use="" during="" roundingmode="BigDecimal.ROUND_HALF_EVEN;" *="" compute="" the="" value="" of="" specified="" number="" digits="" after="" decimal="" point.="" is="" computed="" using="" machin="" s="" formula:="" pi/4="4*arctan(1/5)" arctan(1/239)="" and="" a="" power="" series="" expansion="" arctan(x)="x" sufficient="" precision.="" public="" computepi(int="" digits)="" scale="digits" 5;="" arctan1_5="arctan(5," scale);="" arctan1_239="arctan(239," arctan1_239).multiply(four);="" return="" pi.setscale(digits,="" bigdecimal.round_half_up);="" value,="" radians,="" arctangent="" inverse="" supplied="" integer="" for="" arc="" tangent:="" (x^3)/3="" (x^5)/5="" (x^7)/7="" (x^9)/9="" ...="" arctan(int="" inversex,="" scale)="" result,="" numer,="" term;="" invx="BigDecimal.valueOf(inverseX);" invx2="BigDecimal.valueOf(inverseX" inversex);="" numer="numer.divide(invX2," scale,="" roundingmode);="" result="result.add(term);" do="" denom="2" 1;="" term="numer.divide(BigDecimal.valueOf(denom)," if="" ((i="" %="" 2)="" !="0);" else="" i++;="" while="" (term.compareto(bigdecimal.zero)="" result;=""
not etmek belgili tan�ml�k �ifre bkz. have be uyarlamak --dan a java.sun �rnek.
e�e alt�ndaba�l�k haber, nas�l -e do�ru, Java bilgisayar yaz�l�m�, a��k kaynak bilgisayar yaz�l�m�, program, teknik okul not etmek |
|
RSS 2.0 |
Trackback bu e�ya
|
Email bu e�ya
sen -ebilmek da be�enmek -e do�ru okumak |



































