+ int orig_n = n;
+ double new_x[3], new_f[3];
+
+ if (n==0) return;
+ if (n==1) {
+ new_x[0] = x[0];
+ new_f[0] = f[0];
+ new_x[1] = x[0]+0.00001;
+ new_f[1] = f[0];
+ x = new_x;
+ f = new_f;
+ n = 3;
+ }
+ if (n==2) {
+ new_x[0] = x[0];
+ new_f[0] = f[0];
+ new_x[1] = x[1];
+ new_f[1] = f[1];
+ new_x[2] = x[1] + x[1]-x[0];
+ new_f[2] = f[1] + f[1]-f[0];
+ x = new_x;
+ f = new_f;
+ n = 3;
+ }