
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (+ x (* x (hypot 1.0 (pow x -0.5))))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x + (x * hypot(1.0, pow(x, -0.5))));
}
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x + (x * Math.hypot(1.0, Math.pow(x, -0.5))));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x + (x * math.hypot(1.0, math.pow(x, -0.5))))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x + Float64(x * hypot(1.0, (x ^ -0.5))))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x + (x * hypot(1.0, (x ^ -0.5)))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x + N[(x * N[Sqrt[1.0 ^ 2 + N[Power[x, -0.5], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{x + x \cdot \mathsf{hypot}\left(1, {x}^{-0.5}\right)}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
*-commutative99.7%
expm1-log1p-u99.7%
clear-num99.7%
un-div-inv99.7%
div-inv99.7%
expm1-log1p-u99.7%
add-sqr-sqrt99.7%
hypot-1-def99.7%
expm1-log1p-u99.7%
inv-pow99.7%
sqrt-pow199.7%
metadata-eval99.7%
clear-num99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
*-commutative99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (* x (+ 1.0 (sqrt (+ 1.0 (/ 1.0 x)))))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x * (1.0 + sqrt((1.0 + (1.0 / x)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) / (x * (1.0d0 + sqrt((1.0d0 + (1.0d0 / x)))))
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x * (1.0 + Math.sqrt((1.0 + (1.0 / x)))));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x * (1.0 + math.sqrt((1.0 + (1.0 / x)))))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x * Float64(1.0 + sqrt(Float64(1.0 + Float64(1.0 / x)))))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x * (1.0 + sqrt((1.0 + (1.0 / x))))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(1.0 + N[Sqrt[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{x \cdot \left(1 + \sqrt{1 + \frac{1}{x}}\right)}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
*-commutative99.7%
expm1-log1p-u99.7%
clear-num99.7%
un-div-inv99.7%
div-inv99.7%
expm1-log1p-u99.7%
add-sqr-sqrt99.7%
hypot-1-def99.7%
expm1-log1p-u99.7%
inv-pow99.7%
sqrt-pow199.7%
metadata-eval99.7%
clear-num99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
hypot-undefine99.8%
pow1/299.8%
metadata-eval99.8%
pow-prod-up99.8%
metadata-eval99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow1/299.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (* (pow (+ 1.0 x) -0.5) (/ (+ (/ (- (/ (+ 0.0625 (* 0.0390625 (/ -1.0 x))) x) 0.125) x) 0.5) x)))
double code(double x) {
return pow((1.0 + x), -0.5) * ((((((0.0625 + (0.0390625 * (-1.0 / x))) / x) - 0.125) / x) + 0.5) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) * ((((((0.0625d0 + (0.0390625d0 * ((-1.0d0) / x))) / x) - 0.125d0) / x) + 0.5d0) / x)
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) * ((((((0.0625 + (0.0390625 * (-1.0 / x))) / x) - 0.125) / x) + 0.5) / x);
}
def code(x): return math.pow((1.0 + x), -0.5) * ((((((0.0625 + (0.0390625 * (-1.0 / x))) / x) - 0.125) / x) + 0.5) / x)
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) * Float64(Float64(Float64(Float64(Float64(Float64(0.0625 + Float64(0.0390625 * Float64(-1.0 / x))) / x) - 0.125) / x) + 0.5) / x)) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) * ((((((0.0625 + (0.0390625 * (-1.0 / x))) / x) - 0.125) / x) + 0.5) / x); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(N[(N[(N[(N[(0.0625 + N[(0.0390625 * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.125), $MachinePrecision] / x), $MachinePrecision] + 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(1 + x\right)}^{-0.5} \cdot \frac{\frac{\frac{0.0625 + 0.0390625 \cdot \frac{-1}{x}}{x} - 0.125}{x} + 0.5}{x}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around -inf 99.5%
Final simplification99.5%
(FPCore (x) :precision binary64 (* (pow (+ 1.0 x) -0.5) (/ (+ 0.5 (/ (- (* (/ 1.0 x) 0.0625) 0.125) x)) x)))
double code(double x) {
return pow((1.0 + x), -0.5) * ((0.5 + ((((1.0 / x) * 0.0625) - 0.125) / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) * ((0.5d0 + ((((1.0d0 / x) * 0.0625d0) - 0.125d0) / x)) / x)
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) * ((0.5 + ((((1.0 / x) * 0.0625) - 0.125) / x)) / x);
}
def code(x): return math.pow((1.0 + x), -0.5) * ((0.5 + ((((1.0 / x) * 0.0625) - 0.125) / x)) / x)
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) * Float64(Float64(0.5 + Float64(Float64(Float64(Float64(1.0 / x) * 0.0625) - 0.125) / x)) / x)) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) * ((0.5 + ((((1.0 / x) * 0.0625) - 0.125) / x)) / x); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 + N[(N[(N[(N[(1.0 / x), $MachinePrecision] * 0.0625), $MachinePrecision] - 0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(1 + x\right)}^{-0.5} \cdot \frac{0.5 + \frac{\frac{1}{x} \cdot 0.0625 - 0.125}{x}}{x}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around -inf 99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (* x (+ 2.0 (/ 0.5 x)))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x * (2.0 + (0.5 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) / (x * (2.0d0 + (0.5d0 / x)))
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x * (2.0 + (0.5 / x)));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x * (2.0 + (0.5 / x)))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x * Float64(2.0 + Float64(0.5 / x)))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x * (2.0 + (0.5 / x))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(2.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{x \cdot \left(2 + \frac{0.5}{x}\right)}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
*-commutative99.7%
expm1-log1p-u99.7%
clear-num99.7%
un-div-inv99.7%
div-inv99.7%
expm1-log1p-u99.7%
add-sqr-sqrt99.7%
hypot-1-def99.7%
expm1-log1p-u99.7%
inv-pow99.7%
sqrt-pow199.7%
metadata-eval99.7%
clear-num99.8%
/-rgt-identity99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (* (pow (+ 1.0 x) -0.5) (/ (- 0.5 (/ 0.125 x)) x)))
double code(double x) {
return pow((1.0 + x), -0.5) * ((0.5 - (0.125 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) * ((0.5d0 - (0.125d0 / x)) / x)
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) * ((0.5 - (0.125 / x)) / x);
}
def code(x): return math.pow((1.0 + x), -0.5) * ((0.5 - (0.125 / x)) / x)
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) * Float64(Float64(0.5 - Float64(0.125 / x)) / x)) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) * ((0.5 - (0.125 / x)) / x); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(1 + x\right)}^{-0.5} \cdot \frac{0.5 - \frac{0.125}{x}}{x}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x) :precision binary64 (* 0.5 (pow x -1.5)))
double code(double x) {
return 0.5 * pow(x, -1.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * (x ** (-1.5d0))
end function
public static double code(double x) {
return 0.5 * Math.pow(x, -1.5);
}
def code(x): return 0.5 * math.pow(x, -1.5)
function code(x) return Float64(0.5 * (x ^ -1.5)) end
function tmp = code(x) tmp = 0.5 * (x ^ -1.5); end
code[x_] := N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot {x}^{-1.5}
\end{array}
Initial program 46.0%
frac-sub46.1%
div-inv46.1%
*-rgt-identity46.1%
*-un-lft-identity46.1%
+-commutative46.1%
metadata-eval46.1%
frac-times46.1%
associate-*l/46.1%
*-un-lft-identity46.1%
inv-pow46.1%
sqrt-pow246.1%
+-commutative46.1%
metadata-eval46.1%
Applied egg-rr46.1%
associate-*r/46.1%
*-rgt-identity46.1%
times-frac46.1%
div-sub46.0%
sub-neg46.0%
*-inverses46.0%
metadata-eval46.0%
/-rgt-identity46.0%
Simplified46.0%
flip-+46.0%
sqrt-undiv46.1%
sqrt-undiv46.0%
add-sqr-sqrt46.2%
metadata-eval46.2%
sqrt-undiv46.2%
Applied egg-rr46.2%
*-rgt-identity46.2%
associate-*r/39.7%
*-commutative39.7%
+-commutative39.7%
distribute-rgt-in39.8%
rgt-mult-inverse46.2%
*-lft-identity46.2%
rem-exp-log46.2%
log1p-undefine46.2%
expm1-define99.7%
sub-neg99.7%
metadata-eval99.7%
*-rgt-identity99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
+-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around inf 70.0%
*-commutative70.0%
Simplified70.0%
*-un-lft-identity70.0%
pow-flip70.6%
sqrt-pow197.8%
metadata-eval97.8%
metadata-eval97.8%
Applied egg-rr97.8%
*-lft-identity97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x) :precision binary64 (if (<= x 6.5e+153) (* (+ -0.5 (/ 0.125 x)) (/ -1.0 x)) 0.0))
double code(double x) {
double tmp;
if (x <= 6.5e+153) {
tmp = (-0.5 + (0.125 / x)) * (-1.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 6.5d+153) then
tmp = ((-0.5d0) + (0.125d0 / x)) * ((-1.0d0) / x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 6.5e+153) {
tmp = (-0.5 + (0.125 / x)) * (-1.0 / x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 6.5e+153: tmp = (-0.5 + (0.125 / x)) * (-1.0 / x) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 6.5e+153) tmp = Float64(Float64(-0.5 + Float64(0.125 / x)) * Float64(-1.0 / x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 6.5e+153) tmp = (-0.5 + (0.125 / x)) * (-1.0 / x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 6.5e+153], N[(N[(-0.5 + N[(0.125 / x), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{+153}:\\
\;\;\;\;\left(-0.5 + \frac{0.125}{x}\right) \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 6.49999999999999972e153Initial program 11.1%
frac-sub11.3%
div-inv11.3%
*-rgt-identity11.3%
*-un-lft-identity11.3%
+-commutative11.3%
metadata-eval11.3%
frac-times11.3%
associate-*l/11.3%
*-un-lft-identity11.3%
inv-pow11.3%
sqrt-pow211.3%
+-commutative11.3%
metadata-eval11.3%
Applied egg-rr11.3%
associate-*r/11.3%
*-rgt-identity11.3%
times-frac11.3%
div-sub11.1%
sub-neg11.1%
*-inverses11.1%
metadata-eval11.1%
/-rgt-identity11.1%
Simplified11.1%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
metadata-eval97.9%
Simplified97.9%
frac-2neg97.9%
div-inv97.9%
sub-neg97.9%
distribute-neg-in97.9%
metadata-eval97.9%
distribute-neg-frac97.9%
distribute-frac-neg297.9%
frac-2neg97.9%
distribute-neg-frac297.9%
distribute-neg-frac97.9%
metadata-eval97.9%
Applied egg-rr97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in x around 0 8.4%
if 6.49999999999999972e153 < x Initial program 75.0%
add-exp-log4.5%
log-rec4.5%
pow1/24.5%
log-pow4.5%
+-commutative4.5%
log1p-define4.5%
Applied egg-rr4.5%
Taylor expanded in x around inf 4.5%
distribute-lft-neg-in4.5%
metadata-eval4.5%
*-commutative4.5%
exp-to-pow75.0%
unpow1/275.0%
+-inverses75.0%
Simplified75.0%
Final simplification44.8%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 46.0%
add-exp-log7.4%
log-rec7.4%
pow1/27.4%
log-pow7.4%
+-commutative7.4%
log1p-define7.4%
Applied egg-rr7.4%
Taylor expanded in x around inf 4.7%
distribute-lft-neg-in4.7%
metadata-eval4.7%
*-commutative4.7%
exp-to-pow43.0%
unpow1/243.0%
+-inverses43.0%
Simplified43.0%
(FPCore (x) :precision binary64 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x): return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x) return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0))))) end
function tmp = code(x) tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0)))); end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}
herbie shell --seed 2024112
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:pre (and (> x 1.0) (< x 1e+308))
:alt
(! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))