cañangasñangas Posted January 22, 2012 Report Share Posted January 22, 2012 (edited) <?php function my_pi($ex){ $n=$ex; $a[0]=1; $b[0]=1/pow(2,1/2); $t[0]=1/4; $p[0]=$a[0]; for($i=0;$i<=$n;$i++){ $j=$i+1; $a[$j] = ($a[$j-1]+$b[$j-1])/2; $b[$j] = pow($a[$j-1]*$b[$j-1],1/2); $p[$j] = 2*$p[$j-1]; $t[$j] = $t[$j-1]-($p[$j-1]*pow($a[$j-1]-$a[$j],2)); } return number_format(pow($a[$n]+$b[$n],2)/(4*$t[$n]),$n); } echo my_pi(40); ?> mientras mas grande el argumento mas excacto el valor de pi Edited January 22, 2012 by cañangasñangas Link to comment Share on other sites More sharing options...
holakase Posted September 9, 2013 Report Share Posted September 9, 2013 gracias, pequeño dato, pero de gran valor se agradece! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now