
(FPCore (x) :precision binary64 (* (sqrt (- x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x - 1.0)) * sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x - 1.0d0)) * sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x - 1.0)) * Math.sqrt(x);
}
def code(x): return math.sqrt((x - 1.0)) * math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x - 1.0)) * sqrt(x)) end
function tmp = code(x) tmp = sqrt((x - 1.0)) * sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x - 1} \cdot \sqrt{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (sqrt (- x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x - 1.0)) * sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x - 1.0d0)) * sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x - 1.0)) * Math.sqrt(x);
}
def code(x): return math.sqrt((x - 1.0)) * math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x - 1.0)) * sqrt(x)) end
function tmp = code(x) tmp = sqrt((x - 1.0)) * sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x - 1} \cdot \sqrt{x}
\end{array}
(FPCore (x) :precision binary64 (- (+ x -0.5) (/ (+ (/ 0.0625 x) 0.125) x)))
double code(double x) {
return (x + -0.5) - (((0.0625 / x) + 0.125) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x + (-0.5d0)) - (((0.0625d0 / x) + 0.125d0) / x)
end function
public static double code(double x) {
return (x + -0.5) - (((0.0625 / x) + 0.125) / x);
}
def code(x): return (x + -0.5) - (((0.0625 / x) + 0.125) / x)
function code(x) return Float64(Float64(x + -0.5) - Float64(Float64(Float64(0.0625 / x) + 0.125) / x)) end
function tmp = code(x) tmp = (x + -0.5) - (((0.0625 / x) + 0.125) / x); end
code[x_] := N[(N[(x + -0.5), $MachinePrecision] - N[(N[(N[(0.0625 / x), $MachinePrecision] + 0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + -0.5\right) - \frac{\frac{0.0625}{x} + 0.125}{x}
\end{array}
Initial program 99.3%
Taylor expanded in x around -inf 0.0%
Simplified99.7%
sub-neg99.7%
*-rgt-identity99.7%
distribute-neg-in99.7%
metadata-eval99.7%
Applied egg-rr99.7%
unsub-neg99.7%
associate-+r-99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (- x (- 0.5 (/ -0.125 x))))
double code(double x) {
return x - (0.5 - (-0.125 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x - (0.5d0 - ((-0.125d0) / x))
end function
public static double code(double x) {
return x - (0.5 - (-0.125 / x));
}
def code(x): return x - (0.5 - (-0.125 / x))
function code(x) return Float64(x - Float64(0.5 - Float64(-0.125 / x))) end
function tmp = code(x) tmp = x - (0.5 - (-0.125 / x)); end
code[x_] := N[(x - N[(0.5 - N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(0.5 - \frac{-0.125}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around -inf 0.0%
Simplified99.7%
Taylor expanded in x around inf 99.6%
associate-*r/99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-neg-frac99.6%
unsub-neg99.6%
Simplified99.6%
(FPCore (x) :precision binary64 (+ x -0.5))
double code(double x) {
return x + -0.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x + (-0.5d0)
end function
public static double code(double x) {
return x + -0.5;
}
def code(x): return x + -0.5
function code(x) return Float64(x + -0.5) end
function tmp = code(x) tmp = x + -0.5; end
code[x_] := N[(x + -0.5), $MachinePrecision]
\begin{array}{l}
\\
x + -0.5
\end{array}
Initial program 99.3%
Taylor expanded in x around inf 99.3%
sub-neg99.3%
distribute-rgt-in99.3%
*-lft-identity99.3%
associate-*r/99.3%
metadata-eval99.3%
distribute-neg-frac299.3%
neg-mul-199.3%
associate-*l/99.3%
neg-mul-199.3%
distribute-neg-frac299.3%
associate-/l*99.3%
*-rgt-identity99.3%
associate-*r/99.3%
rgt-mult-inverse99.3%
metadata-eval99.3%
metadata-eval99.3%
Simplified99.3%
(FPCore (x) :precision binary64 x)
double code(double x) {
return x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x
end function
public static double code(double x) {
return x;
}
def code(x): return x
function code(x) return x end
function tmp = code(x) tmp = x; end
code[x_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.3%
Taylor expanded in x around inf 98.5%
herbie shell --seed 2024136
(FPCore (x)
:name "sqrt times"
:precision binary64
(* (sqrt (- x 1.0)) (sqrt x)))