
(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 19 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))))
(if (<= (hypot 1.0 x) 2.0)
(+
(* 0.125 (pow x 2.0))
(+
(* 0.0673828125 (pow x 6.0))
(+ (* -0.056243896484375 (pow x 8.0)) (* -0.0859375 (pow x 4.0)))))
(/ 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);
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = (0.125 * pow(x, 2.0)) + ((0.0673828125 * pow(x, 6.0)) + ((-0.056243896484375 * pow(x, 8.0)) + (-0.0859375 * pow(x, 4.0))));
} else {
tmp = 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0));
}
return tmp;
}
public static double code(double x) {
double t_0 = 0.5 / Math.hypot(1.0, x);
double tmp;
if (Math.hypot(1.0, x) <= 2.0) {
tmp = (0.125 * Math.pow(x, 2.0)) + ((0.0673828125 * Math.pow(x, 6.0)) + ((-0.056243896484375 * Math.pow(x, 8.0)) + (-0.0859375 * Math.pow(x, 4.0))));
} else {
tmp = 1.0 / ((1.0 + Math.sqrt((0.5 + t_0))) / (0.5 - t_0));
}
return tmp;
}
def code(x): t_0 = 0.5 / math.hypot(1.0, x) tmp = 0 if math.hypot(1.0, x) <= 2.0: tmp = (0.125 * math.pow(x, 2.0)) + ((0.0673828125 * math.pow(x, 6.0)) + ((-0.056243896484375 * math.pow(x, 8.0)) + (-0.0859375 * math.pow(x, 4.0)))) else: tmp = 1.0 / ((1.0 + math.sqrt((0.5 + t_0))) / (0.5 - t_0)) return tmp
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) tmp = 0.0 if (hypot(1.0, x) <= 2.0) tmp = Float64(Float64(0.125 * (x ^ 2.0)) + Float64(Float64(0.0673828125 * (x ^ 6.0)) + Float64(Float64(-0.056243896484375 * (x ^ 8.0)) + Float64(-0.0859375 * (x ^ 4.0))))); else tmp = Float64(1.0 / Float64(Float64(1.0 + sqrt(Float64(0.5 + t_0))) / Float64(0.5 - t_0))); end return tmp end
function tmp_2 = code(x) t_0 = 0.5 / hypot(1.0, x); tmp = 0.0; if (hypot(1.0, x) <= 2.0) tmp = (0.125 * (x ^ 2.0)) + ((0.0673828125 * (x ^ 6.0)) + ((-0.056243896484375 * (x ^ 8.0)) + (-0.0859375 * (x ^ 4.0)))); else tmp = 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.0673828125 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-0.056243896484375 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + \left(-0.056243896484375 \cdot {x}^{8} + -0.0859375 \cdot {x}^{4}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + \sqrt{0.5 + t_0}}{0.5 - t_0}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 2Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
Taylor expanded in x around 0 99.9%
if 2 < (hypot.f64 1 x) Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.5%
div-inv98.5%
metadata-eval98.5%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 0.5 (hypot 1.0 x))))
(if (<= (hypot 1.0 x) 1.00005)
(fma x (* x 0.125) (* -0.0859375 (pow x 4.0)))
(/ 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);
double tmp;
if (hypot(1.0, x) <= 1.00005) {
tmp = fma(x, (x * 0.125), (-0.0859375 * pow(x, 4.0)));
} else {
tmp = 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0));
}
return tmp;
}
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) tmp = 0.0 if (hypot(1.0, x) <= 1.00005) tmp = fma(x, Float64(x * 0.125), Float64(-0.0859375 * (x ^ 4.0))); else tmp = Float64(1.0 / Float64(Float64(1.0 + sqrt(Float64(0.5 + t_0))) / Float64(0.5 - t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 1.00005], N[(x * N[(x * 0.125), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $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)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.00005:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.125, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 + \sqrt{0.5 + t_0}}{0.5 - t_0}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 1.00005000000000011Initial program 61.6%
distribute-lft-in61.6%
metadata-eval61.6%
associate-*r/61.6%
metadata-eval61.6%
Simplified61.6%
flip--61.6%
div-inv61.6%
metadata-eval61.6%
add-sqr-sqrt61.6%
associate--r+61.6%
metadata-eval61.6%
Applied egg-rr61.6%
*-commutative61.6%
associate-/r/61.6%
Simplified61.6%
Taylor expanded in x around 0 98.7%
associate-*r/98.7%
metadata-eval98.7%
unpow298.8%
*-commutative98.8%
unpow298.8%
Simplified98.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
if 1.00005000000000011 < (hypot.f64 1 x) Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
flip--98.3%
div-inv98.3%
metadata-eval98.3%
add-sqr-sqrt99.8%
associate--r+99.8%
metadata-eval99.8%
Applied egg-rr99.8%
*-commutative99.8%
associate-/r/99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 0.5 (hypot 1.0 x))))
(if (<= (hypot 1.0 x) 1.00005)
(fma x (* x 0.125) (* -0.0859375 (pow x 4.0)))
(/ (- 0.5 t_0) (+ 1.0 (sqrt (+ 0.5 t_0)))))))
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
double tmp;
if (hypot(1.0, x) <= 1.00005) {
tmp = fma(x, (x * 0.125), (-0.0859375 * pow(x, 4.0)));
} else {
tmp = (0.5 - t_0) / (1.0 + sqrt((0.5 + t_0)));
}
return tmp;
}
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) tmp = 0.0 if (hypot(1.0, x) <= 1.00005) tmp = fma(x, Float64(x * 0.125), Float64(-0.0859375 * (x ^ 4.0))); else tmp = Float64(Float64(0.5 - t_0) / Float64(1.0 + sqrt(Float64(0.5 + t_0)))); end return tmp end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 1.00005], N[(x * N[(x * 0.125), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $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)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.00005:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.125, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - t_0}{1 + \sqrt{0.5 + t_0}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 1.00005000000000011Initial program 61.6%
distribute-lft-in61.6%
metadata-eval61.6%
associate-*r/61.6%
metadata-eval61.6%
Simplified61.6%
flip--61.6%
div-inv61.6%
metadata-eval61.6%
add-sqr-sqrt61.6%
associate--r+61.6%
metadata-eval61.6%
Applied egg-rr61.6%
*-commutative61.6%
associate-/r/61.6%
Simplified61.6%
Taylor expanded in x around 0 98.7%
associate-*r/98.7%
metadata-eval98.7%
unpow298.8%
*-commutative98.8%
unpow298.8%
Simplified98.8%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
if 1.00005000000000011 < (hypot.f64 1 x) Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
flip--98.3%
metadata-eval98.3%
add-sqr-sqrt99.8%
associate--r+99.8%
metadata-eval99.8%
Applied egg-rr99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(if (<= (hypot 1.0 x) 2.0)
(+
(* 0.125 (pow x 2.0))
(+ (* 0.0673828125 (pow x 6.0)) (* -0.0859375 (pow x 4.0))))
(/ (- 0.5 (/ 0.5 (hypot 1.0 x))) (+ 1.0 (sqrt (- 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = (0.125 * pow(x, 2.0)) + ((0.0673828125 * pow(x, 6.0)) + (-0.0859375 * pow(x, 4.0)));
} else {
tmp = (0.5 - (0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 - (0.5 / x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.hypot(1.0, x) <= 2.0) {
tmp = (0.125 * Math.pow(x, 2.0)) + ((0.0673828125 * Math.pow(x, 6.0)) + (-0.0859375 * Math.pow(x, 4.0)));
} else {
tmp = (0.5 - (0.5 / Math.hypot(1.0, x))) / (1.0 + Math.sqrt((0.5 - (0.5 / x))));
}
return tmp;
}
def code(x): tmp = 0 if math.hypot(1.0, x) <= 2.0: tmp = (0.125 * math.pow(x, 2.0)) + ((0.0673828125 * math.pow(x, 6.0)) + (-0.0859375 * math.pow(x, 4.0))) else: tmp = (0.5 - (0.5 / math.hypot(1.0, x))) / (1.0 + math.sqrt((0.5 - (0.5 / x)))) return tmp
function code(x) tmp = 0.0 if (hypot(1.0, x) <= 2.0) tmp = Float64(Float64(0.125 * (x ^ 2.0)) + Float64(Float64(0.0673828125 * (x ^ 6.0)) + Float64(-0.0859375 * (x ^ 4.0)))); else tmp = Float64(Float64(0.5 - Float64(0.5 / hypot(1.0, x))) / Float64(1.0 + sqrt(Float64(0.5 - Float64(0.5 / x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (hypot(1.0, x) <= 2.0) tmp = (0.125 * (x ^ 2.0)) + ((0.0673828125 * (x ^ 6.0)) + (-0.0859375 * (x ^ 4.0))); else tmp = (0.5 - (0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 - (0.5 / x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.0673828125 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 - N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 - \frac{0.5}{x}}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 2Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
Taylor expanded in x around 0 99.8%
if 2 < (hypot.f64 1 x) Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.5%
metadata-eval98.5%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around -inf 98.9%
associate-*r/97.2%
metadata-eval97.2%
Simplified98.9%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= (hypot 1.0 x) 2.0) (fma x (* x 0.125) (* -0.0859375 (pow x 4.0))) (/ (- 0.5 (/ 0.5 (hypot 1.0 x))) (+ 1.0 (sqrt (- 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = fma(x, (x * 0.125), (-0.0859375 * pow(x, 4.0)));
} else {
tmp = (0.5 - (0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 - (0.5 / x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (hypot(1.0, x) <= 2.0) tmp = fma(x, Float64(x * 0.125), Float64(-0.0859375 * (x ^ 4.0))); else tmp = Float64(Float64(0.5 - Float64(0.5 / hypot(1.0, x))) / Float64(1.0 + sqrt(Float64(0.5 - Float64(0.5 / x))))); end return tmp end
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(x * N[(x * 0.125), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 - N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.125, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 - \frac{0.5}{x}}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 2Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 98.6%
associate-*r/98.6%
metadata-eval98.6%
unpow298.6%
*-commutative98.6%
unpow298.6%
Simplified98.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
unpow299.7%
associate-*l*99.7%
fma-def99.7%
Simplified99.7%
if 2 < (hypot.f64 1 x) Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.5%
metadata-eval98.5%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around -inf 98.9%
associate-*r/97.2%
metadata-eval97.2%
Simplified98.9%
Final simplification99.3%
(FPCore (x) :precision binary64 (if (<= (hypot 1.0 x) 1.000000005) (* x (* x 0.125)) (- 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x)))))))
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 1.000000005) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x))));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.hypot(1.0, x) <= 1.000000005) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x))));
}
return tmp;
}
def code(x): tmp = 0 if math.hypot(1.0, x) <= 1.000000005: tmp = x * (x * 0.125) else: tmp = 1.0 - math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))) return tmp
function code(x) tmp = 0.0 if (hypot(1.0, x) <= 1.000000005) tmp = Float64(x * Float64(x * 0.125)); else tmp = Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (hypot(1.0, x) <= 1.000000005) tmp = x * (x * 0.125); else tmp = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x)))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 1.000000005], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.000000005:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 1.000000005Initial program 61.6%
distribute-lft-in61.6%
metadata-eval61.6%
associate-*r/61.6%
metadata-eval61.6%
Simplified61.6%
flip--61.6%
div-inv61.6%
metadata-eval61.6%
add-sqr-sqrt61.6%
associate--r+61.6%
metadata-eval61.6%
Applied egg-rr61.6%
*-commutative61.6%
associate-/r/61.6%
Simplified61.6%
Taylor expanded in x around 0 99.8%
*-commutative99.8%
unpow299.8%
associate-*l*99.8%
Simplified99.8%
if 1.000000005 < (hypot.f64 1 x) Initial program 98.1%
distribute-lft-in98.1%
metadata-eval98.1%
associate-*r/98.1%
metadata-eval98.1%
Simplified98.1%
Final simplification98.9%
(FPCore (x) :precision binary64 (if (<= (hypot 1.0 x) 2.0) (fma 0.125 (* x x) (* -0.0859375 (pow x 4.0))) (/ (+ 0.5 (/ 0.5 x)) (+ 1.0 (sqrt (- 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = fma(0.125, (x * x), (-0.0859375 * pow(x, 4.0)));
} else {
tmp = (0.5 + (0.5 / x)) / (1.0 + sqrt((0.5 - (0.5 / x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (hypot(1.0, x) <= 2.0) tmp = fma(0.125, Float64(x * x), Float64(-0.0859375 * (x ^ 4.0))); else tmp = Float64(Float64(0.5 + Float64(0.5 / x)) / Float64(1.0 + sqrt(Float64(0.5 - Float64(0.5 / x))))); end return tmp end
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(0.125 * N[(x * x), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;\mathsf{fma}\left(0.125, x \cdot x, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{0.5}{x}}{1 + \sqrt{0.5 - \frac{0.5}{x}}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 2Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
Taylor expanded in x around 0 99.6%
fma-def99.6%
unpow299.7%
Simplified99.7%
if 2 < (hypot.f64 1 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 97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
flip--97.2%
metadata-eval97.2%
add-sqr-sqrt98.7%
+-commutative98.7%
Applied egg-rr98.7%
associate--r-98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x) :precision binary64 (if (<= (hypot 1.0 x) 2.0) (fma x (* x 0.125) (* -0.0859375 (pow x 4.0))) (/ (+ 0.5 (/ 0.5 x)) (+ 1.0 (sqrt (- 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = fma(x, (x * 0.125), (-0.0859375 * pow(x, 4.0)));
} else {
tmp = (0.5 + (0.5 / x)) / (1.0 + sqrt((0.5 - (0.5 / x))));
}
return tmp;
}
function code(x) tmp = 0.0 if (hypot(1.0, x) <= 2.0) tmp = fma(x, Float64(x * 0.125), Float64(-0.0859375 * (x ^ 4.0))); else tmp = Float64(Float64(0.5 + Float64(0.5 / x)) / Float64(1.0 + sqrt(Float64(0.5 - Float64(0.5 / x))))); end return tmp end
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(x * N[(x * 0.125), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;\mathsf{fma}\left(x, x \cdot 0.125, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{0.5}{x}}{1 + \sqrt{0.5 - \frac{0.5}{x}}}\\
\end{array}
\end{array}
if (hypot.f64 1 x) < 2Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 98.6%
associate-*r/98.6%
metadata-eval98.6%
unpow298.6%
*-commutative98.6%
unpow298.6%
Simplified98.6%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
unpow299.7%
associate-*l*99.7%
fma-def99.7%
Simplified99.7%
if 2 < (hypot.f64 1 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 97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
flip--97.2%
metadata-eval97.2%
add-sqr-sqrt98.7%
+-commutative98.7%
Applied egg-rr98.7%
associate--r-98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 0.5 (/ 0.5 x))) (t_1 (- 0.5 (/ 0.5 x))))
(if (<= x -1.25)
(/ t_0 (+ 1.0 (sqrt t_1)))
(if (<= x 1.25) (* x (* x 0.125)) (/ t_1 (+ 1.0 (sqrt t_0)))))))
double code(double x) {
double t_0 = 0.5 + (0.5 / x);
double t_1 = 0.5 - (0.5 / x);
double tmp;
if (x <= -1.25) {
tmp = t_0 / (1.0 + sqrt(t_1));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = t_1 / (1.0 + sqrt(t_0));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 + (0.5d0 / x)
t_1 = 0.5d0 - (0.5d0 / x)
if (x <= (-1.25d0)) then
tmp = t_0 / (1.0d0 + sqrt(t_1))
else if (x <= 1.25d0) then
tmp = x * (x * 0.125d0)
else
tmp = t_1 / (1.0d0 + sqrt(t_0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 0.5 + (0.5 / x);
double t_1 = 0.5 - (0.5 / x);
double tmp;
if (x <= -1.25) {
tmp = t_0 / (1.0 + Math.sqrt(t_1));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = t_1 / (1.0 + Math.sqrt(t_0));
}
return tmp;
}
def code(x): t_0 = 0.5 + (0.5 / x) t_1 = 0.5 - (0.5 / x) tmp = 0 if x <= -1.25: tmp = t_0 / (1.0 + math.sqrt(t_1)) elif x <= 1.25: tmp = x * (x * 0.125) else: tmp = t_1 / (1.0 + math.sqrt(t_0)) return tmp
function code(x) t_0 = Float64(0.5 + Float64(0.5 / x)) t_1 = Float64(0.5 - Float64(0.5 / x)) tmp = 0.0 if (x <= -1.25) tmp = Float64(t_0 / Float64(1.0 + sqrt(t_1))); elseif (x <= 1.25) tmp = Float64(x * Float64(x * 0.125)); else tmp = Float64(t_1 / Float64(1.0 + sqrt(t_0))); end return tmp end
function tmp_2 = code(x) t_0 = 0.5 + (0.5 / x); t_1 = 0.5 - (0.5 / x); tmp = 0.0; if (x <= -1.25) tmp = t_0 / (1.0 + sqrt(t_1)); elseif (x <= 1.25) tmp = x * (x * 0.125); else tmp = t_1 / (1.0 + sqrt(t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.25], N[(t$95$0 / N[(1.0 + N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
t_1 := 0.5 - \frac{0.5}{x}\\
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{t_0}{1 + \sqrt{t_1}}\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \sqrt{t_0}}\\
\end{array}
\end{array}
if x < -1.25Initial 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 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
flip--98.0%
metadata-eval98.0%
add-sqr-sqrt99.5%
+-commutative99.5%
Applied egg-rr99.5%
associate--r-99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
if -1.25 < x < 1.25Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
if 1.25 < 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 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.5%
metadata-eval98.5%
add-sqr-sqrt99.9%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.3%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 0.5 (/ 0.5 x))))
(if (<= x -1.25)
(/ t_0 (+ 1.0 (sqrt (- 0.5 (/ 0.5 x)))))
(if (<= x 1.25) (* x (* x 0.125)) (- 1.0 (sqrt t_0))))))
double code(double x) {
double t_0 = 0.5 + (0.5 / x);
double tmp;
if (x <= -1.25) {
tmp = t_0 / (1.0 + sqrt((0.5 - (0.5 / x))));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - sqrt(t_0);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 + (0.5d0 / x)
if (x <= (-1.25d0)) then
tmp = t_0 / (1.0d0 + sqrt((0.5d0 - (0.5d0 / x))))
else if (x <= 1.25d0) then
tmp = x * (x * 0.125d0)
else
tmp = 1.0d0 - sqrt(t_0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 0.5 + (0.5 / x);
double tmp;
if (x <= -1.25) {
tmp = t_0 / (1.0 + Math.sqrt((0.5 - (0.5 / x))));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - Math.sqrt(t_0);
}
return tmp;
}
def code(x): t_0 = 0.5 + (0.5 / x) tmp = 0 if x <= -1.25: tmp = t_0 / (1.0 + math.sqrt((0.5 - (0.5 / x)))) elif x <= 1.25: tmp = x * (x * 0.125) else: tmp = 1.0 - math.sqrt(t_0) return tmp
function code(x) t_0 = Float64(0.5 + Float64(0.5 / x)) tmp = 0.0 if (x <= -1.25) tmp = Float64(t_0 / Float64(1.0 + sqrt(Float64(0.5 - Float64(0.5 / x))))); elseif (x <= 1.25) tmp = Float64(x * Float64(x * 0.125)); else tmp = Float64(1.0 - sqrt(t_0)); end return tmp end
function tmp_2 = code(x) t_0 = 0.5 + (0.5 / x); tmp = 0.0; if (x <= -1.25) tmp = t_0 / (1.0 + sqrt((0.5 - (0.5 / x)))); elseif (x <= 1.25) tmp = x * (x * 0.125); else tmp = 1.0 - sqrt(t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.25], N[(t$95$0 / N[(1.0 + N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{t_0}{1 + \sqrt{0.5 - \frac{0.5}{x}}}\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{t_0}\\
\end{array}
\end{array}
if x < -1.25Initial 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 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
flip--98.0%
metadata-eval98.0%
add-sqr-sqrt99.5%
+-commutative99.5%
Applied egg-rr99.5%
associate--r-99.5%
metadata-eval99.5%
+-commutative99.5%
Simplified99.5%
if -1.25 < x < 1.25Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
if 1.25 < 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 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification99.1%
(FPCore (x) :precision binary64 (if (<= x -1.55) (/ 0.5 (+ 1.0 (sqrt 0.5))) (if (<= x 1.25) (* x (* x 0.125)) (- 1.0 (sqrt (+ 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (x <= -1.55) {
tmp = 0.5 / (1.0 + sqrt(0.5));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - sqrt((0.5 + (0.5 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.55d0)) then
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
else if (x <= 1.25d0) then
tmp = x * (x * 0.125d0)
else
tmp = 1.0d0 - sqrt((0.5d0 + (0.5d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.55) {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - Math.sqrt((0.5 + (0.5 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.55: tmp = 0.5 / (1.0 + math.sqrt(0.5)) elif x <= 1.25: tmp = x * (x * 0.125) else: tmp = 1.0 - math.sqrt((0.5 + (0.5 / x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.55) tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); elseif (x <= 1.25) tmp = Float64(x * Float64(x * 0.125)); else tmp = Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.55) tmp = 0.5 / (1.0 + sqrt(0.5)); elseif (x <= 1.25) tmp = x * (x * 0.125); else tmp = 1.0 - sqrt((0.5 + (0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.55], N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{0.5 + \frac{0.5}{x}}\\
\end{array}
\end{array}
if x < -1.55000000000000004Initial program 98.5%
distribute-lft-in98.5%
metadata-eval98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
flip--98.5%
div-inv98.5%
metadata-eval98.5%
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 97.5%
if -1.55000000000000004 < x < 1.25Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
if 1.25 < 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 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x) :precision binary64 (if (<= x -1.25) (- 1.0 (sqrt (- 0.5 (/ 0.5 x)))) (if (<= x 1.25) (* x (* x 0.125)) (- 1.0 (sqrt (+ 0.5 (/ 0.5 x)))))))
double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = 1.0 - sqrt((0.5 - (0.5 / x)));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - sqrt((0.5 + (0.5 / x)));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.25d0)) then
tmp = 1.0d0 - sqrt((0.5d0 - (0.5d0 / x)))
else if (x <= 1.25d0) then
tmp = x * (x * 0.125d0)
else
tmp = 1.0d0 - sqrt((0.5d0 + (0.5d0 / x)))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.25) {
tmp = 1.0 - Math.sqrt((0.5 - (0.5 / x)));
} else if (x <= 1.25) {
tmp = x * (x * 0.125);
} else {
tmp = 1.0 - Math.sqrt((0.5 + (0.5 / x)));
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.25: tmp = 1.0 - math.sqrt((0.5 - (0.5 / x))) elif x <= 1.25: tmp = x * (x * 0.125) else: tmp = 1.0 - math.sqrt((0.5 + (0.5 / x))) return tmp
function code(x) tmp = 0.0 if (x <= -1.25) tmp = Float64(1.0 - sqrt(Float64(0.5 - Float64(0.5 / x)))); elseif (x <= 1.25) tmp = Float64(x * Float64(x * 0.125)); else tmp = Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / x)))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.25) tmp = 1.0 - sqrt((0.5 - (0.5 / x))); elseif (x <= 1.25) tmp = x * (x * 0.125); else tmp = 1.0 - sqrt((0.5 + (0.5 / x))); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.25], N[(1.0 - N[Sqrt[N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;1 - \sqrt{0.5 - \frac{0.5}{x}}\\
\mathbf{elif}\;x \leq 1.25:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{0.5 + \frac{0.5}{x}}\\
\end{array}
\end{array}
if x < -1.25Initial 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 98.0%
associate-*r/98.0%
metadata-eval98.0%
Simplified98.0%
if -1.25 < x < 1.25Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
if 1.25 < 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 98.5%
associate-*r/98.5%
metadata-eval98.5%
Simplified98.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (if (or (<= x -1.55) (not (<= x 1.55))) (/ 0.5 (+ 1.0 (sqrt 0.5))) (* x (* x 0.125))))
double code(double x) {
double tmp;
if ((x <= -1.55) || !(x <= 1.55)) {
tmp = 0.5 / (1.0 + sqrt(0.5));
} else {
tmp = x * (x * 0.125);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.55d0)) .or. (.not. (x <= 1.55d0))) then
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
else
tmp = x * (x * 0.125d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.55) || !(x <= 1.55)) {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
} else {
tmp = x * (x * 0.125);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.55) or not (x <= 1.55): tmp = 0.5 / (1.0 + math.sqrt(0.5)) else: tmp = x * (x * 0.125) return tmp
function code(x) tmp = 0.0 if ((x <= -1.55) || !(x <= 1.55)) tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); else tmp = Float64(x * Float64(x * 0.125)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.55) || ~((x <= 1.55))) tmp = 0.5 / (1.0 + sqrt(0.5)); else tmp = x * (x * 0.125); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 1.55]], $MachinePrecision]], N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 1.55\right):\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 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.5%
div-inv98.5%
metadata-eval98.5%
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 97.5%
if -1.55000000000000004 < x < 1.55000000000000004Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
Final simplification98.3%
(FPCore (x) :precision binary64 (if (or (<= x -1.55) (not (<= x 1.55))) (- 1.0 (sqrt 0.5)) (* x (* x 0.125))))
double code(double x) {
double tmp;
if ((x <= -1.55) || !(x <= 1.55)) {
tmp = 1.0 - sqrt(0.5);
} else {
tmp = x * (x * 0.125);
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.55d0)) .or. (.not. (x <= 1.55d0))) then
tmp = 1.0d0 - sqrt(0.5d0)
else
tmp = x * (x * 0.125d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.55) || !(x <= 1.55)) {
tmp = 1.0 - Math.sqrt(0.5);
} else {
tmp = x * (x * 0.125);
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.55) or not (x <= 1.55): tmp = 1.0 - math.sqrt(0.5) else: tmp = x * (x * 0.125) return tmp
function code(x) tmp = 0.0 if ((x <= -1.55) || !(x <= 1.55)) tmp = Float64(1.0 - sqrt(0.5)); else tmp = Float64(x * Float64(x * 0.125)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.55) || ~((x <= 1.55))) tmp = 1.0 - sqrt(0.5); else tmp = x * (x * 0.125); end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.55], N[Not[LessEqual[x, 1.55]], $MachinePrecision]], N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 1.55\right):\\
\;\;\;\;1 - \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\end{array}
\end{array}
if x < -1.55000000000000004 or 1.55000000000000004 < 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.1%
if -1.55000000000000004 < x < 1.55000000000000004Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
Final simplification97.6%
(FPCore (x) :precision binary64 (if (<= x -1.2) 0.18181818181818182 (if (<= x 1.2) (* 0.125 (* x x)) 0.18181818181818182)))
double code(double x) {
double tmp;
if (x <= -1.2) {
tmp = 0.18181818181818182;
} else if (x <= 1.2) {
tmp = 0.125 * (x * x);
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.2d0)) then
tmp = 0.18181818181818182d0
else if (x <= 1.2d0) then
tmp = 0.125d0 * (x * x)
else
tmp = 0.18181818181818182d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.2) {
tmp = 0.18181818181818182;
} else if (x <= 1.2) {
tmp = 0.125 * (x * x);
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.2: tmp = 0.18181818181818182 elif x <= 1.2: tmp = 0.125 * (x * x) else: tmp = 0.18181818181818182 return tmp
function code(x) tmp = 0.0 if (x <= -1.2) tmp = 0.18181818181818182; elseif (x <= 1.2) tmp = Float64(0.125 * Float64(x * x)); else tmp = 0.18181818181818182; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.2) tmp = 0.18181818181818182; elseif (x <= 1.2) tmp = 0.125 * (x * x); else tmp = 0.18181818181818182; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.2], 0.18181818181818182, If[LessEqual[x, 1.2], N[(0.125 * N[(x * x), $MachinePrecision]), $MachinePrecision], 0.18181818181818182]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;0.18181818181818182\\
\mathbf{elif}\;x \leq 1.2:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\end{array}
if x < -1.19999999999999996 or 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.5%
div-inv98.5%
metadata-eval98.5%
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%
unpow219.5%
Simplified19.5%
Taylor expanded in x around inf 19.5%
if -1.19999999999999996 < x < 1.19999999999999996Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
Taylor expanded in x around 0 99.0%
unpow299.0%
Simplified99.0%
Final simplification60.2%
(FPCore (x) :precision binary64 (if (<= x -1.2) 0.18181818181818182 (if (<= x 1.2) (* x (* x 0.125)) 0.18181818181818182)))
double code(double x) {
double tmp;
if (x <= -1.2) {
tmp = 0.18181818181818182;
} else if (x <= 1.2) {
tmp = x * (x * 0.125);
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.2d0)) then
tmp = 0.18181818181818182d0
else if (x <= 1.2d0) then
tmp = x * (x * 0.125d0)
else
tmp = 0.18181818181818182d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.2) {
tmp = 0.18181818181818182;
} else if (x <= 1.2) {
tmp = x * (x * 0.125);
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.2: tmp = 0.18181818181818182 elif x <= 1.2: tmp = x * (x * 0.125) else: tmp = 0.18181818181818182 return tmp
function code(x) tmp = 0.0 if (x <= -1.2) tmp = 0.18181818181818182; elseif (x <= 1.2) tmp = Float64(x * Float64(x * 0.125)); else tmp = 0.18181818181818182; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.2) tmp = 0.18181818181818182; elseif (x <= 1.2) tmp = x * (x * 0.125); else tmp = 0.18181818181818182; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.2], 0.18181818181818182, If[LessEqual[x, 1.2], N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision], 0.18181818181818182]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;0.18181818181818182\\
\mathbf{elif}\;x \leq 1.2:\\
\;\;\;\;x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\end{array}
if x < -1.19999999999999996 or 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.5%
div-inv98.5%
metadata-eval98.5%
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%
unpow219.5%
Simplified19.5%
Taylor expanded in x around inf 19.5%
if -1.19999999999999996 < x < 1.19999999999999996Initial program 61.7%
distribute-lft-in61.7%
metadata-eval61.7%
associate-*r/61.7%
metadata-eval61.7%
Simplified61.7%
flip--61.7%
div-inv61.7%
metadata-eval61.7%
add-sqr-sqrt61.8%
associate--r+61.8%
metadata-eval61.8%
Applied egg-rr61.8%
*-commutative61.8%
associate-/r/61.8%
Simplified61.8%
Taylor expanded in x around 0 99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.1%
Simplified99.1%
Final simplification60.2%
(FPCore (x) :precision binary64 (/ 1.0 (+ 5.5 (/ 8.0 (* x x)))))
double code(double x) {
return 1.0 / (5.5 + (8.0 / (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (5.5d0 + (8.0d0 / (x * x)))
end function
public static double code(double x) {
return 1.0 / (5.5 + (8.0 / (x * x)));
}
def code(x): return 1.0 / (5.5 + (8.0 / (x * x)))
function code(x) return Float64(1.0 / Float64(5.5 + Float64(8.0 / Float64(x * x)))) end
function tmp = code(x) tmp = 1.0 / (5.5 + (8.0 / (x * x))); end
code[x_] := N[(1.0 / N[(5.5 + N[(8.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{5.5 + \frac{8}{x \cdot x}}
\end{array}
Initial program 79.7%
distribute-lft-in79.7%
metadata-eval79.7%
associate-*r/79.7%
metadata-eval79.7%
Simplified79.7%
flip--79.7%
div-inv79.7%
metadata-eval79.7%
add-sqr-sqrt80.4%
associate--r+80.4%
metadata-eval80.4%
Applied egg-rr80.4%
*-commutative80.4%
associate-/r/80.4%
Simplified80.4%
Taylor expanded in x around 0 59.9%
associate-*r/59.9%
metadata-eval59.9%
unpow259.9%
Simplified59.9%
Final simplification59.9%
(FPCore (x) :precision binary64 (if (<= x -1.9e-77) 0.18181818181818182 (if (<= x 1.9e-77) 0.0 0.18181818181818182)))
double code(double x) {
double tmp;
if (x <= -1.9e-77) {
tmp = 0.18181818181818182;
} else if (x <= 1.9e-77) {
tmp = 0.0;
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-1.9d-77)) then
tmp = 0.18181818181818182d0
else if (x <= 1.9d-77) then
tmp = 0.0d0
else
tmp = 0.18181818181818182d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -1.9e-77) {
tmp = 0.18181818181818182;
} else if (x <= 1.9e-77) {
tmp = 0.0;
} else {
tmp = 0.18181818181818182;
}
return tmp;
}
def code(x): tmp = 0 if x <= -1.9e-77: tmp = 0.18181818181818182 elif x <= 1.9e-77: tmp = 0.0 else: tmp = 0.18181818181818182 return tmp
function code(x) tmp = 0.0 if (x <= -1.9e-77) tmp = 0.18181818181818182; elseif (x <= 1.9e-77) tmp = 0.0; else tmp = 0.18181818181818182; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -1.9e-77) tmp = 0.18181818181818182; elseif (x <= 1.9e-77) tmp = 0.0; else tmp = 0.18181818181818182; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -1.9e-77], 0.18181818181818182, If[LessEqual[x, 1.9e-77], 0.0, 0.18181818181818182]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-77}:\\
\;\;\;\;0.18181818181818182\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-77}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\end{array}
if x < -1.8999999999999999e-77 or 1.8999999999999999e-77 < x Initial program 83.3%
distribute-lft-in83.3%
metadata-eval83.3%
associate-*r/83.3%
metadata-eval83.3%
Simplified83.3%
flip--83.3%
div-inv83.3%
metadata-eval83.3%
add-sqr-sqrt84.5%
associate--r+84.6%
metadata-eval84.6%
Applied egg-rr84.6%
*-commutative84.6%
associate-/r/84.6%
Simplified84.6%
Taylor expanded in x around 0 33.1%
associate-*r/33.1%
metadata-eval33.1%
unpow233.1%
Simplified33.1%
Taylor expanded in x around inf 17.4%
if -1.8999999999999999e-77 < x < 1.8999999999999999e-77Initial program 74.5%
distribute-lft-in74.5%
metadata-eval74.5%
associate-*r/74.5%
metadata-eval74.5%
Simplified74.5%
Taylor expanded in x around 0 74.5%
Final simplification40.8%
(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 79.7%
distribute-lft-in79.7%
metadata-eval79.7%
associate-*r/79.7%
metadata-eval79.7%
Simplified79.7%
flip--79.7%
div-inv79.7%
metadata-eval79.7%
add-sqr-sqrt80.4%
associate--r+80.4%
metadata-eval80.4%
Applied egg-rr80.4%
*-commutative80.4%
associate-/r/80.4%
Simplified80.4%
Taylor expanded in x around 0 59.9%
associate-*r/59.9%
metadata-eval59.9%
unpow259.9%
Simplified59.9%
Taylor expanded in x around inf 11.6%
Final simplification11.6%
herbie shell --seed 2023227
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))