// x = sqrt(2) の x を求める
// x^2 = 2
// f(x) = x^2 - 2 = 0
#include <stdio.h>
int main()
{
double x, fx, dfdx;
int i;
x = 1;
for (i = 0; i < 10; i++) {
fx = (x * x) - 2;
dfdx = 2 * x;
x -= fx / dfdx;
}
return 0;
}
Ly8geCA9IHNxcnQoMikg44GuIHgg44KS5rGC44KB44KLCi8vIHheMiA9IDIKLy8gZih4KSA9IHheMiAtIDIgPSAwCiNpbmNsdWRlIDxzdGRpby5oPgoKaW50IG1haW4oKQp7Cglkb3VibGUJeCwgZngsIGRmZHg7CglpbnQJaTsKCgl4ID0gMTsKCWZvciAoaSA9IDA7IGkgPCAxMDsgaSsrKSB7CgkJZnggPSAoeCAqIHgpIC0gMjsKCQlkZmR4ID0gMiAqIHg7CgkJeCAtPSBmeCAvIGRmZHg7CgkJcHJpbnRmKCIlZCAlLjIwZlxuIiwgaSwgeCk7Cgl9CglyZXR1cm4gMDsKfQo=