Skip to main content
Commonmark migration
Source Link

#C — 340 bytes + 25 points for numerical approximation = 365

C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quartic quartic.c -lm, to run ./quartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quartic 1 2 3 4 5
n

$ ./quartic -1 2 3 4 5
-1.110290760

$ ./quartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quartic quartic.c -lm, to run ./quartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quartic 1 2 3 4 5
n

$ ./quartic -1 2 3 4 5
-1.110290760

$ ./quartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quartic quartic.c -lm, to run ./quartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quartic 1 2 3 4 5
n

$ ./quartic -1 2 3 4 5
-1.110290760

$ ./quartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

Changed quintic to quartic!
Source Link
user15259
user15259

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quinticquartic quinticquartic.c -lm, to run ./quinticquartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quinticquartic 1 2 3 4 5
n

$ ./quinticquartic -1 2 3 4 5
-1.110290760

$ ./quinticquartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quintic quintic.c -lm, to run ./quintic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quintic 1 2 3 4 5
n

$ ./quintic -1 2 3 4 5
-1.110290760

$ ./quintic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quartic quartic.c -lm, to run ./quartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quartic 1 2 3 4 5
n

$ ./quartic -1 2 3 4 5
-1.110290760

$ ./quartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

Grammar.
Source Link
user15259
user15259

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quintic quintic.c -lm, to run ./quintic a b c d e. Uses Newton–Raphson method, no big whoop. Using a deterministic methodmethods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quintic 1 2 3 4 5
n

$ ./quintic -1 2 3 4 5
-1.110290760

$ ./quintic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quintic quintic.c -lm, to run ./quintic a b c d e. Uses Newton–Raphson method, no big whoop. Using a deterministic method, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quintic 1 2 3 4 5
n

$ ./quintic -1 2 3 4 5
-1.110290760

$ ./quintic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

#C — 340 bytes + 25 points for numerical approximation = 365

To compile gcc -o quintic quintic.c -lm, to run ./quintic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.

$ ./quintic 1 2 3 4 5
n

$ ./quintic -1 2 3 4 5
-1.110290760

$ ./quintic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

Revised score.
Source Link
user15259
user15259
Loading
Source Link
user15259
user15259
Loading