
(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 5 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 (+ 1.0 (/ (- -0.5 (/ (+ 0.125 (/ 0.0625 x)) x)) x))))
double code(double x) {
return x * (1.0 + ((-0.5 - ((0.125 + (0.0625 / x)) / x)) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (((-0.5d0) - ((0.125d0 + (0.0625d0 / x)) / x)) / x))
end function
public static double code(double x) {
return x * (1.0 + ((-0.5 - ((0.125 + (0.0625 / x)) / x)) / x));
}
def code(x): return x * (1.0 + ((-0.5 - ((0.125 + (0.0625 / x)) / x)) / x))
function code(x) return Float64(x * Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(0.125 + Float64(0.0625 / x)) / x)) / x))) end
function tmp = code(x) tmp = x * (1.0 + ((-0.5 - ((0.125 + (0.0625 / x)) / x)) / x)); end
code[x_] := N[(x * N[(1.0 + N[(N[(-0.5 - N[(N[(0.125 + N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + \frac{-0.5 - \frac{0.125 + \frac{0.0625}{x}}{x}}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around inf
Simplified99.5%
associate-+r-N/A
+-commutativeN/A
flip-+N/A
frac-subN/A
/-lowering-/.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
metadata-evalN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
--lowering--.f6435.0%
Applied egg-rr35.0%
Taylor expanded in x around -inf
Simplified99.5%
Final simplification99.5%
(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(x + Float64(-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[(x + N[(-0.5 - N[(N[(0.125 + N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(-0.5 - \frac{0.125 + \frac{0.0625}{x}}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around inf
Simplified99.5%
(FPCore (x) :precision binary64 (+ (/ -0.125 x) (+ x -0.5)))
double code(double x) {
return (-0.125 / x) + (x + -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-0.125d0) / x) + (x + (-0.5d0))
end function
public static double code(double x) {
return (-0.125 / x) + (x + -0.5);
}
def code(x): return (-0.125 / x) + (x + -0.5)
function code(x) return Float64(Float64(-0.125 / x) + Float64(x + -0.5)) end
function tmp = code(x) tmp = (-0.125 / x) + (x + -0.5); end
code[x_] := N[(N[(-0.125 / x), $MachinePrecision] + N[(x + -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.125}{x} + \left(x + -0.5\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around inf
Simplified99.3%
+-commutativeN/A
*-rgt-identityN/A
+-commutativeN/A
associate-+l+N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6499.3%
Applied egg-rr99.3%
(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
sub-negN/A
distribute-lft-inN/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-frac2N/A
mul-1-negN/A
rem-square-sqrtN/A
unpow2N/A
*-commutativeN/A
associate-*r/N/A
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
distribute-neg-frac2N/A
associate-/l*N/A
*-rgt-identityN/A
associate-*r/N/A
rgt-mult-inverseN/A
metadata-evalN/A
metadata-evalN/A
Simplified98.9%
(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
Simplified97.5%
herbie shell --seed 2024138
(FPCore (x)
:name "sqrt times"
:precision binary64
(* (sqrt (- x 1.0)) (sqrt x)))