
(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 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 5e-16) (* 0.5 (pow x -1.5)) (- (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)))) <= 5e-16) {
tmp = 0.5 * pow(x, -1.5);
} 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)))) <= 5d-16) then
tmp = 0.5d0 * (x ** (-1.5d0))
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)))) <= 5e-16) {
tmp = 0.5 * Math.pow(x, -1.5);
} 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)))) <= 5e-16: tmp = 0.5 * math.pow(x, -1.5) 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)))) <= 5e-16) tmp = Float64(0.5 * (x ^ -1.5)); 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)))) <= 5e-16) tmp = 0.5 * (x ^ -1.5); 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], 5e-16], N[(0.5 * N[Power[x, -1.5], $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 5 \cdot 10^{-16}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\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)))) < 5.0000000000000004e-16Initial program 34.4%
frac-sub34.5%
div-inv34.5%
*-un-lft-identity34.5%
+-commutative34.5%
*-rgt-identity34.5%
metadata-eval34.5%
frac-times34.5%
un-div-inv34.5%
pow1/234.5%
pow-flip34.5%
metadata-eval34.5%
+-commutative34.5%
Applied egg-rr34.5%
associate-*r/34.5%
*-rgt-identity34.5%
times-frac34.5%
div-sub34.6%
*-inverses34.6%
/-rgt-identity34.6%
Simplified34.6%
Taylor expanded in x around inf 99.3%
expm1-log1p-u99.3%
expm1-udef33.9%
div-inv33.9%
associate-*l*33.9%
inv-pow33.9%
metadata-eval33.9%
pow-prod-up33.9%
pow333.9%
pow-pow33.9%
metadata-eval33.9%
Applied egg-rr33.9%
expm1-def99.7%
expm1-log1p99.7%
Simplified99.7%
if 5.0000000000000004e-16 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.4%
*-un-lft-identity99.4%
clear-num99.4%
associate-/r/99.4%
prod-diff99.4%
*-un-lft-identity99.4%
fma-neg99.4%
*-un-lft-identity99.4%
inv-pow99.4%
sqrt-pow299.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (/ 1.0 (* x (* (+ 1.0 x) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5))))))
double code(double x) {
return 1.0 / (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 * ((1.0d0 + x) * ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-0.5d0)))))
end function
public static double code(double x) {
return 1.0 / (x * ((1.0 + x) * (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5))));
}
def code(x): return 1.0 / (x * ((1.0 + x) * (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))))
function code(x) return Float64(1.0 / 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 * ((1.0 + x) * ((x ^ -0.5) + ((1.0 + x) ^ -0.5)))); end
code[x_] := N[(1.0 / 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}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}
\end{array}
Initial program 67.7%
flip--67.6%
clear-num67.5%
pow1/267.5%
pow-flip67.4%
metadata-eval67.4%
inv-pow67.4%
sqrt-pow267.4%
+-commutative67.4%
metadata-eval67.4%
frac-times59.6%
metadata-eval59.6%
add-sqr-sqrt60.0%
frac-times61.8%
metadata-eval61.8%
add-sqr-sqrt67.5%
Applied egg-rr67.5%
frac-sub68.4%
*-un-lft-identity68.4%
Applied egg-rr68.4%
*-rgt-identity68.4%
associate--l+91.3%
+-inverses91.3%
metadata-eval91.3%
Simplified91.3%
associate-/r/91.3%
/-rgt-identity91.3%
*-commutative91.3%
associate-*r*98.8%
+-commutative98.8%
+-commutative98.8%
Applied egg-rr98.8%
Final simplification98.8%
(FPCore (x) :precision binary64 (if (<= x 1.1) (- (pow x -0.5) (+ 1.0 (* x -0.5))) (* (pow x -0.5) (- (/ 0.5 x) (/ 0.375 (* x x))))))
double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = pow(x, -0.5) - (1.0 + (x * -0.5));
} else {
tmp = pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.1d0) then
tmp = (x ** (-0.5d0)) - (1.0d0 + (x * (-0.5d0)))
else
tmp = (x ** (-0.5d0)) * ((0.5d0 / x) - (0.375d0 / (x * x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = Math.pow(x, -0.5) - (1.0 + (x * -0.5));
} else {
tmp = Math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.1: tmp = math.pow(x, -0.5) - (1.0 + (x * -0.5)) else: tmp = math.pow(x, -0.5) * ((0.5 / x) - (0.375 / (x * x))) return tmp
function code(x) tmp = 0.0 if (x <= 1.1) tmp = Float64((x ^ -0.5) - Float64(1.0 + Float64(x * -0.5))); else tmp = Float64((x ^ -0.5) * Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.1) tmp = (x ^ -0.5) - (1.0 + (x * -0.5)); else tmp = (x ^ -0.5) * ((0.5 / x) - (0.375 / (x * x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.1], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\
\end{array}
\end{array}
if x < 1.1000000000000001Initial program 99.6%
Taylor expanded in x around 0 98.8%
add-log-exp4.4%
*-un-lft-identity4.4%
log-prod4.4%
metadata-eval4.4%
add-log-exp98.2%
pow1/298.2%
pow-flip98.5%
metadata-eval98.5%
Applied egg-rr99.2%
+-lft-identity98.5%
Simplified99.2%
if 1.1000000000000001 < x Initial program 36.2%
frac-sub36.1%
div-inv36.1%
*-un-lft-identity36.1%
+-commutative36.1%
*-rgt-identity36.1%
metadata-eval36.1%
frac-times36.1%
un-div-inv36.1%
pow1/236.1%
pow-flip36.1%
metadata-eval36.1%
+-commutative36.1%
Applied egg-rr36.1%
associate-*r/36.1%
*-rgt-identity36.1%
times-frac36.1%
div-sub36.2%
*-inverses36.2%
/-rgt-identity36.2%
Simplified36.2%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
metadata-eval97.9%
associate-*r/97.9%
metadata-eval97.9%
unpow297.9%
Simplified97.9%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 1.1) (- (pow x -0.5) (+ 1.0 (* x -0.5))) (/ (* (pow x -0.5) (+ 0.5 (/ -0.375 x))) x)))
double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = pow(x, -0.5) - (1.0 + (x * -0.5));
} else {
tmp = (pow(x, -0.5) * (0.5 + (-0.375 / x))) / x;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.1d0) then
tmp = (x ** (-0.5d0)) - (1.0d0 + (x * (-0.5d0)))
else
tmp = ((x ** (-0.5d0)) * (0.5d0 + ((-0.375d0) / x))) / x
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.1) {
tmp = Math.pow(x, -0.5) - (1.0 + (x * -0.5));
} else {
tmp = (Math.pow(x, -0.5) * (0.5 + (-0.375 / x))) / x;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.1: tmp = math.pow(x, -0.5) - (1.0 + (x * -0.5)) else: tmp = (math.pow(x, -0.5) * (0.5 + (-0.375 / x))) / x return tmp
function code(x) tmp = 0.0 if (x <= 1.1) tmp = Float64((x ^ -0.5) - Float64(1.0 + Float64(x * -0.5))); else tmp = Float64(Float64((x ^ -0.5) * Float64(0.5 + Float64(-0.375 / x))) / x); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.1) tmp = (x ^ -0.5) - (1.0 + (x * -0.5)); else tmp = ((x ^ -0.5) * (0.5 + (-0.375 / x))) / x; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.1], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, -0.5], $MachinePrecision] * N[(0.5 + N[(-0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5} \cdot \left(0.5 + \frac{-0.375}{x}\right)}{x}\\
\end{array}
\end{array}
if x < 1.1000000000000001Initial program 99.6%
Taylor expanded in x around 0 98.8%
add-log-exp4.4%
*-un-lft-identity4.4%
log-prod4.4%
metadata-eval4.4%
add-log-exp98.2%
pow1/298.2%
pow-flip98.5%
metadata-eval98.5%
Applied egg-rr99.2%
+-lft-identity98.5%
Simplified99.2%
if 1.1000000000000001 < x Initial program 36.2%
frac-sub36.1%
div-inv36.1%
*-un-lft-identity36.1%
+-commutative36.1%
*-rgt-identity36.1%
metadata-eval36.1%
frac-times36.1%
un-div-inv36.1%
pow1/236.1%
pow-flip36.1%
metadata-eval36.1%
+-commutative36.1%
Applied egg-rr36.1%
associate-*r/36.1%
*-rgt-identity36.1%
times-frac36.1%
div-sub36.2%
*-inverses36.2%
/-rgt-identity36.2%
Simplified36.2%
flip--36.2%
metadata-eval36.2%
sqrt-undiv36.3%
sqrt-undiv36.2%
add-sqr-sqrt36.4%
sqrt-undiv36.4%
Applied egg-rr36.4%
Taylor expanded in x around inf 97.9%
associate-*r/97.9%
metadata-eval97.9%
associate-*r/97.9%
metadata-eval97.9%
unpow297.9%
associate-/r*97.9%
Simplified97.9%
*-commutative97.9%
sub-div97.9%
associate-*r/97.9%
sub-neg97.9%
distribute-neg-frac97.9%
metadata-eval97.9%
Applied egg-rr97.9%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x 1.0) (- (pow x -0.5) (+ 1.0 (* x -0.5))) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = pow(x, -0.5) - (1.0 + (x * -0.5));
} else {
tmp = 0.5 * pow(x, -1.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)) - (1.0d0 + (x * (-0.5d0)))
else
tmp = 0.5d0 * (x ** (-1.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) - (1.0 + (x * -0.5));
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = math.pow(x, -0.5) - (1.0 + (x * -0.5)) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64((x ^ -0.5) - Float64(1.0 + Float64(x * -0.5))); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = (x ^ -0.5) - (1.0 + (x * -0.5)); else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 1Initial program 99.6%
Taylor expanded in x around 0 98.8%
add-log-exp4.4%
*-un-lft-identity4.4%
log-prod4.4%
metadata-eval4.4%
add-log-exp98.2%
pow1/298.2%
pow-flip98.5%
metadata-eval98.5%
Applied egg-rr99.2%
+-lft-identity98.5%
Simplified99.2%
if 1 < x Initial program 36.2%
frac-sub36.1%
div-inv36.1%
*-un-lft-identity36.1%
+-commutative36.1%
*-rgt-identity36.1%
metadata-eval36.1%
frac-times36.1%
un-div-inv36.1%
pow1/236.1%
pow-flip36.1%
metadata-eval36.1%
+-commutative36.1%
Applied egg-rr36.1%
associate-*r/36.1%
*-rgt-identity36.1%
times-frac36.1%
div-sub36.2%
*-inverses36.2%
/-rgt-identity36.2%
Simplified36.2%
Taylor expanded in x around inf 97.2%
expm1-log1p-u97.2%
expm1-udef33.8%
div-inv33.8%
associate-*l*33.8%
inv-pow33.8%
metadata-eval33.8%
pow-prod-up33.8%
pow333.8%
pow-pow33.8%
metadata-eval33.8%
Applied egg-rr33.8%
expm1-def97.6%
expm1-log1p97.6%
Simplified97.6%
Final simplification98.4%
(FPCore (x) :precision binary64 (if (<= x 0.5) (pow x -0.5) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = pow(x, -0.5);
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.5d0) then
tmp = x ** (-0.5d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.5) {
tmp = Math.pow(x, -0.5);
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.5: tmp = math.pow(x, -0.5) else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.5) tmp = x ^ -0.5; else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.5) tmp = x ^ -0.5; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.5], N[Power[x, -0.5], $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.5Initial program 99.6%
frac-sub99.6%
div-inv99.6%
*-un-lft-identity99.6%
+-commutative99.6%
*-rgt-identity99.6%
metadata-eval99.6%
frac-times99.6%
un-div-inv99.6%
pow1/299.6%
pow-flip100.0%
metadata-eval100.0%
+-commutative100.0%
Applied egg-rr100.0%
associate-*r/100.0%
*-rgt-identity100.0%
times-frac100.0%
div-sub100.0%
*-inverses100.0%
/-rgt-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 94.8%
if 0.5 < x Initial program 36.2%
frac-sub36.1%
div-inv36.1%
*-un-lft-identity36.1%
+-commutative36.1%
*-rgt-identity36.1%
metadata-eval36.1%
frac-times36.1%
un-div-inv36.1%
pow1/236.1%
pow-flip36.1%
metadata-eval36.1%
+-commutative36.1%
Applied egg-rr36.1%
associate-*r/36.1%
*-rgt-identity36.1%
times-frac36.1%
div-sub36.2%
*-inverses36.2%
/-rgt-identity36.2%
Simplified36.2%
Taylor expanded in x around inf 97.2%
expm1-log1p-u97.2%
expm1-udef33.8%
div-inv33.8%
associate-*l*33.8%
inv-pow33.8%
metadata-eval33.8%
pow-prod-up33.8%
pow333.8%
pow-pow33.8%
metadata-eval33.8%
Applied egg-rr33.8%
expm1-def97.6%
expm1-log1p97.6%
Simplified97.6%
Final simplification96.2%
(FPCore (x) :precision binary64 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.68d0) then
tmp = (x ** (-0.5d0)) + (-1.0d0)
else
tmp = 0.5d0 * (x ** (-1.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.68) {
tmp = Math.pow(x, -0.5) + -1.0;
} else {
tmp = 0.5 * Math.pow(x, -1.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.68: tmp = math.pow(x, -0.5) + -1.0 else: tmp = 0.5 * math.pow(x, -1.5) return tmp
function code(x) tmp = 0.0 if (x <= 0.68) tmp = Float64((x ^ -0.5) + -1.0); else tmp = Float64(0.5 * (x ^ -1.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.68) tmp = (x ^ -0.5) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.680000000000000049Initial program 99.6%
Taylor expanded in x around 0 98.2%
add-log-exp4.4%
*-un-lft-identity4.4%
log-prod4.4%
metadata-eval4.4%
add-log-exp98.2%
pow1/298.2%
pow-flip98.5%
metadata-eval98.5%
Applied egg-rr98.5%
+-lft-identity98.5%
Simplified98.5%
if 0.680000000000000049 < x Initial program 36.2%
frac-sub36.1%
div-inv36.1%
*-un-lft-identity36.1%
+-commutative36.1%
*-rgt-identity36.1%
metadata-eval36.1%
frac-times36.1%
un-div-inv36.1%
pow1/236.1%
pow-flip36.1%
metadata-eval36.1%
+-commutative36.1%
Applied egg-rr36.1%
associate-*r/36.1%
*-rgt-identity36.1%
times-frac36.1%
div-sub36.2%
*-inverses36.2%
/-rgt-identity36.2%
Simplified36.2%
Taylor expanded in x around inf 97.2%
expm1-log1p-u97.2%
expm1-udef33.8%
div-inv33.8%
associate-*l*33.8%
inv-pow33.8%
metadata-eval33.8%
pow-prod-up33.8%
pow333.8%
pow-pow33.8%
metadata-eval33.8%
Applied egg-rr33.8%
expm1-def97.6%
expm1-log1p97.6%
Simplified97.6%
Final simplification98.0%
(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 67.7%
frac-sub67.6%
div-inv67.6%
*-un-lft-identity67.6%
+-commutative67.6%
*-rgt-identity67.6%
metadata-eval67.6%
frac-times67.6%
un-div-inv67.6%
pow1/267.6%
pow-flip67.8%
metadata-eval67.8%
+-commutative67.8%
Applied egg-rr67.8%
associate-*r/67.8%
*-rgt-identity67.8%
times-frac67.8%
div-sub67.8%
*-inverses67.8%
/-rgt-identity67.8%
Simplified67.8%
Taylor expanded in x around inf 51.8%
expm1-log1p-u51.8%
expm1-udef19.9%
div-inv19.9%
associate-*l*19.9%
inv-pow19.9%
metadata-eval19.9%
pow-prod-up19.9%
pow319.9%
pow-pow19.9%
metadata-eval19.9%
Applied egg-rr19.9%
expm1-def52.0%
expm1-log1p52.0%
Simplified52.0%
Final simplification52.0%
(FPCore (x) :precision binary64 (* x 0.5))
double code(double x) {
return 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 x * 0.5;
}
def code(x): return x * 0.5
function code(x) return Float64(x * 0.5) end
function tmp = code(x) tmp = x * 0.5; end
code[x_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 67.7%
Taylor expanded in x around 0 50.8%
Taylor expanded in x around inf 4.0%
*-commutative4.0%
Simplified4.0%
Final simplification4.0%
(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 2023238
(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)))))