
(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 (let* ((t_0 (+ 1.0 (/ 1.0 x)))) (* (/ (/ -1.0 x) (- -1.0 (sqrt t_0))) (pow (* x t_0) -0.5))))
double code(double x) {
double t_0 = 1.0 + (1.0 / x);
return ((-1.0 / x) / (-1.0 - sqrt(t_0))) * pow((x * t_0), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 1.0d0 + (1.0d0 / x)
code = (((-1.0d0) / x) / ((-1.0d0) - sqrt(t_0))) * ((x * t_0) ** (-0.5d0))
end function
public static double code(double x) {
double t_0 = 1.0 + (1.0 / x);
return ((-1.0 / x) / (-1.0 - Math.sqrt(t_0))) * Math.pow((x * t_0), -0.5);
}
def code(x): t_0 = 1.0 + (1.0 / x) return ((-1.0 / x) / (-1.0 - math.sqrt(t_0))) * math.pow((x * t_0), -0.5)
function code(x) t_0 = Float64(1.0 + Float64(1.0 / x)) return Float64(Float64(Float64(-1.0 / x) / Float64(-1.0 - sqrt(t_0))) * (Float64(x * t_0) ^ -0.5)) end
function tmp = code(x) t_0 = 1.0 + (1.0 / x); tmp = ((-1.0 / x) / (-1.0 - sqrt(t_0))) * ((x * t_0) ^ -0.5); end
code[x_] := Block[{t$95$0 = N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(-1.0 / x), $MachinePrecision] / N[(-1.0 - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(x * t$95$0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{1}{x}\\
\frac{\frac{-1}{x}}{-1 - \sqrt{t\_0}} \cdot {\left(x \cdot t\_0\right)}^{-0.5}
\end{array}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
flip-+38.8%
sqrt-undiv38.9%
sqrt-undiv38.8%
add-sqr-sqrt39.0%
metadata-eval39.0%
sqrt-undiv39.0%
Applied egg-rr39.0%
*-rgt-identity39.0%
associate-*r/32.4%
*-commutative32.4%
distribute-rgt-in32.3%
rgt-mult-inverse38.9%
*-lft-identity38.9%
+-commutative38.9%
rem-exp-log38.9%
log1p-undefine38.9%
expm1-define99.7%
sub-neg99.7%
*-lft-identity99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around inf 99.7%
Taylor expanded in x around 0 99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (* (/ (/ -1.0 x) (- -1.0 (sqrt (+ 1.0 (/ 1.0 x))))) (pow (+ 1.0 x) -0.5)))
double code(double x) {
return ((-1.0 / x) / (-1.0 - sqrt((1.0 + (1.0 / x))))) * pow((1.0 + x), -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (((-1.0d0) / x) / ((-1.0d0) - sqrt((1.0d0 + (1.0d0 / x))))) * ((1.0d0 + x) ** (-0.5d0))
end function
public static double code(double x) {
return ((-1.0 / x) / (-1.0 - Math.sqrt((1.0 + (1.0 / x))))) * Math.pow((1.0 + x), -0.5);
}
def code(x): return ((-1.0 / x) / (-1.0 - math.sqrt((1.0 + (1.0 / x))))) * math.pow((1.0 + x), -0.5)
function code(x) return Float64(Float64(Float64(-1.0 / x) / Float64(-1.0 - sqrt(Float64(1.0 + Float64(1.0 / x))))) * (Float64(1.0 + x) ^ -0.5)) end
function tmp = code(x) tmp = ((-1.0 / x) / (-1.0 - sqrt((1.0 + (1.0 / x))))) * ((1.0 + x) ^ -0.5); end
code[x_] := N[(N[(N[(-1.0 / x), $MachinePrecision] / N[(-1.0 - N[Sqrt[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{-1}{x}}{-1 - \sqrt{1 + \frac{1}{x}}} \cdot {\left(1 + x\right)}^{-0.5}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
flip-+38.8%
sqrt-undiv38.9%
sqrt-undiv38.8%
add-sqr-sqrt39.0%
metadata-eval39.0%
sqrt-undiv39.0%
Applied egg-rr39.0%
*-rgt-identity39.0%
associate-*r/32.4%
*-commutative32.4%
distribute-rgt-in32.3%
rgt-mult-inverse38.9%
*-lft-identity38.9%
+-commutative38.9%
rem-exp-log38.9%
log1p-undefine38.9%
expm1-define99.7%
sub-neg99.7%
*-lft-identity99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
Final simplification99.7%
(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 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
flip-+38.8%
sqrt-undiv38.9%
sqrt-undiv38.8%
add-sqr-sqrt39.0%
metadata-eval39.0%
sqrt-undiv39.0%
Applied egg-rr39.0%
*-rgt-identity39.0%
associate-*r/32.4%
*-commutative32.4%
distribute-rgt-in32.3%
rgt-mult-inverse38.9%
*-lft-identity38.9%
+-commutative38.9%
rem-exp-log38.9%
log1p-undefine38.9%
expm1-define99.7%
sub-neg99.7%
*-lft-identity99.7%
metadata-eval99.7%
*-commutative99.7%
distribute-lft1-in99.7%
distribute-rgt1-in99.7%
*-rgt-identity99.7%
*-rgt-identity99.7%
associate-*r/99.7%
*-commutative99.7%
distribute-rgt-in99.7%
Simplified99.7%
Taylor expanded in x around -inf 99.0%
Final simplification99.0%
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (/ x (+ 0.5 (/ (+ (/ 0.0625 x) -0.125) x)))))
double code(double x) {
return pow((1.0 + x), -0.5) / (x / (0.5 + (((0.0625 / x) + -0.125) / x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = ((1.0d0 + x) ** (-0.5d0)) / (x / (0.5d0 + (((0.0625d0 / x) + (-0.125d0)) / x)))
end function
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x / (0.5 + (((0.0625 / x) + -0.125) / x)));
}
def code(x): return math.pow((1.0 + x), -0.5) / (x / (0.5 + (((0.0625 / x) + -0.125) / x)))
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x / Float64(0.5 + Float64(Float64(Float64(0.0625 / x) + -0.125) / x)))) end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x / (0.5 + (((0.0625 / x) + -0.125) / x))); end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x / N[(0.5 + N[(N[(N[(0.0625 / x), $MachinePrecision] + -0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{{\left(1 + x\right)}^{-0.5}}{\frac{x}{0.5 + \frac{\frac{0.0625}{x} + -0.125}{x}}}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
Taylor expanded in x around inf 98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
*-commutative98.9%
add-exp-log93.4%
log-prod92.9%
log-pow92.9%
log1p-define92.9%
associate-+r-92.9%
add-sqr-sqrt92.9%
pow292.9%
sqrt-div92.9%
metadata-eval92.9%
sqrt-pow192.9%
metadata-eval92.9%
pow192.9%
Applied egg-rr92.9%
exp-sum93.4%
*-commutative93.4%
log1p-undefine93.4%
exp-to-pow93.8%
rem-exp-log98.9%
Simplified98.9%
clear-num98.9%
un-div-inv99.0%
Applied egg-rr99.0%
(FPCore (x) :precision binary64 (* (+ 0.5 (/ (+ (/ 0.0625 x) -0.125) x)) (/ (pow (+ 1.0 x) -0.5) x)))
double code(double x) {
return (0.5 + (((0.0625 / x) + -0.125) / x)) * (pow((1.0 + x), -0.5) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + (((0.0625d0 / x) + (-0.125d0)) / x)) * (((1.0d0 + x) ** (-0.5d0)) / x)
end function
public static double code(double x) {
return (0.5 + (((0.0625 / x) + -0.125) / x)) * (Math.pow((1.0 + x), -0.5) / x);
}
def code(x): return (0.5 + (((0.0625 / x) + -0.125) / x)) * (math.pow((1.0 + x), -0.5) / x)
function code(x) return Float64(Float64(0.5 + Float64(Float64(Float64(0.0625 / x) + -0.125) / x)) * Float64((Float64(1.0 + x) ^ -0.5) / x)) end
function tmp = code(x) tmp = (0.5 + (((0.0625 / x) + -0.125) / x)) * (((1.0 + x) ^ -0.5) / x); end
code[x_] := N[(N[(0.5 + N[(N[(N[(0.0625 / x), $MachinePrecision] + -0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 + \frac{\frac{0.0625}{x} + -0.125}{x}\right) \cdot \frac{{\left(1 + x\right)}^{-0.5}}{x}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
Taylor expanded in x around inf 98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
associate-*l/99.0%
associate-+r-99.0%
add-sqr-sqrt99.0%
pow299.0%
sqrt-div99.0%
metadata-eval99.0%
sqrt-pow199.0%
metadata-eval99.0%
pow199.0%
Applied egg-rr99.0%
associate-/l*99.0%
Simplified98.9%
(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 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
Taylor expanded in x around inf 98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification98.7%
(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 38.8%
frac-2neg38.8%
metadata-eval38.8%
div-inv38.8%
frac-2neg38.8%
metadata-eval38.8%
div-inv38.8%
distribute-neg-frac238.8%
prod-diff38.8%
distribute-neg-frac38.8%
metadata-eval38.8%
+-commutative38.8%
Applied egg-rr30.0%
+-commutative30.0%
fma-undefine30.0%
mul-1-neg30.0%
distribute-neg-out30.0%
unsub-neg30.0%
Simplified30.0%
Taylor expanded in x around inf 63.6%
*-commutative63.6%
Simplified63.6%
*-un-lft-identity63.6%
pow-flip64.0%
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 (/ (+ 0.5 (/ (+ (/ 0.0625 x) -0.125) x)) x))
double code(double x) {
return (0.5 + (((0.0625 / x) + -0.125) / x)) / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + (((0.0625d0 / x) + (-0.125d0)) / x)) / x
end function
public static double code(double x) {
return (0.5 + (((0.0625 / x) + -0.125) / x)) / x;
}
def code(x): return (0.5 + (((0.0625 / x) + -0.125) / x)) / x
function code(x) return Float64(Float64(0.5 + Float64(Float64(Float64(0.0625 / x) + -0.125) / x)) / x) end
function tmp = code(x) tmp = (0.5 + (((0.0625 / x) + -0.125) / x)) / x; end
code[x_] := N[(N[(0.5 + N[(N[(N[(0.0625 / x), $MachinePrecision] + -0.125), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{\frac{0.0625}{x} + -0.125}{x}}{x}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
Taylor expanded in x around inf 98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
*-commutative98.9%
add-exp-log93.4%
log-prod92.9%
log-pow92.9%
log1p-define92.9%
associate-+r-92.9%
add-sqr-sqrt92.9%
pow292.9%
sqrt-div92.9%
metadata-eval92.9%
sqrt-pow192.9%
metadata-eval92.9%
pow192.9%
Applied egg-rr92.9%
exp-sum93.4%
*-commutative93.4%
log1p-undefine93.4%
exp-to-pow93.8%
rem-exp-log98.9%
Simplified98.9%
Taylor expanded in x around 0 7.8%
Final simplification7.8%
(FPCore (x) :precision binary64 (/ 0.5 x))
double code(double x) {
return 0.5 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 / x
end function
public static double code(double x) {
return 0.5 / x;
}
def code(x): return 0.5 / x
function code(x) return Float64(0.5 / x) end
function tmp = code(x) tmp = 0.5 / x; end
code[x_] := N[(0.5 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{x}
\end{array}
Initial program 38.8%
frac-sub39.0%
div-inv39.0%
*-un-lft-identity39.0%
+-commutative39.0%
*-rgt-identity39.0%
metadata-eval39.0%
frac-times39.0%
associate-*l/39.0%
*-un-lft-identity39.0%
inv-pow39.0%
sqrt-pow239.0%
+-commutative39.0%
metadata-eval39.0%
Applied egg-rr39.0%
associate-*r/39.0%
*-rgt-identity39.0%
times-frac39.0%
div-sub38.9%
sub-neg38.9%
*-inverses38.9%
metadata-eval38.9%
/-rgt-identity38.9%
Simplified38.9%
Taylor expanded in x around inf 97.9%
Taylor expanded in x around 0 7.8%
(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 2024141
(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)))))