
(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 14 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) (fma (pow x -0.5) (+ 1.0 x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / x) / fma(pow(x, -0.5), (1.0 + x), sqrt((1.0 + x)));
}
function code(x) return Float64(Float64(1.0 / x) / fma((x ^ -0.5), Float64(1.0 + x), sqrt(Float64(1.0 + x)))) end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 + x), $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{\mathsf{fma}\left({x}^{-0.5}, 1 + x, \sqrt{1 + x}\right)}
\end{array}
Initial program 70.8%
add-log-exp56.5%
*-un-lft-identity56.5%
log-prod56.5%
metadata-eval56.5%
add-log-exp70.8%
inv-pow70.8%
sqrt-pow268.2%
+-commutative68.2%
metadata-eval68.2%
Applied egg-rr68.2%
+-lft-identity68.2%
Simplified68.2%
inv-pow68.2%
sqrt-pow271.1%
metadata-eval71.1%
metadata-eval71.1%
pow-pow56.3%
+-commutative56.3%
pow1/357.3%
flip--57.3%
Applied egg-rr72.2%
*-rgt-identity72.2%
*-rgt-identity72.2%
associate--l+91.1%
+-inverses91.1%
metadata-eval91.1%
metadata-eval91.1%
+-inverses91.1%
associate--l+72.2%
associate--l+91.1%
associate-*l*98.9%
Simplified98.9%
expm1-log1p-u95.4%
expm1-udef66.5%
Applied egg-rr66.5%
expm1-def95.4%
expm1-log1p98.9%
associate-/r*99.4%
fma-def99.4%
*-commutative99.4%
fma-def99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ 1.0 x)))) 1e-9) (/ (+ 1.0 (- x x)) (* x (+ (* (sqrt (/ 1.0 x)) 1.5) (* (sqrt x) 2.0)))) (- (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
double tmp;
if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 1e-9) {
tmp = (1.0 + (x - x)) / (x * ((sqrt((1.0 / x)) * 1.5) + (sqrt(x) * 2.0)));
} else {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((1.0d0 + x)))) <= 1d-9) then
tmp = (1.0d0 + (x - x)) / (x * ((sqrt((1.0d0 / x)) * 1.5d0) + (sqrt(x) * 2.0d0)))
else
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (((1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((1.0 + x)))) <= 1e-9) {
tmp = (1.0 + (x - x)) / (x * ((Math.sqrt((1.0 / x)) * 1.5) + (Math.sqrt(x) * 2.0)));
} else {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
}
return tmp;
}
def code(x): tmp = 0 if ((1.0 / math.sqrt(x)) - (1.0 / math.sqrt((1.0 + x)))) <= 1e-9: tmp = (1.0 + (x - x)) / (x * ((math.sqrt((1.0 / x)) * 1.5) + (math.sqrt(x) * 2.0))) else: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) return tmp
function code(x) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(1.0 + x)))) <= 1e-9) tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(Float64(sqrt(Float64(1.0 / x)) * 1.5) + Float64(sqrt(x) * 2.0)))); else tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 1e-9) tmp = (1.0 + (x - x)) / (x * ((sqrt((1.0 / x)) * 1.5) + (sqrt(x) * 2.0))); else tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-9], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 1.5), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-9}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{\frac{1}{x}} \cdot 1.5 + \sqrt{x} \cdot 2\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1.00000000000000006e-9Initial program 37.2%
add-log-exp6.2%
*-un-lft-identity6.2%
log-prod6.2%
metadata-eval6.2%
add-log-exp37.2%
inv-pow37.2%
sqrt-pow231.4%
+-commutative31.4%
metadata-eval31.4%
Applied egg-rr31.4%
+-lft-identity31.4%
Simplified31.4%
inv-pow31.4%
sqrt-pow237.4%
metadata-eval37.4%
metadata-eval37.4%
pow-pow5.2%
+-commutative5.2%
pow1/37.4%
flip--7.4%
Applied egg-rr40.6%
*-rgt-identity40.6%
*-rgt-identity40.6%
associate--l+81.6%
+-inverses81.6%
metadata-eval81.6%
metadata-eval81.6%
+-inverses81.6%
associate--l+40.6%
associate--l+81.6%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 98.5%
+-commutative98.5%
associate-+r+98.5%
distribute-rgt-out98.5%
metadata-eval98.5%
Simplified98.5%
if 1.00000000000000006e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow299.9%
metadata-eval99.9%
pow1/299.9%
pow-flip99.9%
+-commutative99.9%
metadata-eval99.9%
Applied egg-rr99.9%
fma-udef99.9%
distribute-lft1-in99.9%
metadata-eval99.9%
mul0-lft99.9%
+-rgt-identity99.9%
Simplified99.9%
Final simplification99.3%
(FPCore (x) :precision binary64 (/ (+ 1.0 (- x x)) (* x (* (+ 1.0 x) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))))
double code(double x) {
return (1.0 + (x - x)) / (x * ((1.0 + x) * (pow(x, -0.5) + pow((1.0 + x), -0.5))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 + (x - x)) / (x * ((1.0d0 + x) * ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))))
end function
public static double code(double x) {
return (1.0 + (x - x)) / (x * ((1.0 + x) * (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5))));
}
def code(x): return (1.0 + (x - x)) / (x * ((1.0 + x) * (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))))
function code(x) return Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(Float64(1.0 + x) * Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))))) end
function tmp = code(x) tmp = (1.0 + (x - x)) / (x * ((1.0 + x) * ((x ^ -0.5) + ((1.0 + x) ^ -0.5)))); end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(1.0 + x), $MachinePrecision] * N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \left(x - x\right)}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}
\end{array}
Initial program 70.8%
add-log-exp56.5%
*-un-lft-identity56.5%
log-prod56.5%
metadata-eval56.5%
add-log-exp70.8%
inv-pow70.8%
sqrt-pow268.2%
+-commutative68.2%
metadata-eval68.2%
Applied egg-rr68.2%
+-lft-identity68.2%
Simplified68.2%
inv-pow68.2%
sqrt-pow271.1%
metadata-eval71.1%
metadata-eval71.1%
pow-pow56.3%
+-commutative56.3%
pow1/357.3%
flip--57.3%
Applied egg-rr72.2%
*-rgt-identity72.2%
*-rgt-identity72.2%
associate--l+91.1%
+-inverses91.1%
metadata-eval91.1%
metadata-eval91.1%
+-inverses91.1%
associate--l+72.2%
associate--l+91.1%
associate-*l*98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (<= x 1e+16) (/ (/ (/ 1.0 x) (+ 1.0 x)) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))) (/ (+ 1.0 (- x x)) (* x (* (sqrt x) 2.0)))))
double code(double x) {
double tmp;
if (x <= 1e+16) {
tmp = ((1.0 / x) / (1.0 + x)) / (pow(x, -0.5) + pow((1.0 + x), -0.5));
} else {
tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d+16) then
tmp = ((1.0d0 / x) / (1.0d0 + x)) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))
else
tmp = (1.0d0 + (x - x)) / (x * (sqrt(x) * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e+16) {
tmp = ((1.0 / x) / (1.0 + x)) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
} else {
tmp = (1.0 + (x - x)) / (x * (Math.sqrt(x) * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e+16: tmp = ((1.0 / x) / (1.0 + x)) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5)) else: tmp = (1.0 + (x - x)) / (x * (math.sqrt(x) * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= 1e+16) tmp = Float64(Float64(Float64(1.0 / x) / Float64(1.0 + x)) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5))); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(sqrt(x) * 2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e+16) tmp = ((1.0 / x) / (1.0 + x)) / ((x ^ -0.5) + ((1.0 + x) ^ -0.5)); else tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e+16], N[(N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+16}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{1 + x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{x} \cdot 2\right)}\\
\end{array}
\end{array}
if x < 1e16Initial program 96.8%
flip--96.7%
div-inv96.6%
frac-times96.4%
metadata-eval96.4%
add-sqr-sqrt96.6%
frac-times96.6%
metadata-eval96.6%
add-sqr-sqrt96.8%
+-commutative96.8%
pow1/296.8%
pow-flip96.7%
metadata-eval96.7%
inv-pow96.7%
sqrt-pow296.7%
+-commutative96.7%
metadata-eval96.7%
Applied egg-rr96.7%
associate-*r/96.8%
*-rgt-identity96.8%
Simplified96.8%
frac-sub99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
*-rgt-identity99.3%
associate--l+99.3%
+-inverses99.3%
metadata-eval99.3%
associate-/r*99.3%
Simplified99.3%
if 1e16 < x Initial program 36.9%
add-log-exp5.1%
*-un-lft-identity5.1%
log-prod5.1%
metadata-eval5.1%
add-log-exp36.9%
inv-pow36.9%
sqrt-pow230.6%
+-commutative30.6%
metadata-eval30.6%
Applied egg-rr30.6%
+-lft-identity30.6%
Simplified30.6%
inv-pow30.6%
sqrt-pow236.9%
metadata-eval36.9%
metadata-eval36.9%
pow-pow3.3%
+-commutative3.3%
pow1/35.2%
flip--5.2%
Applied egg-rr36.9%
*-rgt-identity36.9%
*-rgt-identity36.9%
associate--l+80.5%
+-inverses80.5%
metadata-eval80.5%
metadata-eval80.5%
+-inverses80.5%
associate--l+36.9%
associate--l+80.5%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 98.7%
Final simplification99.0%
(FPCore (x) :precision binary64 (if (<= x 170000000.0) (- (pow x -0.5) (pow (+ 1.0 x) -0.5)) (/ (+ 1.0 (- x x)) (* x (* (sqrt x) 2.0)))))
double code(double x) {
double tmp;
if (x <= 170000000.0) {
tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
} else {
tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 170000000.0d0) then
tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
else
tmp = (1.0d0 + (x - x)) / (x * (sqrt(x) * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 170000000.0) {
tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
} else {
tmp = (1.0 + (x - x)) / (x * (Math.sqrt(x) * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 170000000.0: tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5) else: tmp = (1.0 + (x - x)) / (x * (math.sqrt(x) * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= 170000000.0) tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5)); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(sqrt(x) * 2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 170000000.0) tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5); else tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 170000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 170000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{x} \cdot 2\right)}\\
\end{array}
\end{array}
if x < 1.7e8Initial program 98.8%
*-un-lft-identity98.8%
clear-num98.8%
associate-/r/98.8%
prod-diff98.8%
*-un-lft-identity98.8%
fma-neg98.8%
*-un-lft-identity98.8%
inv-pow98.8%
sqrt-pow299.2%
metadata-eval99.2%
pow1/299.2%
pow-flip99.2%
+-commutative99.2%
metadata-eval99.2%
Applied egg-rr99.2%
fma-udef99.2%
distribute-lft1-in99.2%
metadata-eval99.2%
mul0-lft99.2%
+-rgt-identity99.2%
Simplified99.2%
if 1.7e8 < x Initial program 36.5%
add-log-exp5.2%
*-un-lft-identity5.2%
log-prod5.2%
metadata-eval5.2%
add-log-exp36.5%
inv-pow36.5%
sqrt-pow230.6%
+-commutative30.6%
metadata-eval30.6%
Applied egg-rr30.6%
+-lft-identity30.6%
Simplified30.6%
inv-pow30.6%
sqrt-pow236.7%
metadata-eval36.7%
metadata-eval36.7%
pow-pow3.8%
+-commutative3.8%
pow1/36.0%
flip--6.0%
Applied egg-rr39.0%
*-rgt-identity39.0%
*-rgt-identity39.0%
associate--l+81.1%
+-inverses81.1%
metadata-eval81.1%
metadata-eval81.1%
+-inverses81.1%
associate--l+39.0%
associate--l+81.1%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 98.3%
Final simplification98.8%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (+ 1.0 (- x x)) (* x (* (+ 1.0 x) (* (sqrt (/ 1.0 x)) 2.0))))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 + (x - x)) / (x * ((1.0 + x) * (sqrt((1.0 / x)) * 2.0)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 + (x - x)) / (x * ((1.0d0 + x) * (sqrt((1.0d0 / x)) * 2.0d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 + (x - x)) / (x * ((1.0 + x) * (Math.sqrt((1.0 / x)) * 2.0)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (1.0 + (x - x)) / (x * ((1.0 + x) * (math.sqrt((1.0 / x)) * 2.0))) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(Float64(1.0 + x) * Float64(sqrt(Float64(1.0 / x)) * 2.0)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (1.0 + (x - x)) / (x * ((1.0 + x) * (sqrt((1.0 / x)) * 2.0))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(1.0 + x), $MachinePrecision] * N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\left(1 + x\right) \cdot \left(\sqrt{\frac{1}{x}} \cdot 2\right)\right)}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
if 0.680000000000000049 < x Initial program 37.7%
add-log-exp7.0%
*-un-lft-identity7.0%
log-prod7.0%
metadata-eval7.0%
add-log-exp37.7%
inv-pow37.7%
sqrt-pow232.0%
+-commutative32.0%
metadata-eval32.0%
Applied egg-rr32.0%
+-lft-identity32.0%
Simplified32.0%
inv-pow32.0%
sqrt-pow237.9%
metadata-eval37.9%
metadata-eval37.9%
pow-pow6.0%
+-commutative6.0%
pow1/38.2%
flip--8.2%
Applied egg-rr41.1%
*-rgt-identity41.1%
*-rgt-identity41.1%
associate--l+81.7%
+-inverses81.7%
metadata-eval81.7%
metadata-eval81.7%
+-inverses81.7%
associate--l+41.1%
associate--l+81.7%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 96.7%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (+ 1.0 (- x x)) (* x (* (sqrt x) 2.0)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 + (x - x)) / (x * (sqrt(x) * 2.0d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 + (x - x)) / (x * (Math.sqrt(x) * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (1.0 + (x - x)) / (x * (math.sqrt(x) * 2.0)) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(sqrt(x) * 2.0))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 2.0)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{x} \cdot 2\right)}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
if 1 < x Initial program 37.7%
add-log-exp7.0%
*-un-lft-identity7.0%
log-prod7.0%
metadata-eval7.0%
add-log-exp37.7%
inv-pow37.7%
sqrt-pow232.0%
+-commutative32.0%
metadata-eval32.0%
Applied egg-rr32.0%
+-lft-identity32.0%
Simplified32.0%
inv-pow32.0%
sqrt-pow237.9%
metadata-eval37.9%
metadata-eval37.9%
pow-pow6.0%
+-commutative6.0%
pow1/38.2%
flip--8.2%
Applied egg-rr41.1%
*-rgt-identity41.1%
*-rgt-identity41.1%
associate--l+81.7%
+-inverses81.7%
metadata-eval81.7%
metadata-eval81.7%
+-inverses81.7%
associate--l+41.1%
associate--l+81.7%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around inf 96.6%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (/ (/ 1.0 (* x x)) (+ 1.0 (pow x -0.5)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / (x * x)) / (1.0 + pow(x, -0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (1.0d0 / (x * x)) / (1.0d0 + (x ** (-0.5d0)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = (1.0 / (x * x)) / (1.0 + Math.pow(x, -0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = (1.0 / (x * x)) / (1.0 + math.pow(x, -0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(Float64(1.0 / Float64(x * x)) / Float64(1.0 + (x ^ -0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (1.0 / (x * x)) / (1.0 + (x ^ -0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(1.0 / N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot x}}{1 + {x}^{-0.5}}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
if 1 < x Initial program 37.7%
flip--37.7%
div-inv37.7%
frac-times21.5%
metadata-eval21.5%
add-sqr-sqrt22.2%
frac-times27.1%
metadata-eval27.1%
add-sqr-sqrt38.0%
+-commutative38.0%
pow1/238.0%
pow-flip38.0%
metadata-eval38.0%
inv-pow38.0%
sqrt-pow238.0%
+-commutative38.0%
metadata-eval38.0%
Applied egg-rr38.0%
associate-*r/38.0%
*-rgt-identity38.0%
Simplified38.0%
Taylor expanded in x around 0 35.3%
Taylor expanded in x around inf 36.9%
unpow236.9%
Simplified36.9%
Final simplification69.8%
(FPCore (x) :precision binary64 (if (<= x 2.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (pow (* x x) -0.25)))
double code(double x) {
double tmp;
if (x <= 2.0) {
tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = pow((x * x), -0.25);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.0d0) then
tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
else
tmp = (x * x) ** (-0.25d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 2.0) {
tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
} else {
tmp = Math.pow((x * x), -0.25);
}
return tmp;
}
def code(x): tmp = 0 if x <= 2.0: tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0 else: tmp = math.pow((x * x), -0.25) return tmp
function code(x) tmp = 0.0 if (x <= 2.0) tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0); else tmp = Float64(x * x) ^ -0.25; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2.0) tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0; else tmp = (x * x) ^ -0.25; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[N[(x * x), $MachinePrecision], -0.25], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\end{array}
\end{array}
if x < 2Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 98.4%
if 2 < x Initial program 37.7%
*-un-lft-identity37.7%
clear-num37.7%
associate-/r/37.7%
prod-diff37.7%
*-un-lft-identity37.7%
fma-neg37.7%
*-un-lft-identity37.7%
inv-pow37.7%
sqrt-pow231.9%
metadata-eval31.9%
pow1/231.9%
pow-flip37.9%
+-commutative37.9%
metadata-eval37.9%
Applied egg-rr37.9%
fma-udef37.9%
distribute-lft1-in37.9%
metadata-eval37.9%
mul0-lft37.9%
+-rgt-identity37.9%
Simplified37.9%
add-cbrt-cube8.3%
rem-cube-cbrt8.2%
add-cbrt-cube8.2%
pow-pow8.2%
+-commutative8.2%
metadata-eval8.2%
Applied egg-rr8.2%
Taylor expanded in x around inf 5.7%
inv-pow5.7%
sqrt-pow15.7%
metadata-eval5.7%
metadata-eval5.7%
pow-pow36.1%
pow236.1%
Applied egg-rr36.1%
Final simplification69.4%
(FPCore (x) :precision binary64 (if (<= x 0.82) (+ (pow x -0.5) -1.0) (/ 1.0 x)))
double code(double x) {
double tmp;
if (x <= 0.82) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.82d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 1.0d0 / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.82) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 1.0 / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.82: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 1.0 / x return tmp
function code(x) tmp = 0.0 if (x <= 0.82) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(1.0 / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.82) tmp = (x ^ -0.5) + -1.0; else tmp = 1.0 / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.82], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(1.0 / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.82:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\
\end{array}
\end{array}
if x < 0.819999999999999951Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 97.9%
if 0.819999999999999951 < x Initial program 37.7%
flip--37.7%
div-inv37.7%
frac-times21.5%
metadata-eval21.5%
add-sqr-sqrt22.2%
frac-times27.1%
metadata-eval27.1%
add-sqr-sqrt38.0%
+-commutative38.0%
pow1/238.0%
pow-flip38.0%
metadata-eval38.0%
inv-pow38.0%
sqrt-pow238.0%
+-commutative38.0%
metadata-eval38.0%
Applied egg-rr38.0%
associate-*r/38.0%
*-rgt-identity38.0%
Simplified38.0%
Taylor expanded in x around 0 7.9%
*-commutative7.9%
+-commutative7.9%
distribute-lft-in7.9%
*-rgt-identity7.9%
Simplified7.9%
Taylor expanded in x around inf 7.9%
Final simplification56.1%
(FPCore (x) :precision binary64 (if (<= x 0.8) (+ (pow x -0.5) -1.0) (pow (* x x) -0.25)))
double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = pow((x * x), -0.25);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.8d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = (x * x) ** (-0.25d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.8) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = Math.pow((x * x), -0.25);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.8: tmp = math.pow(x, -0.5) + -1.0 else: tmp = math.pow((x * x), -0.25) return tmp
function code(x) tmp = 0.0 if (x <= 0.8) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(x * x) ^ -0.25; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.8) tmp = (x ^ -0.5) + -1.0; else tmp = (x * x) ^ -0.25; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.8], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[Power[N[(x * x), $MachinePrecision], -0.25], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.8:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\end{array}
\end{array}
if x < 0.80000000000000004Initial program 99.6%
*-un-lft-identity99.6%
clear-num99.6%
associate-/r/99.6%
prod-diff99.6%
*-un-lft-identity99.6%
fma-neg99.6%
*-un-lft-identity99.6%
inv-pow99.6%
sqrt-pow2100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 97.9%
if 0.80000000000000004 < x Initial program 37.7%
*-un-lft-identity37.7%
clear-num37.7%
associate-/r/37.7%
prod-diff37.7%
*-un-lft-identity37.7%
fma-neg37.7%
*-un-lft-identity37.7%
inv-pow37.7%
sqrt-pow231.9%
metadata-eval31.9%
pow1/231.9%
pow-flip37.9%
+-commutative37.9%
metadata-eval37.9%
Applied egg-rr37.9%
fma-udef37.9%
distribute-lft1-in37.9%
metadata-eval37.9%
mul0-lft37.9%
+-rgt-identity37.9%
Simplified37.9%
add-cbrt-cube8.3%
rem-cube-cbrt8.2%
add-cbrt-cube8.2%
pow-pow8.2%
+-commutative8.2%
metadata-eval8.2%
Applied egg-rr8.2%
Taylor expanded in x around inf 5.7%
inv-pow5.7%
sqrt-pow15.7%
metadata-eval5.7%
metadata-eval5.7%
pow-pow36.1%
pow236.1%
Applied egg-rr36.1%
Final simplification69.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 70.8%
*-un-lft-identity70.8%
clear-num70.8%
associate-/r/70.8%
prod-diff70.8%
*-un-lft-identity70.8%
fma-neg70.8%
*-un-lft-identity70.8%
inv-pow70.8%
sqrt-pow268.3%
metadata-eval68.3%
pow1/268.3%
pow-flip71.1%
+-commutative71.1%
metadata-eval71.1%
Applied egg-rr71.1%
fma-udef71.1%
distribute-lft1-in71.1%
metadata-eval71.1%
mul0-lft71.1%
+-rgt-identity71.1%
Simplified71.1%
add-cbrt-cube57.3%
rem-cube-cbrt57.3%
add-cbrt-cube57.3%
pow-pow57.3%
+-commutative57.3%
metadata-eval57.3%
Applied egg-rr57.3%
Taylor expanded in x around inf 53.3%
inv-pow53.3%
sqrt-pow153.4%
metadata-eval53.4%
*-un-lft-identity53.4%
Applied egg-rr53.4%
*-lft-identity53.4%
Simplified53.4%
Final simplification53.4%
(FPCore (x) :precision binary64 (/ 1.0 x))
double code(double x) {
return 1.0 / x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / x
end function
public static double code(double x) {
return 1.0 / x;
}
def code(x): return 1.0 / x
function code(x) return Float64(1.0 / x) end
function tmp = code(x) tmp = 1.0 / x; end
code[x_] := N[(1.0 / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x}
\end{array}
Initial program 70.8%
flip--70.8%
div-inv70.7%
frac-times63.1%
metadata-eval63.1%
add-sqr-sqrt63.5%
frac-times65.8%
metadata-eval65.8%
add-sqr-sqrt70.8%
+-commutative70.8%
pow1/270.8%
pow-flip70.8%
metadata-eval70.8%
inv-pow70.8%
sqrt-pow270.8%
+-commutative70.8%
metadata-eval70.8%
Applied egg-rr70.8%
associate-*r/70.8%
*-rgt-identity70.8%
Simplified70.8%
Taylor expanded in x around 0 55.1%
*-commutative55.1%
+-commutative55.1%
distribute-lft-in55.1%
*-rgt-identity55.1%
Simplified55.1%
Taylor expanded in x around inf 7.5%
Final simplification7.5%
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
return -1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -1.0d0
end function
public static double code(double x) {
return -1.0;
}
def code(x): return -1.0
function code(x) return -1.0 end
function tmp = code(x) tmp = -1.0; end
code[x_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 70.8%
Taylor expanded in x around 0 53.4%
Taylor expanded in x around inf 1.9%
Final simplification1.9%
(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 2023256
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))