[ create a new paste ] login | about

Link: http://codepad.org/ZTu5GTBq    [ raw code | output | fork ]

C, pasted on Nov 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#define Sq(a)   ((a)*(a))
void Func2(double x) {
    int i = 0;
    double y,xx;
    for ( ; i<10 && x!=x - (Sq(x)+Sq(y=x+0.5)-1)/(4*x+1) ; i++) {
        x = x - (Sq(x)+Sq(y)-1)/(4*x+1);
        xx = x - (Sq(x)+Sq(y)-1)/(4*x+1);
        printf("%d %d\n",x!=xx,x==xx);
        printf("%.60f\n",x);
        printf("%.60f\n",xx);
    }
    printf("i:%d , x:%.20f , y:%.20f , x^2+y^2:%.16f\n",i,x,y,Sq(x)+Sq(y));
}
int main(void) {
    Func2(1);
    Func2(-1);
    return 0;
}


Output:
1 0
0.550000000000000044408920985006261616945266723632812500000000
0.064843750000000061062266354383609723299741744995117187500000
1 0
0.423437500000000022204460492503130808472633361816406250000000
0.318825224767981418860784970092936418950557708740234375000000
1 0
0.411544736078886308483504308242117986083030700683593750000000
0.403190846691330873063918716070475056767463684082031250000000
1 0
0.411437836404556167568813407342531718313694000244140625000000
0.411364171470505746164292304456466808915138244628906250000000
1 0
0.411437827766147679042774143454153090715408325195312500000000
0.411437821814437609813097651567659340798854827880859375000000
1 0
0.411437827766147623531622912196326069533824920654296875000000
0.411437827766147623531622912196326069533824920654296875000000
1 0
0.411437827766147623531622912196326069533824920654296875000000
0.411437827766147623531622912196326069533824920654296875000000
1 0
0.411437827766147623531622912196326069533824920654296875000000
0.411437827766147623531622912196326069533824920654296875000000
1 0
0.411437827766147623531622912196326069533824920654296875000000
0.411437827766147623531622912196326069533824920654296875000000
1 0
0.411437827766147623531622912196326069533824920654296875000000
0.411437827766147623531622912196326069533824920654296875000000
i:10 , x:0.41143782776614762353 , y:0.91143782776614767904 , x^2+y^2:1.0000000000000000
1 0
-0.916666666666666629659232512494781985878944396972656250000000
-0.882812500000000000000000000000000000000000000000000000000000
1 0
-0.911458333333333370340767487505218014121055603027343750000000
-0.909807660761154823880758613086072728037834167480468750000000
1 0
-0.911437828083989542982124021364143118262290954589843750000000
-0.911431450110434027145345226017525419592857360839843750000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827667293198885545280063524842262268066406250000000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
1 0
-0.911437827766147679042774143454153090715408325195312500000000
-0.911437827766147679042774143454153090715408325195312500000000
i:10 , x:-0.91143782776614767904 , y:-0.41143782776614767904 , x^2+y^2:1.0000000000000000


Create a new paste based on this one


Comments: