| Alternative 1 | |
|---|---|
| Error | 29.3 |
| Cost | 13376 |
\[1 - \left(\left(1 + \sqrt{x}\right) - \sqrt{x + 1}\right)
\]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ x 1.0)))) (if (!= 1.0 0.0) (/ 1.0 (+ t_0 (sqrt x))) (- t_0 (sqrt x)))))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}
double code(double x) {
double t_0 = sqrt((x + 1.0));
double tmp;
if (1.0 != 0.0) {
tmp = 1.0 / (t_0 + sqrt(x));
} else {
tmp = t_0 - sqrt(x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((x + 1.0d0))
if (1.0d0 /= 0.0d0) then
tmp = 1.0d0 / (t_0 + sqrt(x))
else
tmp = t_0 - sqrt(x)
end if
code = tmp
end function
public static double code(double x) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
double tmp;
if (1.0 != 0.0) {
tmp = 1.0 / (t_0 + Math.sqrt(x));
} else {
tmp = t_0 - Math.sqrt(x);
}
return tmp;
}
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
def code(x): t_0 = math.sqrt((x + 1.0)) tmp = 0 if 1.0 != 0.0: tmp = 1.0 / (t_0 + math.sqrt(x)) else: tmp = t_0 - math.sqrt(x) return tmp
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function code(x) t_0 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (1.0 != 0.0) tmp = Float64(1.0 / Float64(t_0 + sqrt(x))); else tmp = Float64(t_0 - sqrt(x)); end return tmp end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
function tmp_2 = code(x) t_0 = sqrt((x + 1.0)); tmp = 0.0; if (1.0 ~= 0.0) tmp = 1.0 / (t_0 + sqrt(x)); else tmp = t_0 - sqrt(x); end tmp_2 = tmp; end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[Unequal[1.0, 0.0], N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]]
\sqrt{x + 1} - \sqrt{x}
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;1 \ne 0:\\
\;\;\;\;\frac{1}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;t_0 - \sqrt{x}\\
\end{array}
| Original | 30.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 30.0
Applied egg-rr29.7
Taylor expanded in x around 0 0.2
Taylor expanded in x around 0 0.2
Taylor expanded in x around 0 0.2
| Alternative 1 | |
|---|---|
| Error | 29.3 |
| Cost | 13376 |
| Alternative 2 | |
|---|---|
| Error | 30.0 |
| Cost | 13120 |
| Alternative 3 | |
|---|---|
| Error | 30.9 |
| Cost | 6848 |
| Alternative 4 | |
|---|---|
| Error | 31.3 |
| Cost | 64 |
herbie shell --seed 2023010
(FPCore (x)
:name "Main:bigenough3 from C"
:precision binary64
:herbie-target
(/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))
(- (sqrt (+ x 1.0)) (sqrt x)))