#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.