
(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 13 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 (/ (/ 1.0 (hypot (sqrt x) x)) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.hypot(Math.sqrt(x), x)) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x): return (1.0 / math.hypot(math.sqrt(x), x)) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x) return Float64(Float64(1.0 / hypot(sqrt(x), x)) / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) end
function tmp = code(x) tmp = (1.0 / hypot(sqrt(x), x)) / (sqrt(x) + sqrt((1.0 + x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Initial program 42.3%
frac-sub42.4%
*-rgt-identity42.4%
*-un-lft-identity42.4%
+-commutative42.4%
sqrt-unprod42.4%
+-commutative42.4%
Applied egg-rr42.4%
flip--43.7%
add-sqr-sqrt43.6%
add-sqr-sqrt44.2%
add-sqr-sqrt44.2%
hypot-1-def44.2%
Applied egg-rr44.2%
associate--l+84.9%
+-inverses84.9%
metadata-eval84.9%
+-commutative84.9%
hypot-undefine84.9%
metadata-eval84.9%
rem-square-sqrt84.9%
Simplified84.9%
div-inv84.9%
distribute-rgt-in84.9%
*-un-lft-identity84.9%
add-sqr-sqrt84.9%
hypot-define99.6%
Applied egg-rr99.6%
frac-times98.8%
metadata-eval98.8%
Applied egg-rr98.8%
associate-/l/99.7%
Simplified99.7%
(FPCore (x) :precision binary64 (/ 1.0 (* (hypot (sqrt x) x) (+ (sqrt x) (sqrt (+ 1.0 x))))))
double code(double x) {
return 1.0 / (hypot(sqrt(x), x) * (sqrt(x) + sqrt((1.0 + x))));
}
public static double code(double x) {
return 1.0 / (Math.hypot(Math.sqrt(x), x) * (Math.sqrt(x) + Math.sqrt((1.0 + x))));
}
def code(x): return 1.0 / (math.hypot(math.sqrt(x), x) * (math.sqrt(x) + math.sqrt((1.0 + x))))
function code(x) return Float64(1.0 / Float64(hypot(sqrt(x), x) * Float64(sqrt(x) + sqrt(Float64(1.0 + x))))) end
function tmp = code(x) tmp = 1.0 / (hypot(sqrt(x), x) * (sqrt(x) + sqrt((1.0 + x)))); end
code[x_] := N[(1.0 / N[(N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}
\end{array}
Initial program 42.3%
frac-sub42.4%
*-rgt-identity42.4%
*-un-lft-identity42.4%
+-commutative42.4%
sqrt-unprod42.4%
+-commutative42.4%
Applied egg-rr42.4%
flip--43.7%
add-sqr-sqrt43.6%
add-sqr-sqrt44.2%
add-sqr-sqrt44.2%
hypot-1-def44.2%
Applied egg-rr44.2%
associate--l+84.9%
+-inverses84.9%
metadata-eval84.9%
+-commutative84.9%
hypot-undefine84.9%
metadata-eval84.9%
rem-square-sqrt84.9%
Simplified84.9%
*-un-lft-identity84.9%
associate-/l/85.0%
distribute-rgt-in85.0%
*-un-lft-identity85.0%
add-sqr-sqrt85.0%
hypot-define98.8%
Applied egg-rr98.8%
*-lft-identity98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (/ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) (* x (+ 1.0 (/ 0.5 x)))))
double code(double x) {
return (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) / (x * (1.0d0 + (0.5d0 / x)))
end function
public static double code(double x) {
return (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x)));
}
def code(x): return (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x)))
function code(x) return Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) / Float64(x * Float64(1.0 + Float64(0.5 / x)))) end
function tmp = code(x) tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) / (x * (1.0 + (0.5 / x))); end
code[x_] := N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * N[(1.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x \cdot \left(1 + \frac{0.5}{x}\right)}
\end{array}
Initial program 42.3%
frac-sub42.4%
*-rgt-identity42.4%
*-un-lft-identity42.4%
+-commutative42.4%
sqrt-unprod42.4%
+-commutative42.4%
Applied egg-rr42.4%
flip--43.7%
add-sqr-sqrt43.6%
add-sqr-sqrt44.2%
add-sqr-sqrt44.2%
hypot-1-def44.2%
Applied egg-rr44.2%
associate--l+84.9%
+-inverses84.9%
metadata-eval84.9%
+-commutative84.9%
hypot-undefine84.9%
metadata-eval84.9%
rem-square-sqrt84.9%
Simplified84.9%
Taylor expanded in x around inf 98.4%
associate-*r/98.4%
metadata-eval98.4%
Simplified98.4%
(FPCore (x) :precision binary64 (* (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) (/ (- 1.0 (/ 0.5 x)) x)))
double code(double x) {
return (1.0 / (sqrt(x) + sqrt((1.0 + x)))) * ((1.0 - (0.5 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) * ((1.0d0 - (0.5d0 / x)) / x)
end function
public static double code(double x) {
return (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) * ((1.0 - (0.5 / x)) / x);
}
def code(x): return (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) * ((1.0 - (0.5 / x)) / x)
function code(x) return Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) * Float64(Float64(1.0 - Float64(0.5 / x)) / x)) end
function tmp = code(x) tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) * ((1.0 - (0.5 / x)) / x); end
code[x_] := N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot \frac{1 - \frac{0.5}{x}}{x}
\end{array}
Initial program 42.3%
frac-sub42.4%
*-rgt-identity42.4%
*-un-lft-identity42.4%
+-commutative42.4%
sqrt-unprod42.4%
+-commutative42.4%
Applied egg-rr42.4%
flip--43.7%
add-sqr-sqrt43.6%
add-sqr-sqrt44.2%
add-sqr-sqrt44.2%
hypot-1-def44.2%
Applied egg-rr44.2%
associate--l+84.9%
+-inverses84.9%
metadata-eval84.9%
+-commutative84.9%
hypot-undefine84.9%
metadata-eval84.9%
rem-square-sqrt84.9%
Simplified84.9%
div-inv84.9%
distribute-rgt-in84.9%
*-un-lft-identity84.9%
add-sqr-sqrt84.9%
hypot-define99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
(FPCore (x) :precision binary64 (/ (* 0.5 (pow x -0.5)) (sqrt (* x (+ 1.0 x)))))
double code(double x) {
return (0.5 * pow(x, -0.5)) / sqrt((x * (1.0 + x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 * (x ** (-0.5d0))) / sqrt((x * (1.0d0 + x)))
end function
public static double code(double x) {
return (0.5 * Math.pow(x, -0.5)) / Math.sqrt((x * (1.0 + x)));
}
def code(x): return (0.5 * math.pow(x, -0.5)) / math.sqrt((x * (1.0 + x)))
function code(x) return Float64(Float64(0.5 * (x ^ -0.5)) / sqrt(Float64(x * Float64(1.0 + x)))) end
function tmp = code(x) tmp = (0.5 * (x ^ -0.5)) / sqrt((x * (1.0 + x))); end
code[x_] := N[(N[(0.5 * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 \cdot {x}^{-0.5}}{\sqrt{x \cdot \left(1 + x\right)}}
\end{array}
Initial program 42.3%
frac-sub42.4%
*-rgt-identity42.4%
*-un-lft-identity42.4%
+-commutative42.4%
sqrt-unprod42.4%
+-commutative42.4%
Applied egg-rr42.4%
Taylor expanded in x around inf 82.9%
*-commutative82.9%
unpow1/282.9%
rem-exp-log80.3%
exp-neg80.3%
exp-prod80.3%
distribute-lft-neg-out80.3%
distribute-rgt-neg-in80.3%
metadata-eval80.3%
exp-to-pow82.9%
Simplified82.9%
Final simplification82.9%
(FPCore (x) :precision binary64 (* 0.5 (sqrt (/ 1.0 (pow x 3.0)))))
double code(double x) {
return 0.5 * sqrt((1.0 / pow(x, 3.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 * sqrt((1.0d0 / (x ** 3.0d0)))
end function
public static double code(double x) {
return 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
}
def code(x): return 0.5 * math.sqrt((1.0 / math.pow(x, 3.0)))
function code(x) return Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0)))) end
function tmp = code(x) tmp = 0.5 * sqrt((1.0 / (x ^ 3.0))); end
code[x_] := N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}
\end{array}
Initial program 42.3%
Taylor expanded in x around inf 69.6%
(FPCore (x) :precision binary64 (/ (+ (/ 1.0 x) (/ (+ -1.0 (/ (+ 1.0 (/ (+ (/ 1.0 x) -1.0) x)) x)) x)) (* (pow x -0.5) 2.0)))
double code(double x) {
return ((1.0 / x) + ((-1.0 + ((1.0 + (((1.0 / x) + -1.0) / x)) / x)) / x)) / (pow(x, -0.5) * 2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + (((-1.0d0) + ((1.0d0 + (((1.0d0 / x) + (-1.0d0)) / x)) / x)) / x)) / ((x ** (-0.5d0)) * 2.0d0)
end function
public static double code(double x) {
return ((1.0 / x) + ((-1.0 + ((1.0 + (((1.0 / x) + -1.0) / x)) / x)) / x)) / (Math.pow(x, -0.5) * 2.0);
}
def code(x): return ((1.0 / x) + ((-1.0 + ((1.0 + (((1.0 / x) + -1.0) / x)) / x)) / x)) / (math.pow(x, -0.5) * 2.0)
function code(x) return Float64(Float64(Float64(1.0 / x) + Float64(Float64(-1.0 + Float64(Float64(1.0 + Float64(Float64(Float64(1.0 / x) + -1.0) / x)) / x)) / x)) / Float64((x ^ -0.5) * 2.0)) end
function tmp = code(x) tmp = ((1.0 / x) + ((-1.0 + ((1.0 + (((1.0 / x) + -1.0) / x)) / x)) / x)) / ((x ^ -0.5) * 2.0); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(-1.0 + N[(N[(1.0 + N[(N[(N[(1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + \frac{-1 + \frac{1 + \frac{\frac{1}{x} + -1}{x}}{x}}{x}}{{x}^{-0.5} \cdot 2}
\end{array}
Initial program 42.3%
flip--42.3%
div-inv42.3%
frac-times26.6%
metadata-eval26.6%
add-sqr-sqrt20.6%
frac-times28.9%
metadata-eval28.9%
add-sqr-sqrt42.5%
+-commutative42.5%
inv-pow42.5%
sqrt-pow242.5%
metadata-eval42.5%
pow1/242.5%
pow-flip42.5%
+-commutative42.5%
metadata-eval42.5%
Applied egg-rr42.5%
associate-*r/42.5%
*-rgt-identity42.5%
Simplified42.5%
Taylor expanded in x around -inf 42.0%
Taylor expanded in x around inf 41.1%
*-commutative41.1%
unpow1/241.1%
rem-exp-log41.1%
exp-neg41.1%
exp-prod41.1%
distribute-lft-neg-out41.1%
distribute-rgt-neg-in41.1%
metadata-eval41.1%
exp-to-pow41.1%
Simplified41.1%
Final simplification41.1%
(FPCore (x) :precision binary64 (/ (+ (/ 1.0 x) (/ 1.0 (- -1.0 x))) (* (pow x -0.5) 2.0)))
double code(double x) {
return ((1.0 / x) + (1.0 / (-1.0 - x))) / (pow(x, -0.5) * 2.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + (1.0d0 / ((-1.0d0) - x))) / ((x ** (-0.5d0)) * 2.0d0)
end function
public static double code(double x) {
return ((1.0 / x) + (1.0 / (-1.0 - x))) / (Math.pow(x, -0.5) * 2.0);
}
def code(x): return ((1.0 / x) + (1.0 / (-1.0 - x))) / (math.pow(x, -0.5) * 2.0)
function code(x) return Float64(Float64(Float64(1.0 / x) + Float64(1.0 / Float64(-1.0 - x))) / Float64((x ^ -0.5) * 2.0)) end
function tmp = code(x) tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) / ((x ^ -0.5) * 2.0); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + N[(1.0 / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + \frac{1}{-1 - x}}{{x}^{-0.5} \cdot 2}
\end{array}
Initial program 42.3%
flip--42.3%
div-inv42.3%
frac-times26.6%
metadata-eval26.6%
add-sqr-sqrt20.6%
frac-times28.9%
metadata-eval28.9%
add-sqr-sqrt42.5%
+-commutative42.5%
inv-pow42.5%
sqrt-pow242.5%
metadata-eval42.5%
pow1/242.5%
pow-flip42.5%
+-commutative42.5%
metadata-eval42.5%
Applied egg-rr42.5%
associate-*r/42.5%
*-rgt-identity42.5%
Simplified42.5%
Taylor expanded in x around inf 41.1%
*-commutative41.1%
unpow1/241.1%
rem-exp-log41.1%
exp-neg41.1%
exp-prod41.1%
distribute-lft-neg-out41.1%
distribute-rgt-neg-in41.1%
metadata-eval41.1%
exp-to-pow41.1%
Simplified41.1%
Final simplification41.1%
(FPCore (x) :precision binary64 (* (+ (/ 1.0 x) (/ 1.0 (- -1.0 x))) (* (sqrt x) 0.5)))
double code(double x) {
return ((1.0 / x) + (1.0 / (-1.0 - x))) * (sqrt(x) * 0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 / x) + (1.0d0 / ((-1.0d0) - x))) * (sqrt(x) * 0.5d0)
end function
public static double code(double x) {
return ((1.0 / x) + (1.0 / (-1.0 - x))) * (Math.sqrt(x) * 0.5);
}
def code(x): return ((1.0 / x) + (1.0 / (-1.0 - x))) * (math.sqrt(x) * 0.5)
function code(x) return Float64(Float64(Float64(1.0 / x) + Float64(1.0 / Float64(-1.0 - x))) * Float64(sqrt(x) * 0.5)) end
function tmp = code(x) tmp = ((1.0 / x) + (1.0 / (-1.0 - x))) * (sqrt(x) * 0.5); end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] + N[(1.0 / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{1}{x} + \frac{1}{-1 - x}\right) \cdot \left(\sqrt{x} \cdot 0.5\right)
\end{array}
Initial program 42.3%
flip--42.3%
div-inv42.3%
frac-times26.6%
metadata-eval26.6%
add-sqr-sqrt20.6%
frac-times28.9%
metadata-eval28.9%
add-sqr-sqrt42.5%
+-commutative42.5%
inv-pow42.5%
sqrt-pow242.5%
metadata-eval42.5%
pow1/242.5%
pow-flip42.5%
+-commutative42.5%
metadata-eval42.5%
Applied egg-rr42.5%
Taylor expanded in x around inf 41.1%
*-commutative41.1%
Simplified41.1%
Final simplification41.1%
(FPCore (x) :precision binary64 (if (<= x 4.6e+153) (/ (- 1.0 (sqrt (/ 1.0 x))) x) 0.0))
double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = (1.0 - sqrt((1.0 / x))) / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 4.6d+153) then
tmp = (1.0d0 - sqrt((1.0d0 / x))) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = (1.0 - Math.sqrt((1.0 / x))) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.6e+153: tmp = (1.0 - math.sqrt((1.0 / x))) / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 4.6e+153) tmp = Float64(Float64(1.0 - sqrt(Float64(1.0 / x))) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.6e+153) tmp = (1.0 - sqrt((1.0 / x))) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.6e+153], N[(N[(1.0 - N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1 - \sqrt{\frac{1}{x}}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.6000000000000003e153Initial program 10.6%
frac-sub11.0%
*-rgt-identity11.0%
*-un-lft-identity11.0%
+-commutative11.0%
sqrt-unprod11.0%
+-commutative11.0%
Applied egg-rr11.0%
flip--13.6%
add-sqr-sqrt13.5%
add-sqr-sqrt14.6%
add-sqr-sqrt14.6%
hypot-1-def14.6%
Applied egg-rr14.6%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
+-commutative99.3%
hypot-undefine99.4%
metadata-eval99.4%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around 0 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in x around inf 8.4%
mul-1-neg8.4%
unsub-neg8.4%
Simplified8.4%
if 4.6000000000000003e153 < x Initial program 71.1%
add-cube-cbrt11.6%
associate-*l*11.6%
inv-pow11.6%
add-cube-cbrt17.4%
unpow-prod-down22.7%
prod-diff21.3%
Applied egg-rr16.1%
fma-undefine4.4%
distribute-lft-neg-in4.4%
fma-undefine23.4%
+-commutative23.4%
Simplified4.4%
Taylor expanded in x around inf 71.1%
distribute-rgt1-in71.1%
metadata-eval71.1%
mul0-lft71.1%
Simplified71.1%
(FPCore (x) :precision binary64 (if (<= x 4.6e+153) (/ 1.0 (+ x (sqrt x))) 0.0))
double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / (x + sqrt(x));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 4.6d+153) then
tmp = 1.0d0 / (x + sqrt(x))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / (x + Math.sqrt(x));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.6e+153: tmp = 1.0 / (x + math.sqrt(x)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 4.6e+153) tmp = Float64(1.0 / Float64(x + sqrt(x))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.6e+153) tmp = 1.0 / (x + sqrt(x)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.6e+153], N[(1.0 / N[(x + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.6000000000000003e153Initial program 10.6%
frac-sub11.0%
*-rgt-identity11.0%
*-un-lft-identity11.0%
+-commutative11.0%
sqrt-unprod11.0%
+-commutative11.0%
Applied egg-rr11.0%
flip--13.6%
add-sqr-sqrt13.5%
add-sqr-sqrt14.6%
add-sqr-sqrt14.6%
hypot-1-def14.6%
Applied egg-rr14.6%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
+-commutative99.3%
hypot-undefine99.4%
metadata-eval99.4%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around 0 8.4%
*-commutative8.4%
Simplified8.4%
sqrt-div8.4%
metadata-eval8.4%
frac-times8.4%
metadata-eval8.4%
Applied egg-rr8.4%
*-commutative8.4%
+-commutative8.4%
distribute-lft-in8.4%
rem-square-sqrt8.4%
*-rgt-identity8.4%
Simplified8.4%
if 4.6000000000000003e153 < x Initial program 71.1%
add-cube-cbrt11.6%
associate-*l*11.6%
inv-pow11.6%
add-cube-cbrt17.4%
unpow-prod-down22.7%
prod-diff21.3%
Applied egg-rr16.1%
fma-undefine4.4%
distribute-lft-neg-in4.4%
fma-undefine23.4%
+-commutative23.4%
Simplified4.4%
Taylor expanded in x around inf 71.1%
distribute-rgt1-in71.1%
metadata-eval71.1%
mul0-lft71.1%
Simplified71.1%
(FPCore (x) :precision binary64 (if (<= x 4.6e+153) (/ 1.0 x) 0.0))
double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 4.6d+153) then
tmp = 1.0d0 / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 4.6e+153) {
tmp = 1.0 / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 4.6e+153: tmp = 1.0 / x else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if (x <= 4.6e+153) tmp = Float64(1.0 / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 4.6e+153) tmp = 1.0 / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 4.6e+153], N[(1.0 / x), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 4.6000000000000003e153Initial program 10.6%
frac-sub11.0%
*-rgt-identity11.0%
*-un-lft-identity11.0%
+-commutative11.0%
sqrt-unprod11.0%
+-commutative11.0%
Applied egg-rr11.0%
flip--13.6%
add-sqr-sqrt13.5%
add-sqr-sqrt14.6%
add-sqr-sqrt14.6%
hypot-1-def14.6%
Applied egg-rr14.6%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
+-commutative99.3%
hypot-undefine99.4%
metadata-eval99.4%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around 0 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in x around inf 8.4%
if 4.6000000000000003e153 < x Initial program 71.1%
add-cube-cbrt11.6%
associate-*l*11.6%
inv-pow11.6%
add-cube-cbrt17.4%
unpow-prod-down22.7%
prod-diff21.3%
Applied egg-rr16.1%
fma-undefine4.4%
distribute-lft-neg-in4.4%
fma-undefine23.4%
+-commutative23.4%
Simplified4.4%
Taylor expanded in x around inf 71.1%
distribute-rgt1-in71.1%
metadata-eval71.1%
mul0-lft71.1%
Simplified71.1%
(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 42.3%
add-cube-cbrt10.8%
associate-*l*10.8%
inv-pow10.8%
add-cube-cbrt14.1%
unpow-prod-down16.9%
prod-diff16.1%
Applied egg-rr13.3%
fma-undefine7.2%
distribute-lft-neg-in7.2%
fma-undefine17.1%
+-commutative17.1%
Simplified7.3%
Taylor expanded in x around inf 39.3%
distribute-rgt1-in39.3%
metadata-eval39.3%
mul0-lft39.3%
Simplified39.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 2024145
(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)))))