
(FPCore (x) :precision binary64 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x): return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x))))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x): return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x))))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (/ 0.5 (hypot 1.0 x)))) (/ (- 0.5 t_0) (+ 1.0 (cbrt (pow (+ 0.5 t_0) 1.5))))))
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
return (0.5 - t_0) / (1.0 + cbrt(pow((0.5 + t_0), 1.5)));
}
public static double code(double x) {
double t_0 = 0.5 / Math.hypot(1.0, x);
return (0.5 - t_0) / (1.0 + Math.cbrt(Math.pow((0.5 + t_0), 1.5)));
}
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) return Float64(Float64(0.5 - t_0) / Float64(1.0 + cbrt((Float64(0.5 + t_0) ^ 1.5)))) end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(N[(0.5 - t$95$0), $MachinePrecision] / N[(1.0 + N[Power[N[Power[N[(0.5 + t$95$0), $MachinePrecision], 1.5], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{0.5 - t\_0}{1 + \sqrt[3]{{\left(0.5 + t\_0\right)}^{1.5}}}
\end{array}
\end{array}
Initial program 99.1%
distribute-lft-in99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
flip--99.1%
metadata-eval99.1%
add-sqr-sqrt99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
add-cbrt-cube99.9%
pow399.9%
sqrt-pow299.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 0.5 (hypot 1.0 x)))) (/ 1.0 (/ (+ 1.0 (sqrt (+ 0.5 t_0))) (- 0.5 t_0)))))
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
return 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0));
}
public static double code(double x) {
double t_0 = 0.5 / Math.hypot(1.0, x);
return 1.0 / ((1.0 + Math.sqrt((0.5 + t_0))) / (0.5 - t_0));
}
def code(x): t_0 = 0.5 / math.hypot(1.0, x) return 1.0 / ((1.0 + math.sqrt((0.5 + t_0))) / (0.5 - t_0))
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) return Float64(1.0 / Float64(Float64(1.0 + sqrt(Float64(0.5 + t_0))) / Float64(0.5 - t_0))) end
function tmp = code(x) t_0 = 0.5 / hypot(1.0, x); tmp = 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0)); end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(N[(1.0 + N[Sqrt[N[(0.5 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{1}{\frac{1 + \sqrt{0.5 + t\_0}}{0.5 - t\_0}}
\end{array}
\end{array}
Initial program 99.1%
distribute-lft-in99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
flip--99.1%
div-inv99.1%
metadata-eval99.1%
add-sqr-sqrt99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 0.5 (hypot 1.0 x)))) (/ (- 0.5 t_0) (+ 1.0 (sqrt (+ 0.5 t_0))))))
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
return (0.5 - t_0) / (1.0 + sqrt((0.5 + t_0)));
}
public static double code(double x) {
double t_0 = 0.5 / Math.hypot(1.0, x);
return (0.5 - t_0) / (1.0 + Math.sqrt((0.5 + t_0)));
}
def code(x): t_0 = 0.5 / math.hypot(1.0, x) return (0.5 - t_0) / (1.0 + math.sqrt((0.5 + t_0)))
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) return Float64(Float64(0.5 - t_0) / Float64(1.0 + sqrt(Float64(0.5 + t_0)))) end
function tmp = code(x) t_0 = 0.5 / hypot(1.0, x); tmp = (0.5 - t_0) / (1.0 + sqrt((0.5 + t_0))); end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(N[(0.5 - t$95$0), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{0.5 - t\_0}{1 + \sqrt{0.5 + t\_0}}
\end{array}
\end{array}
Initial program 99.1%
distribute-lft-in99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
flip--99.1%
metadata-eval99.1%
add-sqr-sqrt99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (- 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x))))))
double code(double x) {
return 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x))));
}
def code(x): return 1.0 - math.sqrt((0.5 + (0.5 / math.hypot(1.0, x))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x)))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}
\end{array}
Initial program 99.1%
distribute-lft-in99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x 1.2) (+ 1.0 (- -1.0 (* (pow x 2.0) -0.125))) (/ (- 0.5 (/ 0.5 x)) (+ 1.0 (sqrt 0.5)))))
double code(double x) {
double tmp;
if (x <= 1.2) {
tmp = 1.0 + (-1.0 - (pow(x, 2.0) * -0.125));
} else {
tmp = (0.5 - (0.5 / x)) / (1.0 + sqrt(0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.2d0) then
tmp = 1.0d0 + ((-1.0d0) - ((x ** 2.0d0) * (-0.125d0)))
else
tmp = (0.5d0 - (0.5d0 / x)) / (1.0d0 + sqrt(0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.2) {
tmp = 1.0 + (-1.0 - (Math.pow(x, 2.0) * -0.125));
} else {
tmp = (0.5 - (0.5 / x)) / (1.0 + Math.sqrt(0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.2: tmp = 1.0 + (-1.0 - (math.pow(x, 2.0) * -0.125)) else: tmp = (0.5 - (0.5 / x)) / (1.0 + math.sqrt(0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 1.2) tmp = Float64(1.0 + Float64(-1.0 - Float64((x ^ 2.0) * -0.125))); else tmp = Float64(Float64(0.5 - Float64(0.5 / x)) / Float64(1.0 + sqrt(0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.2) tmp = 1.0 + (-1.0 - ((x ^ 2.0) * -0.125)); else tmp = (0.5 - (0.5 / x)) / (1.0 + sqrt(0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.2], N[(1.0 + N[(-1.0 - N[(N[Power[x, 2.0], $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2:\\
\;\;\;\;1 + \left(-1 - {x}^{2} \cdot -0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{0.5}{x}}{1 + \sqrt{0.5}}\\
\end{array}
\end{array}
if x < 1.19999999999999996Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 66.0%
*-commutative66.0%
Simplified66.0%
if 1.19999999999999996 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.4%
metadata-eval98.4%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around inf 98.3%
Final simplification74.5%
(FPCore (x) :precision binary64 (if (<= x 1.55) (+ 1.0 (- -1.0 (* (pow x 2.0) -0.125))) (/ 0.5 (+ 1.0 (sqrt 0.5)))))
double code(double x) {
double tmp;
if (x <= 1.55) {
tmp = 1.0 + (-1.0 - (pow(x, 2.0) * -0.125));
} else {
tmp = 0.5 / (1.0 + sqrt(0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.55d0) then
tmp = 1.0d0 + ((-1.0d0) - ((x ** 2.0d0) * (-0.125d0)))
else
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.55) {
tmp = 1.0 + (-1.0 - (Math.pow(x, 2.0) * -0.125));
} else {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.55: tmp = 1.0 + (-1.0 - (math.pow(x, 2.0) * -0.125)) else: tmp = 0.5 / (1.0 + math.sqrt(0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 1.55) tmp = Float64(1.0 + Float64(-1.0 - Float64((x ^ 2.0) * -0.125))); else tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.55) tmp = 1.0 + (-1.0 - ((x ^ 2.0) * -0.125)); else tmp = 0.5 / (1.0 + sqrt(0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.55], N[(1.0 + N[(-1.0 - N[(N[Power[x, 2.0], $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55:\\
\;\;\;\;1 + \left(-1 - {x}^{2} \cdot -0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\end{array}
\end{array}
if x < 1.55000000000000004Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 66.0%
*-commutative66.0%
Simplified66.0%
if 1.55000000000000004 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.4%
div-inv98.4%
metadata-eval98.4%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
Final simplification74.4%
(FPCore (x) :precision binary64 (if (<= x 1e-11) 0.0 (/ 0.5 (+ 1.0 (sqrt 0.5)))))
double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 0.5 / (1.0 + sqrt(0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d-11) then
tmp = 0.0d0
else
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-11: tmp = 0.0 else: tmp = 0.5 / (1.0 + math.sqrt(0.5)) return tmp
function code(x) tmp = 0.0 if (x <= 1e-11) tmp = 0.0; else tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-11) tmp = 0.0; else tmp = 0.5 / (1.0 + sqrt(0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-11], 0.0, N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-11}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\end{array}
\end{array}
if x < 9.99999999999999939e-12Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 65.1%
if 9.99999999999999939e-12 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.4%
div-inv98.4%
metadata-eval98.4%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in x around inf 98.2%
Final simplification73.8%
(FPCore (x) :precision binary64 (if (<= x 1e-11) 0.0 (- 1.0 (sqrt 0.5))))
double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 1.0 - sqrt(0.5);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d-11) then
tmp = 0.0d0
else
tmp = 1.0d0 - sqrt(0.5d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 1.0 - Math.sqrt(0.5);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-11: tmp = 0.0 else: tmp = 1.0 - math.sqrt(0.5) return tmp
function code(x) tmp = 0.0 if (x <= 1e-11) tmp = 0.0; else tmp = Float64(1.0 - sqrt(0.5)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-11) tmp = 0.0; else tmp = 1.0 - sqrt(0.5); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-11], 0.0, N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-11}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{0.5}\\
\end{array}
\end{array}
if x < 9.99999999999999939e-12Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 65.1%
if 9.99999999999999939e-12 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in x around inf 96.7%
Final simplification73.4%
(FPCore (x) :precision binary64 (if (<= x 1.0) 0.0 (- 0.25 (/ 0.25 x))))
double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 0.0;
} else {
tmp = 0.25 - (0.25 / x);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 0.0d0
else
tmp = 0.25d0 - (0.25d0 / x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1.0) {
tmp = 0.0;
} else {
tmp = 0.25 - (0.25 / x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1.0: tmp = 0.0 else: tmp = 0.25 - (0.25 / x) return tmp
function code(x) tmp = 0.0 if (x <= 1.0) tmp = 0.0; else tmp = Float64(0.25 - Float64(0.25 / x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1.0) tmp = 0.0; else tmp = 0.25 - (0.25 / x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1.0], 0.0, N[(0.25 - N[(0.25 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.25 - \frac{0.25}{x}\\
\end{array}
\end{array}
if x < 1Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 65.1%
if 1 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.4%
metadata-eval98.4%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 99.3%
associate-*r/99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in x around 0 22.7%
associate-*r/22.7%
metadata-eval22.7%
Simplified22.7%
Final simplification54.0%
(FPCore (x) :precision binary64 (if (<= x 1e-11) 0.0 0.18181818181818182))
double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d-11) then
tmp = 0.0d0
else
tmp = 0.18181818181818182d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e-11) {
tmp = 0.0;
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-11: tmp = 0.0 else: tmp = 0.18181818181818182 return tmp
function code(x) tmp = 0.0 if (x <= 1e-11) tmp = 0.0; else tmp = 0.18181818181818182; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-11) tmp = 0.0; else tmp = 0.18181818181818182; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-11], 0.0, 0.18181818181818182]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-11}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\end{array}
if x < 9.99999999999999939e-12Initial program 99.4%
distribute-lft-in99.4%
metadata-eval99.4%
associate-*r/99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 65.1%
if 9.99999999999999939e-12 < x Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.4%
div-inv98.4%
metadata-eval98.4%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in x around 0 19.5%
associate-*r/19.5%
metadata-eval19.5%
Simplified19.5%
Taylor expanded in x around inf 19.5%
Final simplification53.2%
(FPCore (x) :precision binary64 0.18181818181818182)
double code(double x) {
return 0.18181818181818182;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.18181818181818182d0
end function
public static double code(double x) {
return 0.18181818181818182;
}
def code(x): return 0.18181818181818182
function code(x) return 0.18181818181818182 end
function tmp = code(x) tmp = 0.18181818181818182; end
code[x_] := 0.18181818181818182
\begin{array}{l}
\\
0.18181818181818182
\end{array}
Initial program 99.1%
distribute-lft-in99.1%
metadata-eval99.1%
associate-*r/99.1%
metadata-eval99.1%
Simplified99.1%
flip--99.1%
div-inv99.1%
metadata-eval99.1%
add-sqr-sqrt99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
*-commutative99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in x around 0 31.8%
associate-*r/31.8%
metadata-eval31.8%
Simplified31.8%
Taylor expanded in x around inf 11.7%
Final simplification11.7%
herbie shell --seed 2024053
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))