
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x + 1} - \sqrt{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{x + 1} - \sqrt{x}
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) {
return 1.0 / (sqrt((1.0 + x)) + sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
end function
public static double code(double x) {
return 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
}
def code(x): return 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
function code(x) return Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x))) end
function tmp = code(x) tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x)); end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{1 + x} + \sqrt{x}}
\end{array}
Initial program 53.7%
flip--53.9%
div-inv53.9%
add-sqr-sqrt54.4%
add-sqr-sqrt54.4%
associate--l+54.4%
Applied egg-rr54.4%
+-commutative54.4%
associate-+l-99.7%
+-inverses99.7%
metadata-eval99.7%
associate-*r/99.7%
metadata-eval99.7%
+-commutative99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x) :precision binary64 (if (<= x 65000000.0) (- (sqrt (+ 1.0 x)) (pow x 0.5)) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = sqrt((1.0 + x)) - pow(x, 0.5);
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 65000000.0d0) then
tmp = sqrt((1.0d0 + x)) - (x ** 0.5d0)
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = Math.sqrt((1.0 + x)) - Math.pow(x, 0.5);
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 65000000.0: tmp = math.sqrt((1.0 + x)) - math.pow(x, 0.5) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 65000000.0) tmp = Float64(sqrt(Float64(1.0 + x)) - (x ^ 0.5)); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 65000000.0) tmp = sqrt((1.0 + x)) - (x ^ 0.5); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 65000000.0], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Power[x, 0.5], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 65000000:\\
\;\;\;\;\sqrt{1 + x} - {x}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 6.5e7Initial program 99.3%
expm1-log1p-u99.2%
Applied egg-rr99.2%
expm1-log1p-u99.3%
flip3--99.2%
add-cbrt-cube99.1%
rem-cube-cbrt99.2%
div-sub99.2%
Applied egg-rr99.3%
div-sub99.3%
associate-+l+99.4%
*-commutative99.4%
Simplified99.4%
metadata-eval99.4%
sqrt-pow299.2%
metadata-eval99.2%
sqrt-pow299.2%
add-sqr-sqrt99.3%
add-sqr-sqrt99.2%
sqrt-prod99.2%
*-commutative99.2%
flip3--99.3%
add-sqr-sqrt99.2%
cancel-sign-sub-inv99.2%
pow1/299.3%
sqrt-pow199.2%
metadata-eval99.2%
pow1/299.3%
sqrt-pow199.2%
metadata-eval99.2%
Applied egg-rr99.2%
distribute-lft-neg-out99.2%
unsub-neg99.2%
pow-sqr99.4%
metadata-eval99.4%
Simplified99.4%
if 6.5e7 < x Initial program 4.3%
expm1-log1p-u4.3%
Applied egg-rr4.3%
expm1-log1p-u4.3%
flip3--3.1%
add-cbrt-cube3.3%
rem-cube-cbrt2.9%
div-sub2.9%
Applied egg-rr3.1%
div-sub3.2%
associate-+l+3.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 99.6%
Final simplification99.5%
(FPCore (x) :precision binary64 (if (<= x 65000000.0) (- (sqrt (+ 1.0 x)) (sqrt x)) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = sqrt((1.0 + x)) - sqrt(x);
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 65000000.0d0) then
tmp = sqrt((1.0d0 + x)) - sqrt(x)
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 65000000.0) {
tmp = Math.sqrt((1.0 + x)) - Math.sqrt(x);
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 65000000.0: tmp = math.sqrt((1.0 + x)) - math.sqrt(x) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 65000000.0) tmp = Float64(sqrt(Float64(1.0 + x)) - sqrt(x)); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 65000000.0) tmp = sqrt((1.0 + x)) - sqrt(x); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 65000000.0], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 65000000:\\
\;\;\;\;\sqrt{1 + x} - \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 6.5e7Initial program 99.3%
if 6.5e7 < x Initial program 4.3%
expm1-log1p-u4.3%
Applied egg-rr4.3%
expm1-log1p-u4.3%
flip3--3.1%
add-cbrt-cube3.3%
rem-cube-cbrt2.9%
div-sub2.9%
Applied egg-rr3.1%
div-sub3.2%
associate-+l+3.2%
*-commutative3.2%
Simplified3.2%
Taylor expanded in x around inf 99.6%
Final simplification99.4%
(FPCore (x) :precision binary64 (if (<= x 1.22) (+ 1.0 (- (+ (* x (* x -0.125)) (* x 0.5)) (sqrt x))) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 1.22) {
tmp = 1.0 + (((x * (x * -0.125)) + (x * 0.5)) - sqrt(x));
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.22d0) then
tmp = 1.0d0 + (((x * (x * (-0.125d0))) + (x * 0.5d0)) - sqrt(x))
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.22) {
tmp = 1.0 + (((x * (x * -0.125)) + (x * 0.5)) - Math.sqrt(x));
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.22: tmp = 1.0 + (((x * (x * -0.125)) + (x * 0.5)) - math.sqrt(x)) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.22) tmp = Float64(1.0 + Float64(Float64(Float64(x * Float64(x * -0.125)) + Float64(x * 0.5)) - sqrt(x))); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.22) tmp = 1.0 + (((x * (x * -0.125)) + (x * 0.5)) - sqrt(x)); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.22], N[(1.0 + N[(N[(N[(x * N[(x * -0.125), $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.22:\\
\;\;\;\;1 + \left(\left(x \cdot \left(x \cdot -0.125\right) + x \cdot 0.5\right) - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 1.21999999999999997Initial program 99.9%
Taylor expanded in x around 0 99.3%
+-commutative99.3%
unpow299.3%
associate-*r*99.3%
distribute-rgt-out99.3%
*-commutative99.3%
Simplified99.3%
associate--l+99.3%
+-commutative99.3%
+-commutative99.3%
fma-def99.3%
Applied egg-rr99.3%
fma-udef99.3%
distribute-rgt-in99.3%
*-commutative99.3%
Applied egg-rr99.3%
if 1.21999999999999997 < x Initial program 7.4%
expm1-log1p-u7.4%
Applied egg-rr7.4%
expm1-log1p-u7.4%
flip3--6.3%
add-cbrt-cube6.4%
rem-cube-cbrt6.1%
div-sub6.1%
Applied egg-rr6.3%
div-sub6.4%
associate-+l+6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in x around inf 97.1%
Final simplification98.2%
(FPCore (x) :precision binary64 (if (<= x 1.22) (- (+ 1.0 (* x (+ 0.5 (* x -0.125)))) (sqrt x)) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 1.22) {
tmp = (1.0 + (x * (0.5 + (x * -0.125)))) - sqrt(x);
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.22d0) then
tmp = (1.0d0 + (x * (0.5d0 + (x * (-0.125d0))))) - sqrt(x)
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.22) {
tmp = (1.0 + (x * (0.5 + (x * -0.125)))) - Math.sqrt(x);
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.22: tmp = (1.0 + (x * (0.5 + (x * -0.125)))) - math.sqrt(x) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.22) tmp = Float64(Float64(1.0 + Float64(x * Float64(0.5 + Float64(x * -0.125)))) - sqrt(x)); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.22) tmp = (1.0 + (x * (0.5 + (x * -0.125)))) - sqrt(x); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.22], N[(N[(1.0 + N[(x * N[(0.5 + N[(x * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.22:\\
\;\;\;\;\left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right) - \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 1.21999999999999997Initial program 99.9%
Taylor expanded in x around 0 99.3%
+-commutative99.3%
unpow299.3%
associate-*r*99.3%
distribute-rgt-out99.3%
*-commutative99.3%
Simplified99.3%
if 1.21999999999999997 < x Initial program 7.4%
expm1-log1p-u7.4%
Applied egg-rr7.4%
expm1-log1p-u7.4%
flip3--6.3%
add-cbrt-cube6.4%
rem-cube-cbrt6.1%
div-sub6.1%
Applied egg-rr6.3%
div-sub6.4%
associate-+l+6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in x around inf 97.1%
Final simplification98.2%
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ 1.0 (- (* x 0.5) (sqrt x))) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 + ((x * 0.5) - sqrt(x));
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 1.0d0 + ((x * 0.5d0) - sqrt(x))
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 + ((x * 0.5) - Math.sqrt(x));
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = 1.0 + ((x * 0.5) - math.sqrt(x)) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 + Float64(Float64(x * 0.5) - sqrt(x))); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = 1.0 + ((x * 0.5) - sqrt(x)); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(1.0 + N[(N[(x * 0.5), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 + \left(x \cdot 0.5 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 1Initial program 99.9%
Taylor expanded in x around 0 98.9%
associate--l+98.9%
+-commutative98.9%
*-commutative98.9%
Applied egg-rr98.9%
if 1 < x Initial program 7.4%
expm1-log1p-u7.4%
Applied egg-rr7.4%
expm1-log1p-u7.4%
flip3--6.3%
add-cbrt-cube6.4%
rem-cube-cbrt6.1%
div-sub6.1%
Applied egg-rr6.3%
div-sub6.4%
associate-+l+6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in x around inf 97.1%
Final simplification98.0%
(FPCore (x) :precision binary64 (if (<= x 0.25) 1.0 (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 0.25) {
tmp = 1.0;
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 0.25d0) then
tmp = 1.0d0
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 0.25) {
tmp = 1.0;
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 0.25: tmp = 1.0 else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 0.25) tmp = 1.0; else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 0.25) tmp = 1.0; else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 0.25], 1.0, N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.25:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 0.25Initial program 99.9%
Taylor expanded in x around 0 95.4%
if 0.25 < x Initial program 8.1%
expm1-log1p-u8.1%
Applied egg-rr8.1%
expm1-log1p-u8.1%
flip3--7.0%
add-cbrt-cube7.1%
rem-cube-cbrt6.8%
div-sub6.8%
Applied egg-rr7.0%
div-sub7.1%
associate-+l+7.1%
*-commutative7.1%
Simplified7.1%
Taylor expanded in x around inf 96.6%
Final simplification96.0%
(FPCore (x) :precision binary64 (if (<= x 1.0) (/ 1.0 (+ 1.0 (sqrt x))) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 / (1.0 + sqrt(x));
} else {
tmp = 0.5 * sqrt((1.0 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 1.0d0 / (1.0d0 + sqrt(x))
else
tmp = 0.5d0 * sqrt((1.0d0 / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 1.0 / (1.0 + Math.sqrt(x));
} else {
tmp = 0.5 * Math.sqrt((1.0 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = 1.0 / (1.0 + math.sqrt(x)) else: tmp = 0.5 * math.sqrt((1.0 / x)) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 / Float64(1.0 + sqrt(x))); else tmp = Float64(0.5 * sqrt(Float64(1.0 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = 1.0 / (1.0 + sqrt(x)); else tmp = 0.5 * sqrt((1.0 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], N[(1.0 / N[(1.0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{1}{1 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\
\end{array}
\end{array}
if x < 1Initial program 99.9%
flip--99.9%
div-inv99.9%
add-sqr-sqrt99.8%
add-sqr-sqrt99.9%
associate--l+99.9%
Applied egg-rr99.9%
+-commutative99.9%
associate-+l-99.9%
+-inverses99.9%
metadata-eval99.9%
associate-*r/99.9%
metadata-eval99.9%
+-commutative99.9%
Simplified99.9%
add-sqr-sqrt99.8%
pow299.8%
pow1/299.8%
sqrt-pow199.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 97.2%
if 1 < x Initial program 7.4%
expm1-log1p-u7.4%
Applied egg-rr7.4%
expm1-log1p-u7.4%
flip3--6.3%
add-cbrt-cube6.4%
rem-cube-cbrt6.1%
div-sub6.1%
Applied egg-rr6.3%
div-sub6.4%
associate-+l+6.4%
*-commutative6.4%
Simplified6.4%
Taylor expanded in x around inf 97.1%
Final simplification97.2%
(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 53.7%
Taylor expanded in x around 0 50.9%
Final simplification50.9%
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))))
double code(double x) {
return 1.0 / (sqrt((x + 1.0)) + sqrt(x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))
end function
public static double code(double x) {
return 1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
def code(x): return 1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))
function code(x) return Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) end
function tmp = code(x) tmp = 1.0 / (sqrt((x + 1.0)) + sqrt(x)); end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\sqrt{x + 1} + \sqrt{x}}
\end{array}
herbie shell --seed 2023305
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:herbie-target
(/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))
(- (sqrt (+ x 1.0)) (sqrt x)))