
(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 8 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 (/ (+ 0.0390625 (/ 0.02734375 x)) x)) x)) x))
x))))
double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 - ((0.0390625 + (0.02734375 / x)) / x)) / x)) / x)) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (((-0.5d0) + (((-0.125d0) + (((-0.0625d0) - ((0.0390625d0 + (0.02734375d0 / x)) / x)) / x)) / x)) / x))
end function
public static double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 - ((0.0390625 + (0.02734375 / x)) / x)) / x)) / x)) / x));
}
def code(x): return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 - ((0.0390625 + (0.02734375 / x)) / x)) / x)) / x)) / x))
function code(x) return Float64(x * Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(-0.125 + Float64(Float64(-0.0625 - Float64(Float64(0.0390625 + Float64(0.02734375 / x)) / x)) / x)) / x)) / x))) end
function tmp = code(x) tmp = x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 - ((0.0390625 + (0.02734375 / x)) / x)) / x)) / x)) / x)); end
code[x_] := N[(x * N[(1.0 + N[(N[(-0.5 + N[(N[(-0.125 + N[(N[(-0.0625 - N[(N[(0.0390625 + N[(0.02734375 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / 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 - \frac{0.0390625 + \frac{0.02734375}{x}}{x}}{x}}{x}}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around -inf 0.0%
Simplified99.6%
Final simplification99.6%
(FPCore (x)
:precision binary64
(*
x
(+
1.0
(*
(+ -0.5 (/ (+ -0.125 (/ (+ -0.0625 (/ -0.0390625 x)) x)) x))
(/ 1.0 x)))))
double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) * (1.0 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (((-0.5d0) + (((-0.125d0) + (((-0.0625d0) + ((-0.0390625d0) / x)) / x)) / x)) * (1.0d0 / x)))
end function
public static double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) * (1.0 / x)));
}
def code(x): return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) * (1.0 / x)))
function code(x) return Float64(x * Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(-0.125 + Float64(Float64(-0.0625 + Float64(-0.0390625 / x)) / x)) / x)) * Float64(1.0 / x)))) end
function tmp = code(x) tmp = x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) * (1.0 / x))); end
code[x_] := N[(x * N[(1.0 + N[(N[(-0.5 + N[(N[(-0.125 + N[(N[(-0.0625 + N[(-0.0390625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 + \left(-0.5 + \frac{-0.125 + \frac{-0.0625 + \frac{-0.0390625}{x}}{x}}{x}\right) \cdot \frac{1}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around -inf 0.0%
Simplified99.6%
div-inv99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x) :precision binary64 (* x (+ 1.0 (/ (+ -0.5 (/ (+ -0.125 (/ (+ -0.0625 (/ -0.0390625 x)) x)) x)) x))))
double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 + (((-0.5d0) + (((-0.125d0) + (((-0.0625d0) + ((-0.0390625d0) / x)) / x)) / x)) / x))
end function
public static double code(double x) {
return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) / x));
}
def code(x): return x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) / x))
function code(x) return Float64(x * Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(-0.125 + Float64(Float64(-0.0625 + Float64(-0.0390625 / x)) / x)) / x)) / x))) end
function tmp = code(x) tmp = x * (1.0 + ((-0.5 + ((-0.125 + ((-0.0625 + (-0.0390625 / x)) / x)) / x)) / x)); end
code[x_] := N[(x * N[(1.0 + N[(N[(-0.5 + N[(N[(-0.125 + N[(N[(-0.0625 + N[(-0.0390625 / x), $MachinePrecision]), $MachinePrecision] / 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 + \frac{-0.0390625}{x}}{x}}{x}}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around -inf 0.0%
Simplified99.6%
Final simplification99.6%
(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 0.0%
Simplified99.6%
Taylor expanded in x around inf 99.5%
sub-neg99.5%
associate-*r/99.5%
neg-mul-199.5%
distribute-neg-in99.5%
metadata-eval99.5%
unsub-neg99.5%
associate-*r/99.5%
metadata-eval99.5%
metadata-eval99.5%
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%
add-log-exp6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
add-log-exp99.3%
*-commutative99.3%
sqrt-unprod51.9%
sub-neg51.9%
metadata-eval51.9%
Applied egg-rr51.9%
+-lft-identity51.9%
Simplified51.9%
Taylor expanded in x around inf 99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (* x (- 1.0 (/ 0.5 x))))
double code(double x) {
return x * (1.0 - (0.5 / x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (1.0d0 - (0.5d0 / x))
end function
public static double code(double x) {
return x * (1.0 - (0.5 / x));
}
def code(x): return x * (1.0 - (0.5 / x))
function code(x) return Float64(x * Float64(1.0 - Float64(0.5 / x))) end
function tmp = code(x) tmp = x * (1.0 - (0.5 / x)); end
code[x_] := N[(x * N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{0.5}{x}\right)
\end{array}
Initial program 99.3%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Final simplification99.3%
(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%
add-log-exp6.4%
*-un-lft-identity6.4%
log-prod6.4%
metadata-eval6.4%
add-log-exp99.3%
*-commutative99.3%
sqrt-unprod51.9%
sub-neg51.9%
metadata-eval51.9%
Applied egg-rr51.9%
+-lft-identity51.9%
Simplified51.9%
Taylor expanded in x around inf 99.5%
Simplified99.5%
Taylor expanded in x around inf 99.5%
Final simplification99.5%
(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.6%
Final simplification98.6%
herbie shell --seed 2024055
(FPCore (x)
:name "sqrt times"
:precision binary64
(* (sqrt (- x 1.0)) (sqrt x)))