
(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 8 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 (sqrt (+ 1.0 x))))
(if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
(* 0.5 (pow x -1.5))
(/ (/ (+ x (- 1.0 x)) (+ (sqrt x) t_0)) (sqrt (* x (+ 1.0 x)))))))
double code(double x) {
double t_0 = sqrt((1.0 + x));
double tmp;
if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = 0.5 * pow(x, -1.5);
} else {
tmp = ((x + (1.0 - x)) / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 + x))
if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
tmp = 0.5d0 * (x ** (-1.5d0))
else
tmp = ((x + (1.0d0 - x)) / (sqrt(x) + t_0)) / sqrt((x * (1.0d0 + x)))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.sqrt((1.0 + x));
double tmp;
if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
tmp = 0.5 * Math.pow(x, -1.5);
} else {
tmp = ((x + (1.0 - x)) / (Math.sqrt(x) + t_0)) / Math.sqrt((x * (1.0 + x)));
}
return tmp;
}
def code(x): t_0 = math.sqrt((1.0 + x)) tmp = 0 if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0: tmp = 0.5 * math.pow(x, -1.5) else: tmp = ((x + (1.0 - x)) / (math.sqrt(x) + t_0)) / math.sqrt((x * (1.0 + x))) return tmp
function code(x) t_0 = sqrt(Float64(1.0 + x)) tmp = 0.0 if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 0.0) tmp = Float64(0.5 * (x ^ -1.5)); else tmp = Float64(Float64(Float64(x + Float64(1.0 - x)) / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(1.0 + x)))); end return tmp end
function tmp_2 = code(x) t_0 = sqrt((1.0 + x)); tmp = 0.0; if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) tmp = 0.5 * (x ^ -1.5); else tmp = ((x + (1.0 - x)) / (sqrt(x) + t_0)) / sqrt((x * (1.0 + x))); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + \left(1 - x\right)}{\sqrt{x} + t_0}}{\sqrt{x \cdot \left(1 + x\right)}}\\
\end{array}
\end{array}
if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0Initial program 38.2%
flip--38.2%
frac-times24.3%
metadata-eval24.3%
add-sqr-sqrt21.0%
frac-times21.3%
metadata-eval21.3%
add-sqr-sqrt38.2%
+-commutative38.2%
pow1/238.2%
pow-flip38.2%
metadata-eval38.2%
inv-pow38.2%
sqrt-pow238.2%
+-commutative38.2%
metadata-eval38.2%
Applied egg-rr38.2%
Taylor expanded in x around inf 69.8%
exp-to-pow67.1%
*-commutative67.1%
exp-neg67.6%
distribute-lft-neg-in67.6%
metadata-eval67.6%
*-commutative67.6%
exp-to-pow70.4%
metadata-eval70.4%
pow-sqr70.5%
rem-sqrt-square100.0%
rem-square-sqrt99.5%
fabs-sqr99.5%
rem-square-sqrt100.0%
Simplified100.0%
if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 98.2%
frac-sub98.2%
*-un-lft-identity98.2%
*-rgt-identity98.2%
+-commutative98.2%
sqrt-unprod98.2%
+-commutative98.2%
Applied egg-rr98.2%
flip--98.5%
add-sqr-sqrt99.0%
+-commutative99.0%
add-sqr-sqrt99.5%
associate--l+99.5%
+-commutative99.5%
add-sqr-sqrt99.5%
hypot-1-def99.5%
Applied egg-rr99.5%
expm1-log1p-u99.5%
expm1-udef98.9%
hypot-udef98.9%
metadata-eval98.9%
add-sqr-sqrt98.9%
+-commutative98.9%
Applied egg-rr98.9%
expm1-def99.5%
expm1-log1p99.5%
+-commutative99.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 5e-18) (* 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-18) {
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-18) 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-18) {
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-18: 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-18) 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-18) 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-18], 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^{-18}:\\
\;\;\;\;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.00000000000000036e-18Initial program 38.1%
flip--38.1%
frac-times24.5%
metadata-eval24.5%
add-sqr-sqrt21.2%
frac-times21.5%
metadata-eval21.5%
add-sqr-sqrt38.1%
+-commutative38.1%
pow1/238.1%
pow-flip38.1%
metadata-eval38.1%
inv-pow38.1%
sqrt-pow238.1%
+-commutative38.1%
metadata-eval38.1%
Applied egg-rr38.1%
Taylor expanded in x around inf 70.1%
exp-to-pow67.3%
*-commutative67.3%
exp-neg67.9%
distribute-lft-neg-in67.9%
metadata-eval67.9%
*-commutative67.9%
exp-to-pow70.7%
metadata-eval70.7%
pow-sqr70.8%
rem-sqrt-square99.8%
rem-square-sqrt99.3%
fabs-sqr99.3%
rem-square-sqrt99.8%
Simplified99.8%
if 5.00000000000000036e-18 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) Initial program 99.2%
*-un-lft-identity99.2%
clear-num99.2%
associate-/r/99.2%
prod-diff99.2%
*-un-lft-identity99.2%
fma-neg99.2%
*-un-lft-identity99.2%
pow1/299.2%
pow-flip99.7%
metadata-eval99.7%
pow1/299.7%
pow-flip99.7%
+-commutative99.7%
metadata-eval99.7%
Applied egg-rr99.7%
+-commutative99.7%
sub-neg99.7%
fma-udef99.7%
distribute-lft1-in99.7%
metadata-eval99.7%
mul0-lft99.7%
+-commutative99.7%
associate-+r+99.7%
sub-neg99.7%
neg-sub099.7%
+-commutative99.7%
sub-neg99.7%
Simplified99.7%
Final simplification99.7%
(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.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if 1 < x Initial program 38.7%
flip--38.7%
frac-times25.3%
metadata-eval25.3%
add-sqr-sqrt22.1%
frac-times22.3%
metadata-eval22.3%
add-sqr-sqrt38.7%
+-commutative38.7%
pow1/238.7%
pow-flip38.7%
metadata-eval38.7%
inv-pow38.7%
sqrt-pow238.7%
+-commutative38.7%
metadata-eval38.7%
Applied egg-rr38.7%
Taylor expanded in x around inf 69.7%
exp-to-pow67.0%
*-commutative67.0%
exp-neg67.5%
distribute-lft-neg-in67.5%
metadata-eval67.5%
*-commutative67.5%
exp-to-pow70.2%
metadata-eval70.2%
pow-sqr70.3%
rem-sqrt-square98.9%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification99.5%
(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.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Applied egg-rr98.0%
Taylor expanded in x around inf 96.7%
inv-pow96.7%
sqrt-pow197.0%
metadata-eval97.0%
expm1-log1p-u89.9%
expm1-udef89.9%
Applied egg-rr89.9%
expm1-def89.9%
expm1-log1p97.0%
Simplified97.0%
if 0.5 < x Initial program 38.7%
flip--38.7%
frac-times25.3%
metadata-eval25.3%
add-sqr-sqrt22.1%
frac-times22.3%
metadata-eval22.3%
add-sqr-sqrt38.7%
+-commutative38.7%
pow1/238.7%
pow-flip38.7%
metadata-eval38.7%
inv-pow38.7%
sqrt-pow238.7%
+-commutative38.7%
metadata-eval38.7%
Applied egg-rr38.7%
Taylor expanded in x around inf 69.7%
exp-to-pow67.0%
*-commutative67.0%
exp-neg67.5%
distribute-lft-neg-in67.5%
metadata-eval67.5%
*-commutative67.5%
exp-to-pow70.2%
metadata-eval70.2%
pow-sqr70.3%
rem-sqrt-square98.9%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification97.9%
(FPCore (x) :precision binary64 (if (<= x 0.65) (+ (pow x -0.5) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
double tmp;
if (x <= 0.65) {
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.65d0) 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.65) {
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.65: 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.65) 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.65) tmp = (x ^ -0.5) + -1.0; else tmp = 0.5 * (x ^ -1.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.65], 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.65:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\end{array}
if x < 0.650000000000000022Initial program 99.5%
*-un-lft-identity99.5%
clear-num99.5%
associate-/r/99.5%
prod-diff99.5%
*-un-lft-identity99.5%
fma-neg99.5%
*-un-lft-identity99.5%
pow1/299.5%
pow-flip100.0%
metadata-eval100.0%
pow1/2100.0%
pow-flip100.0%
+-commutative100.0%
metadata-eval100.0%
Applied egg-rr100.0%
+-commutative100.0%
sub-neg100.0%
fma-udef100.0%
distribute-lft1-in100.0%
metadata-eval100.0%
mul0-lft100.0%
+-commutative100.0%
associate-+r+100.0%
sub-neg100.0%
neg-sub0100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 99.7%
if 0.650000000000000022 < x Initial program 38.7%
flip--38.7%
frac-times25.3%
metadata-eval25.3%
add-sqr-sqrt22.1%
frac-times22.3%
metadata-eval22.3%
add-sqr-sqrt38.7%
+-commutative38.7%
pow1/238.7%
pow-flip38.7%
metadata-eval38.7%
inv-pow38.7%
sqrt-pow238.7%
+-commutative38.7%
metadata-eval38.7%
Applied egg-rr38.7%
Taylor expanded in x around inf 69.7%
exp-to-pow67.0%
*-commutative67.0%
exp-neg67.5%
distribute-lft-neg-in67.5%
metadata-eval67.5%
*-commutative67.5%
exp-to-pow70.2%
metadata-eval70.2%
pow-sqr70.3%
rem-sqrt-square98.9%
rem-square-sqrt98.4%
fabs-sqr98.4%
rem-square-sqrt98.9%
Simplified98.9%
Final simplification99.3%
(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 69.8%
*-un-lft-identity69.8%
clear-num69.8%
associate-/r/69.8%
prod-diff69.8%
*-un-lft-identity69.8%
fma-neg69.8%
*-un-lft-identity69.8%
pow1/269.8%
pow-flip65.8%
metadata-eval65.8%
pow1/265.8%
pow-flip70.1%
+-commutative70.1%
metadata-eval70.1%
Applied egg-rr70.1%
+-commutative70.1%
sub-neg70.1%
fma-udef70.1%
distribute-lft1-in70.1%
metadata-eval70.1%
mul0-lft70.1%
+-commutative70.1%
associate-+r+70.1%
sub-neg70.1%
neg-sub070.1%
+-commutative70.1%
sub-neg70.1%
Simplified70.1%
Applied egg-rr52.9%
Taylor expanded in x around inf 52.2%
inv-pow52.2%
sqrt-pow152.4%
metadata-eval52.4%
expm1-log1p-u48.7%
expm1-udef64.4%
Applied egg-rr64.4%
expm1-def48.7%
expm1-log1p52.4%
Simplified52.4%
Final simplification52.4%
(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 69.8%
*-un-lft-identity69.8%
clear-num69.8%
associate-/r/69.8%
prod-diff69.8%
*-un-lft-identity69.8%
fma-neg69.8%
*-un-lft-identity69.8%
pow1/269.8%
pow-flip65.8%
metadata-eval65.8%
pow1/265.8%
pow-flip70.1%
+-commutative70.1%
metadata-eval70.1%
Applied egg-rr70.1%
+-commutative70.1%
sub-neg70.1%
fma-udef70.1%
distribute-lft1-in70.1%
metadata-eval70.1%
mul0-lft70.1%
+-commutative70.1%
associate-+r+70.1%
sub-neg70.1%
neg-sub070.1%
+-commutative70.1%
sub-neg70.1%
Simplified70.1%
Taylor expanded in x around 0 52.8%
Taylor expanded in x around inf 3.8%
*-commutative3.8%
Simplified3.8%
Final simplification3.8%
(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 69.8%
add-cube-cbrt55.4%
associate-*l*55.4%
frac-2neg55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
distribute-neg-frac55.4%
metadata-eval55.4%
frac-2neg55.4%
prod-diff52.8%
Applied egg-rr53.2%
fma-udef57.3%
distribute-rgt-neg-in57.3%
metadata-eval57.3%
*-rgt-identity57.3%
fma-udef57.3%
distribute-lft-neg-in57.3%
neg-mul-157.3%
distribute-lft1-in57.3%
metadata-eval57.3%
mul0-lft57.3%
associate-+r+57.3%
+-rgt-identity57.3%
Simplified53.2%
Taylor expanded in x around 0 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 2023306
(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)))))