Created
August 9, 2014 13:45
-
-
Save keizo042/6f99e1a978ebbb5de23d to your computer and use it in GitHub Desktop.
newton法、美しいアルゴリズム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<stdlib.h> | |
double newton(double c) | |
{ | |
double x; | |
int i; | |
x = ( c + c / c ) / 2; | |
for(i=0;i < 1000000; i++) | |
{ | |
x = ( x + c /x ) / 2; | |
} | |
return x; | |
} | |
int | |
main(int argc, char **argv) | |
{ | |
double c =2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2*2-1, | |
t; | |
t = newton(c); | |
printf("%10.100lf\n",t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment