
(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 (* (/ 1.0 (+ x (* (sqrt (+ x 1.0)) (sqrt x)))) (pow (+ x 1.0) -0.5)))
double code(double x) {
return (1.0 / (x + (sqrt((x + 1.0)) * sqrt(x)))) * pow((x + 1.0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x + (sqrt((x + 1.0d0)) * sqrt(x)))) * ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
return (1.0 / (x + (Math.sqrt((x + 1.0)) * Math.sqrt(x)))) * Math.pow((x + 1.0), -0.5);
}
def code(x): return (1.0 / (x + (math.sqrt((x + 1.0)) * math.sqrt(x)))) * math.pow((x + 1.0), -0.5)
function code(x) return Float64(Float64(1.0 / Float64(x + Float64(sqrt(Float64(x + 1.0)) * sqrt(x)))) * (Float64(x + 1.0) ^ -0.5)) end
function tmp = code(x) tmp = (1.0 / (x + (sqrt((x + 1.0)) * sqrt(x)))) * ((x + 1.0) ^ -0.5); end
code[x_] := N[(N[(1.0 / N[(x + N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x + \sqrt{x + 1} \cdot \sqrt{x}} \cdot {\left(x + 1\right)}^{-0.5}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
div-inv99.0%
pow1/299.0%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l/99.2%
distribute-rgt-in99.2%
rem-square-sqrt99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ x 1.0)))) (/ (/ 1.0 (+ x (* t_0 (sqrt x)))) t_0)))
double code(double x) {
double t_0 = sqrt((x + 1.0));
return (1.0 / (x + (t_0 * sqrt(x)))) / t_0;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sqrt((x + 1.0d0))
code = (1.0d0 / (x + (t_0 * sqrt(x)))) / t_0
end function
public static double code(double x) {
double t_0 = Math.sqrt((x + 1.0));
return (1.0 / (x + (t_0 * Math.sqrt(x)))) / t_0;
}
def code(x): t_0 = math.sqrt((x + 1.0)) return (1.0 / (x + (t_0 * math.sqrt(x)))) / t_0
function code(x) t_0 = sqrt(Float64(x + 1.0)) return Float64(Float64(1.0 / Float64(x + Float64(t_0 * sqrt(x)))) / t_0) end
function tmp = code(x) t_0 = sqrt((x + 1.0)); tmp = (1.0 / (x + (t_0 * sqrt(x)))) / t_0; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(1.0 / N[(x + N[(t$95$0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\frac{\frac{1}{x + t\_0 \cdot \sqrt{x}}}{t\_0}
\end{array}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
associate-/l/99.0%
add-sqr-sqrt98.9%
times-frac99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-*r/99.0%
pow-sqr99.1%
metadata-eval99.1%
unpow-199.1%
associate-/l/99.0%
distribute-rgt-in99.1%
rem-square-sqrt99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ -1.0 (- (* x (+ -1.0 (/ (- (/ 0.125 x) 0.5) x))) x))))
double code(double x) {
return pow((x + 1.0), -0.5) * (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((-1.0d0) / ((x * ((-1.0d0) + (((0.125d0 / x) - 0.5d0) / x))) - x))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x));
}
def code(x): return math.pow((x + 1.0), -0.5) * (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(-1.0 / Float64(Float64(x * Float64(-1.0 + Float64(Float64(Float64(0.125 / x) - 0.5) / x))) - x))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x)); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(-1.0 / N[(N[(x * N[(-1.0 + N[(N[(N[(0.125 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{-1}{x \cdot \left(-1 + \frac{\frac{0.125}{x} - 0.5}{x}\right) - x}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
div-inv99.0%
pow1/299.0%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l/99.2%
distribute-rgt-in99.2%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (/ (/ -1.0 (- (* x (+ -1.0 (/ (- (/ 0.125 x) 0.5) x))) x)) (sqrt (+ x 1.0))))
double code(double x) {
return (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x)) / sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / ((x * ((-1.0d0) + (((0.125d0 / x) - 0.5d0) / x))) - x)) / sqrt((x + 1.0d0))
end function
public static double code(double x) {
return (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x)) / Math.sqrt((x + 1.0));
}
def code(x): return (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x)) / math.sqrt((x + 1.0))
function code(x) return Float64(Float64(-1.0 / Float64(Float64(x * Float64(-1.0 + Float64(Float64(Float64(0.125 / x) - 0.5) / x))) - x)) / sqrt(Float64(x + 1.0))) end
function tmp = code(x) tmp = (-1.0 / ((x * (-1.0 + (((0.125 / x) - 0.5) / x))) - x)) / sqrt((x + 1.0)); end
code[x_] := N[(N[(-1.0 / N[(N[(x * N[(-1.0 + N[(N[(N[(0.125 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1}{x \cdot \left(-1 + \frac{\frac{0.125}{x} - 0.5}{x}\right) - x}}{\sqrt{x + 1}}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
associate-/l/99.0%
add-sqr-sqrt98.9%
times-frac99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-*r/99.0%
pow-sqr99.1%
metadata-eval99.1%
unpow-199.1%
associate-/l/99.0%
distribute-rgt-in99.1%
rem-square-sqrt99.3%
Simplified99.3%
Taylor expanded in x around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
distribute-rgt-neg-in0.0%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ (- (/ (+ (/ 0.0625 x) -0.125) x) -0.5) x)))
double code(double x) {
return pow((x + 1.0), -0.5) * (((((0.0625 / x) + -0.125) / x) - -0.5) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * (((((0.0625d0 / x) + (-0.125d0)) / x) - (-0.5d0)) / x)
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * (((((0.0625 / x) + -0.125) / x) - -0.5) / x);
}
def code(x): return math.pow((x + 1.0), -0.5) * (((((0.0625 / x) + -0.125) / x) - -0.5) / x)
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(Float64(Float64(Float64(0.0625 / x) + -0.125) / x) - -0.5) / x)) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * (((((0.0625 / x) + -0.125) / x) - -0.5) / x); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(N[(N[(N[(0.0625 / x), $MachinePrecision] + -0.125), $MachinePrecision] / x), $MachinePrecision] - -0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{\frac{\frac{0.0625}{x} + -0.125}{x} - -0.5}{x}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
div-inv99.0%
pow1/299.0%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l/99.2%
distribute-rgt-in99.2%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around -inf 0.0%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (/ (/ (- 0.5 (/ (- 0.125 (/ 0.0625 x)) x)) x) (sqrt (+ x 1.0))))
double code(double x) {
return ((0.5 - ((0.125 - (0.0625 / x)) / x)) / x) / sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.5d0 - ((0.125d0 - (0.0625d0 / x)) / x)) / x) / sqrt((x + 1.0d0))
end function
public static double code(double x) {
return ((0.5 - ((0.125 - (0.0625 / x)) / x)) / x) / Math.sqrt((x + 1.0));
}
def code(x): return ((0.5 - ((0.125 - (0.0625 / x)) / x)) / x) / math.sqrt((x + 1.0))
function code(x) return Float64(Float64(Float64(0.5 - Float64(Float64(0.125 - Float64(0.0625 / x)) / x)) / x) / sqrt(Float64(x + 1.0))) end
function tmp = code(x) tmp = ((0.5 - ((0.125 - (0.0625 / x)) / x)) / x) / sqrt((x + 1.0)); end
code[x_] := N[(N[(N[(0.5 - N[(N[(0.125 - N[(0.0625 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5 - \frac{0.125 - \frac{0.0625}{x}}{x}}{x}}{\sqrt{x + 1}}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
Taylor expanded in x around inf 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around -inf 98.5%
mul-1-neg98.5%
unsub-neg98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ 1.0 (* x (+ 2.0 (/ 0.5 x))))))
double code(double x) {
return pow((x + 1.0), -0.5) * (1.0 / (x * (2.0 + (0.5 / x))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * (1.0d0 / (x * (2.0d0 + (0.5d0 / x))))
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * (1.0 / (x * (2.0 + (0.5 / x))));
}
def code(x): return math.pow((x + 1.0), -0.5) * (1.0 / (x * (2.0 + (0.5 / x))))
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(1.0 / Float64(x * Float64(2.0 + Float64(0.5 / x))))) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * (1.0 / (x * (2.0 + (0.5 / x)))); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(1.0 / N[(x * N[(2.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{1}{x \cdot \left(2 + \frac{0.5}{x}\right)}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
div-inv99.0%
pow1/299.0%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l/99.2%
distribute-rgt-in99.2%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (/ (/ 1.0 (* x (+ 2.0 (/ 0.5 x)))) (sqrt (+ x 1.0))))
double code(double x) {
return (1.0 / (x * (2.0 + (0.5 / x)))) / sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / (x * (2.0d0 + (0.5d0 / x)))) / sqrt((x + 1.0d0))
end function
public static double code(double x) {
return (1.0 / (x * (2.0 + (0.5 / x)))) / Math.sqrt((x + 1.0));
}
def code(x): return (1.0 / (x * (2.0 + (0.5 / x)))) / math.sqrt((x + 1.0))
function code(x) return Float64(Float64(1.0 / Float64(x * Float64(2.0 + Float64(0.5 / x)))) / sqrt(Float64(x + 1.0))) end
function tmp = code(x) tmp = (1.0 / (x * (2.0 + (0.5 / x)))) / sqrt((x + 1.0)); end
code[x_] := N[(N[(1.0 / N[(x * N[(2.0 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x \cdot \left(2 + \frac{0.5}{x}\right)}}{\sqrt{x + 1}}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
associate-/l/99.0%
add-sqr-sqrt98.9%
times-frac99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
inv-pow99.0%
sqrt-pow199.0%
metadata-eval99.0%
Applied egg-rr99.0%
associate-*l/99.0%
associate-*r/99.0%
pow-sqr99.1%
metadata-eval99.1%
unpow-199.1%
associate-/l/99.0%
distribute-rgt-in99.1%
rem-square-sqrt99.3%
Simplified99.3%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (* (pow (+ x 1.0) -0.5) (/ (- 0.5 (/ 0.125 x)) x)))
double code(double x) {
return pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((x + 1.0d0) ** (-0.5d0)) * ((0.5d0 - (0.125d0 / x)) / x)
end function
public static double code(double x) {
return Math.pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x);
}
def code(x): return math.pow((x + 1.0), -0.5) * ((0.5 - (0.125 / x)) / x)
function code(x) return Float64((Float64(x + 1.0) ^ -0.5) * Float64(Float64(0.5 - Float64(0.125 / x)) / x)) end
function tmp = code(x) tmp = ((x + 1.0) ^ -0.5) * ((0.5 - (0.125 / x)) / x); end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] * N[(N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{-0.5} \cdot \frac{0.5 - \frac{0.125}{x}}{x}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
flip--34.8%
add-sqr-sqrt26.1%
add-sqr-sqrt36.0%
Applied egg-rr36.0%
associate--l+99.1%
+-inverses99.1%
metadata-eval99.1%
+-commutative99.1%
Simplified99.1%
div-inv99.0%
pow1/299.0%
pow-flip99.2%
metadata-eval99.2%
Applied egg-rr99.2%
associate-/l/99.2%
distribute-rgt-in99.2%
rem-square-sqrt99.4%
Simplified99.4%
Taylor expanded in x around inf 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 (/ (/ (- 0.5 (/ 0.125 x)) x) (sqrt (+ x 1.0))))
double code(double x) {
return ((0.5 - (0.125 / x)) / x) / sqrt((x + 1.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((0.5d0 - (0.125d0 / x)) / x) / sqrt((x + 1.0d0))
end function
public static double code(double x) {
return ((0.5 - (0.125 / x)) / x) / Math.sqrt((x + 1.0));
}
def code(x): return ((0.5 - (0.125 / x)) / x) / math.sqrt((x + 1.0))
function code(x) return Float64(Float64(Float64(0.5 - Float64(0.125 / x)) / x) / sqrt(Float64(x + 1.0))) end
function tmp = code(x) tmp = ((0.5 - (0.125 / x)) / x) / sqrt((x + 1.0)); end
code[x_] := N[(N[(N[(0.5 - N[(0.125 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{0.5 - \frac{0.125}{x}}{x}}{\sqrt{x + 1}}
\end{array}
Initial program 34.2%
frac-sub34.3%
associate-/r*34.3%
*-un-lft-identity34.3%
+-commutative34.3%
*-rgt-identity34.3%
+-commutative34.3%
Applied egg-rr34.3%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
metadata-eval97.9%
Simplified97.9%
Final simplification97.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 34.2%
add-sqr-sqrt20.8%
sqrt-unprod34.2%
frac-times30.5%
metadata-eval30.5%
add-sqr-sqrt26.4%
+-commutative26.4%
Applied egg-rr26.4%
Taylor expanded in x around inf 58.7%
*-commutative58.7%
Simplified58.7%
*-un-lft-identity58.7%
pow-flip61.2%
sqrt-pow197.1%
metadata-eval97.1%
metadata-eval97.1%
Applied egg-rr97.1%
*-lft-identity97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
return pow(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 Math.pow(x, -0.5);
}
def code(x): return math.pow(x, -0.5)
function code(x) return x ^ -0.5 end
function tmp = code(x) tmp = x ^ -0.5; end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}
\\
{x}^{-0.5}
\end{array}
Initial program 34.2%
Taylor expanded in x around 0 5.7%
*-un-lft-identity5.7%
inv-pow5.7%
sqrt-pow15.7%
metadata-eval5.7%
Applied egg-rr5.7%
*-lft-identity5.7%
Simplified5.7%
(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 2024138
(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)))))