
(FPCore (x) :precision binary64 (/ x (+ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return x / (1.0 + sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / (1.0d0 + sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return x / (1.0 + Math.sqrt((x + 1.0)));
}
def code(x): return x / (1.0 + math.sqrt((x + 1.0)))
function code(x) return Float64(x / Float64(1.0 + sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = x / (1.0 + sqrt((x + 1.0))); end
code[x_] := N[(x / N[(1.0 + N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + \sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ x (+ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return x / (1.0 + sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / (1.0d0 + sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return x / (1.0 + Math.sqrt((x + 1.0)));
}
def code(x): return x / (1.0 + math.sqrt((x + 1.0)))
function code(x) return Float64(x / Float64(1.0 + sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = x / (1.0 + sqrt((x + 1.0))); end
code[x_] := N[(x / N[(1.0 + N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + \sqrt{x + 1}}
\end{array}
(FPCore (x) :precision binary64 (/ x (+ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return x / (1.0 + sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x / (1.0d0 + sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return x / (1.0 + Math.sqrt((x + 1.0)));
}
def code(x): return x / (1.0 + math.sqrt((x + 1.0)))
function code(x) return Float64(x / Float64(1.0 + sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = x / (1.0 + sqrt((x + 1.0))); end
code[x_] := N[(x / N[(1.0 + N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1 + \sqrt{x + 1}}
\end{array}
Initial program 99.7%
(FPCore (x) :precision binary64 (sqrt (+ x 1.0)))
double code(double x) {
return sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0))
end function
public static double code(double x) {
return Math.sqrt((x + 1.0));
}
def code(x): return math.sqrt((x + 1.0))
function code(x) return sqrt(Float64(x + 1.0)) end
function tmp = code(x) tmp = sqrt((x + 1.0)); end
code[x_] := N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x + 1}
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites33.6%
(FPCore (x) :precision binary64 (+ x 1.0))
double code(double x) {
return x + 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x + 1.0d0
end function
public static double code(double x) {
return x + 1.0;
}
def code(x): return x + 1.0
function code(x) return Float64(x + 1.0) end
function tmp = code(x) tmp = x + 1.0; end
code[x_] := N[(x + 1.0), $MachinePrecision]
\begin{array}{l}
\\
x + 1
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Applied rewrites4.9%
herbie shell --seed 2024321
(FPCore (x)
:name "Numeric.Log:$clog1p from log-domain-0.10.2.1, B"
:precision binary64
:pre (TRUE)
(/ x (+ 1.0 (sqrt (+ x 1.0)))))