
(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 6 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 (* (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}
Initial program 99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (- (+ x -0.5) (/ (+ 0.125 (/ 0.0625 x)) x)))
double code(double x) {
return (x + -0.5) - ((0.125 + (0.0625 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x + (-0.5d0)) - ((0.125d0 + (0.0625d0 / x)) / x)
end function
public static double code(double x) {
return (x + -0.5) - ((0.125 + (0.0625 / x)) / x);
}
def code(x): return (x + -0.5) - ((0.125 + (0.0625 / x)) / x)
function code(x) return Float64(Float64(x + -0.5) - Float64(Float64(0.125 + Float64(0.0625 / x)) / x)) end
function tmp = code(x) tmp = (x + -0.5) - ((0.125 + (0.0625 / x)) / x); end
code[x_] := N[(N[(x + -0.5), $MachinePrecision] - N[(N[(0.125 + N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + -0.5\right) - \frac{0.125 + \frac{0.0625}{x}}{x}
\end{array}
Initial program 99.2%
Taylor expanded in x around -inf 0.0%
Simplified99.1%
sub-neg99.1%
*-rgt-identity99.1%
distribute-neg-in99.1%
metadata-eval99.1%
Applied egg-rr99.1%
associate-+r+99.1%
sub-neg99.1%
Simplified99.1%
(FPCore (x) :precision binary64 (+ -0.5 (- x (/ (+ 0.125 (/ 0.0625 x)) x))))
double code(double x) {
return -0.5 + (x - ((0.125 + (0.0625 / x)) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (-0.5d0) + (x - ((0.125d0 + (0.0625d0 / x)) / x))
end function
public static double code(double x) {
return -0.5 + (x - ((0.125 + (0.0625 / x)) / x));
}
def code(x): return -0.5 + (x - ((0.125 + (0.0625 / x)) / x))
function code(x) return Float64(-0.5 + Float64(x - Float64(Float64(0.125 + Float64(0.0625 / x)) / x))) end
function tmp = code(x) tmp = -0.5 + (x - ((0.125 + (0.0625 / x)) / x)); end
code[x_] := N[(-0.5 + N[(x - N[(N[(0.125 + N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 + \left(x - \frac{0.125 + \frac{0.0625}{x}}{x}\right)
\end{array}
Initial program 99.2%
Taylor expanded in x around -inf 0.0%
Simplified99.1%
expm1-log1p-u99.1%
expm1-undefine99.1%
*-rgt-identity99.1%
Applied egg-rr99.1%
sub-neg99.1%
metadata-eval99.1%
+-commutative99.1%
log1p-undefine99.1%
rem-exp-log99.1%
associate-+r+99.1%
metadata-eval99.1%
Simplified99.1%
sub-neg99.1%
associate-+r+99.1%
metadata-eval99.1%
distribute-neg-in99.1%
metadata-eval99.1%
sub-neg99.1%
Applied egg-rr99.1%
associate-+r-99.1%
+-commutative99.1%
associate-+r-99.1%
Simplified99.1%
(FPCore (x) :precision binary64 (+ x (- (/ -0.125 x) 0.5)))
double code(double x) {
return x + ((-0.125 / x) - 0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x + (((-0.125d0) / x) - 0.5d0)
end function
public static double code(double x) {
return x + ((-0.125 / x) - 0.5);
}
def code(x): return x + ((-0.125 / x) - 0.5)
function code(x) return Float64(x + Float64(Float64(-0.125 / x) - 0.5)) end
function tmp = code(x) tmp = x + ((-0.125 / x) - 0.5); end
code[x_] := N[(x + N[(N[(-0.125 / x), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\frac{-0.125}{x} - 0.5\right)
\end{array}
Initial program 99.2%
Taylor expanded in x around -inf 0.0%
Simplified99.1%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
metadata-eval99.0%
distribute-neg-frac99.0%
unsub-neg99.0%
Simplified99.0%
Final simplification99.0%
(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.2%
Taylor expanded in x around inf 98.6%
sub-neg98.6%
distribute-rgt-in98.6%
*-lft-identity98.6%
associate-*r/98.6%
metadata-eval98.6%
distribute-neg-frac298.6%
neg-mul-198.6%
associate-*l/98.6%
neg-mul-198.6%
distribute-neg-frac298.6%
associate-/l*98.6%
*-rgt-identity98.6%
associate-*r/98.6%
rgt-mult-inverse98.6%
metadata-eval98.6%
metadata-eval98.6%
Simplified98.6%
(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.2%
Taylor expanded in x around inf 97.5%
herbie shell --seed 2024146
(FPCore (x)
:name "sqrt times"
:precision binary64
(* (sqrt (- x 1.0)) (sqrt x)))