summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--charf.c5
-rw-r--r--double-error.c6
-rw-r--r--double-error.h2
-rw-r--r--double.c5
-rw-r--r--double.h2
-rw-r--r--ratio.c8
-rw-r--r--ratio.h2
7 files changed, 27 insertions, 3 deletions
diff --git a/charf.c b/charf.c
index 6e319ec..670e4d0 100644
--- a/charf.c
+++ b/charf.c
@@ -177,13 +177,14 @@ void compute(EXPTYPE p, int t){
/*Print f and ||Mf^{(k)}||_p/||f^{(k)}||_p if the latter is close to 1/2.*/
//if(to_double(r)>.4997)
if(to_double(r)>.65)
+ //if(to_double(r)>.30)
{
printf("f: ");
for(int i=0;i<D;i++) printf("%1.0f ",to_double(f[i]));
printf("\n");
char s[128];
- to_string(s,r);
- printf("%.4f (%s)\n",to_double(r),s);
+ root_to_string(s,r,p);
+ printf("%s\n",s);
}
}
diff --git a/double-error.c b/double-error.c
index 06d27ae..d5bac3d 100644
--- a/double-error.c
+++ b/double-error.c
@@ -108,3 +108,9 @@ double_error power(double_error de, double_error p) {
}
double to_double(double_error de){ return de.v; }
+
+bool root_to_string(char* s, double_error de, double_error p){
+ double_error de1p = power(de,ratio(convert_int(1),p));
+ to_string(s,de1p);
+ return true;
+}
diff --git a/double-error.h b/double-error.h
index bce8cd5..23b78d9 100644
--- a/double-error.h
+++ b/double-error.h
@@ -23,3 +23,5 @@ double_error power(double_error,double_error);
double to_double(double_error);
bool to_string(char*,double_error);
+
+bool root_to_string(char*,double_error,double_error);
diff --git a/double.c b/double.c
index cf4796c..f86a586 100644
--- a/double.c
+++ b/double.c
@@ -31,3 +31,8 @@ bool to_string(char* s, double d){
sprintf(s,"%f",d);
return true;
}
+
+bool root_to_string(char* s, double d, double p){
+ to_string(s,pow(d,1/p));
+ return true;
+}
diff --git a/double.h b/double.h
index e0d0a21..98949b1 100644
--- a/double.h
+++ b/double.h
@@ -21,3 +21,5 @@ double power(double,double);
double to_double(double);
double to_string(char*,double);
+
+double root_to_string(char*,double,double);
diff --git a/ratio.c b/ratio.c
index 07a28ce..3b38ea7 100644
--- a/ratio.c
+++ b/ratio.c
@@ -127,8 +127,14 @@ double to_double(rational r){
return i*((double)r.n)/((double)r.d);
}
-bool to_string(char* s,rational r){
+bool to_string(char* s, rational r){
double f = to_double(r);
sprintf(s,"%llu / %llu = %f +/- %6.1e",r.n,r.d,f,f*DBL_EPSILON);
return true;
}
+
+bool root_to_string(char* s, rational r, unsigned int p){
+ double f = pow(to_double(r),1.0/p);
+ sprintf(s,"(%llu / %llu)^1/%i = %f +/- %6.1e",r.n,r.d,p,f,2*DBL_EPSILON*f);
+ return true;
+}
diff --git a/ratio.h b/ratio.h
index 5899cfa..cd50c8e 100644
--- a/ratio.h
+++ b/ratio.h
@@ -28,3 +28,5 @@ rational power(rational,unsigned int);
double to_double(rational);
bool to_string(char*,rational r);
+
+bool root_to_string(char*,rational r,unsigned int);