
(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 12 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 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
pow199.6%
Applied egg-rr99.6%
unpow199.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (* x (+ 1.0 (hypot 1.0 (pow x -0.5))))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x * (1.0 + hypot(1.0, pow(x, -0.5))));
}
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x * (1.0 + Math.hypot(1.0, Math.pow(x, -0.5))));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x * (1.0 + math.hypot(1.0, math.pow(x, -0.5))))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x * Float64(1.0 + hypot(1.0, (x ^ -0.5))))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x * (1.0 + hypot(1.0, (x ^ -0.5)))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(1.0 + 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 \cdot \left(1 + \mathsf{hypot}\left(1, {x}^{-0.5}\right)\right)}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
pow199.6%
Applied egg-rr99.6%
unpow199.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
(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 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
pow199.6%
Applied egg-rr99.6%
unpow199.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
hypot-undefine99.7%
pow1/299.7%
metadata-eval99.7%
pow-prod-up99.7%
metadata-eval99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow1/299.7%
Simplified99.7%
(FPCore (x) :precision binary64 (* (pow (+ 1.0 x) -0.5) (/ (+ (/ (- (/ (- 0.0625 (* (/ 1.0 x) 0.0390625)) x) 0.125) x) 0.5) x)))
double code(double x) {
return pow((1.0 + x), -0.5) * ((((((0.0625 - ((1.0 / x) * 0.0390625)) / 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 - ((1.0d0 / x) * 0.0390625d0)) / 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 - ((1.0 / x) * 0.0390625)) / x) - 0.125) / x) + 0.5) / x);
}
def code(x): return math.pow((1.0 + x), -0.5) * ((((((0.0625 - ((1.0 / x) * 0.0390625)) / 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(Float64(1.0 / x) * 0.0390625)) / x) - 0.125) / x) + 0.5) / x)) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) * ((((((0.0625 - ((1.0 / x) * 0.0390625)) / 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[(N[(1.0 / x), $MachinePrecision] * 0.0390625), $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 - \frac{1}{x} \cdot 0.0390625}{x} - 0.125}{x} + 0.5}{x}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around -inf 99.2%
Final simplification99.2%
(FPCore (x) :precision binary64 (* (pow (+ 1.0 x) -0.5) (/ (- (/ (- (- 0.125) (/ -0.0625 x)) x) -0.5) x)))
double code(double x) {
return pow((1.0 + x), -0.5) * ((((-0.125 - (-0.0625 / x)) / x) - -0.5) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) * ((((-0.125d0 - ((-0.0625d0) / x)) / x) - (-0.5d0)) / x)
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) * ((((-0.125 - (-0.0625 / x)) / x) - -0.5) / x);
}
def code(x): return math.pow((1.0 + x), -0.5) * ((((-0.125 - (-0.0625 / x)) / x) - -0.5) / x)
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) * Float64(Float64(Float64(Float64(Float64(-0.125) - Float64(-0.0625 / x)) / x) - -0.5) / x)) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) * ((((-0.125 - (-0.0625 / x)) / x) - -0.5) / x); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(N[(N[((-0.125) - N[(-0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(1 + x\right)}^{-0.5} \cdot \frac{\frac{\left(-0.125\right) - \frac{-0.0625}{x}}{x} - -0.5}{x}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around -inf 99.1%
mul-1-neg99.1%
distribute-neg-frac299.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (* x (+ 1.0 (+ 1.0 (/ 0.5 x))))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x * (1.0 + (1.0 + (0.5 / x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) / (x * (1.0d0 + (1.0d0 + (0.5d0 / x))))
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x * (1.0 + (1.0 + (0.5 / x))));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x * (1.0 + (1.0 + (0.5 / x))))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x * Float64(1.0 + Float64(1.0 + Float64(0.5 / x))))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x * (1.0 + (1.0 + (0.5 / x)))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(1.0 + N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{x \cdot \left(1 + \left(1 + \frac{0.5}{x}\right)\right)}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
pow199.6%
Applied egg-rr99.6%
unpow199.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (* x (+ (/ 0.5 x) 2.0))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x * ((0.5 / x) + 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) / (x * ((0.5d0 / x) + 2.0d0))
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x * ((0.5 / x) + 2.0));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x * ((0.5 / x) + 2.0))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x * Float64(Float64(0.5 / x) + 2.0))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x * ((0.5 / x) + 2.0)); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x * N[(N[(0.5 / x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{x \cdot \left(\frac{0.5}{x} + 2\right)}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
pow199.6%
Applied egg-rr99.6%
unpow199.6%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Taylor expanded in x around inf 99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification99.0%
(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((Float64(1.0 + x) ^ -0.5) * 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[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] * N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5} \cdot \left(0.5 - \frac{0.125}{x}\right)}{x}
\end{array}
Initial program 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
associate-*l/99.0%
Applied egg-rr99.0%
Final simplification99.0%
(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 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
Taylor expanded in x around inf 98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.9%
(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 30.0%
frac-sub30.0%
div-inv30.0%
*-rgt-identity30.0%
*-un-lft-identity30.0%
+-commutative30.0%
metadata-eval30.0%
frac-times30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
inv-pow30.0%
sqrt-pow230.0%
+-commutative30.0%
metadata-eval30.0%
Applied egg-rr30.0%
associate-*r/30.0%
*-rgt-identity30.0%
times-frac30.0%
div-sub30.0%
sub-neg30.0%
*-inverses30.0%
metadata-eval30.0%
/-rgt-identity30.0%
Simplified30.0%
flip-+29.9%
pow229.9%
sqrt-undiv29.9%
metadata-eval29.9%
sqrt-undiv29.9%
Applied egg-rr29.9%
unpow229.9%
rem-square-sqrt30.0%
*-rgt-identity30.0%
associate-*r/26.8%
*-commutative26.8%
+-commutative26.8%
distribute-rgt-in26.8%
rgt-mult-inverse30.0%
*-lft-identity30.0%
rem-exp-log30.0%
log1p-undefine30.0%
expm1-define99.6%
sub-neg99.6%
*-rgt-identity99.6%
metadata-eval99.6%
distribute-lft1-in99.6%
distribute-rgt1-in99.6%
*-rgt-identity99.6%
*-rgt-identity99.6%
associate-*r/99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 61.4%
*-commutative61.4%
Simplified61.4%
*-un-lft-identity61.4%
pow-flip62.4%
sqrt-pow198.1%
metadata-eval98.1%
metadata-eval98.1%
Applied egg-rr98.1%
*-lft-identity98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x) :precision binary64 (if (<= x 6.3e+153) (/ (- 0.5 (/ 0.125 x)) x) 0.0))
double code(double x) {
double tmp;
if (x <= 6.3e+153) {
tmp = (0.5 - (0.125 / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 6.3d+153) then
tmp = (0.5d0 - (0.125d0 / x)) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 6.3e+153) {
tmp = (0.5 - (0.125 / x)) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 6.3e+153: tmp = (0.5 - (0.125 / x)) / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 6.3e+153) tmp = Float64(Float64(0.5 - Float64(0.125 / x)) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 6.3e+153) tmp = (0.5 - (0.125 / x)) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 6.3e+153], N[(N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.3 \cdot 10^{+153}:\\
\;\;\;\;\frac{0.5 - \frac{0.125}{x}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 6.3000000000000001e153Initial program 9.3%
frac-sub9.4%
div-inv9.4%
*-rgt-identity9.4%
*-un-lft-identity9.4%
+-commutative9.4%
metadata-eval9.4%
frac-times9.4%
associate-*l/9.4%
*-un-lft-identity9.4%
inv-pow9.4%
sqrt-pow29.4%
+-commutative9.4%
metadata-eval9.4%
Applied egg-rr9.4%
associate-*r/9.4%
*-rgt-identity9.4%
times-frac9.4%
div-sub9.3%
sub-neg9.3%
*-inverses9.3%
metadata-eval9.3%
/-rgt-identity9.3%
Simplified9.3%
Taylor expanded in x around inf 98.1%
associate-*r/98.1%
metadata-eval98.1%
Simplified98.1%
associate-*l/98.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 8.5%
if 6.3000000000000001e153 < x Initial program 53.0%
add-exp-log5.1%
log-rec5.1%
pow1/25.1%
log-pow5.1%
+-commutative5.1%
log1p-define5.1%
Applied egg-rr5.1%
Taylor expanded in x around inf 5.1%
distribute-lft-neg-in5.1%
metadata-eval5.1%
*-commutative5.1%
exp-to-pow53.0%
unpow1/253.0%
+-inverses53.0%
Simplified53.0%
Final simplification29.5%
(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 30.0%
add-exp-log7.3%
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.9%
distribute-lft-neg-in4.9%
metadata-eval4.9%
*-commutative4.9%
exp-to-pow27.3%
unpow1/227.3%
+-inverses27.3%
Simplified27.3%
(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 2024143
(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)))))