
(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 13 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.0859375 (pow x 4.0)) (* 0.125 (pow x 2.0))))
(t_1 (/ 0.5 (hypot 1.0 x)))
(t_2 (+ 0.5 t_1))
(t_3 (sqrt t_2)))
(if (<= x -0.0017)
(/ (/ (+ 0.25 (/ -0.25 (fma x x 1.0))) (- -0.5 t_1)) (- -1.0 t_3))
(if (<= x -7e-60)
t_0
(if (<= x 7e-60)
0.0
(if (<= x 0.0024) t_0 (/ (- 1.0 t_2) (+ 1.0 t_3))))))))
double code(double x) {
double t_0 = (-0.0859375 * pow(x, 4.0)) + (0.125 * pow(x, 2.0));
double t_1 = 0.5 / hypot(1.0, x);
double t_2 = 0.5 + t_1;
double t_3 = sqrt(t_2);
double tmp;
if (x <= -0.0017) {
tmp = ((0.25 + (-0.25 / fma(x, x, 1.0))) / (-0.5 - t_1)) / (-1.0 - t_3);
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0024) {
tmp = t_0;
} else {
tmp = (1.0 - t_2) / (1.0 + t_3);
}
return tmp;
}
function code(x) t_0 = Float64(Float64(-0.0859375 * (x ^ 4.0)) + Float64(0.125 * (x ^ 2.0))) t_1 = Float64(0.5 / hypot(1.0, x)) t_2 = Float64(0.5 + t_1) t_3 = sqrt(t_2) tmp = 0.0 if (x <= -0.0017) tmp = Float64(Float64(Float64(0.25 + Float64(-0.25 / fma(x, x, 1.0))) / Float64(-0.5 - t_1)) / Float64(-1.0 - t_3)); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0024) tmp = t_0; else tmp = Float64(Float64(1.0 - t_2) / Float64(1.0 + t_3)); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$2], $MachinePrecision]}, If[LessEqual[x, -0.0017], N[(N[(N[(0.25 + N[(-0.25 / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-0.5 - t$95$1), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -7e-60], t$95$0, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.0024], t$95$0, N[(N[(1.0 - t$95$2), $MachinePrecision] / N[(1.0 + t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}\\
t_1 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
t_2 := 0.5 + t\_1\\
t_3 := \sqrt{t\_2}\\
\mathbf{if}\;x \leq -0.0017:\\
\;\;\;\;\frac{\frac{0.25 + \frac{-0.25}{\mathsf{fma}\left(x, x, 1\right)}}{-0.5 - t\_1}}{-1 - t\_3}\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.0024:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_2}{1 + t\_3}\\
\end{array}
\end{array}
if x < -0.00169999999999999991Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
flip--98.3%
div-inv98.2%
metadata-eval98.2%
add-sqr-sqrt99.8%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
flip--99.9%
frac-2neg99.9%
metadata-eval99.9%
frac-times99.9%
metadata-eval99.9%
frac-times99.8%
metadata-eval99.8%
hypot-udef99.8%
hypot-udef99.8%
rem-square-sqrt99.9%
metadata-eval99.9%
unpow299.9%
Applied egg-rr99.9%
times-frac99.9%
associate-*r/99.9%
Simplified99.9%
if -0.00169999999999999991 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 0.00239999999999999979Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 100.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
if 0.00239999999999999979 < x Initial program 98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
sub-neg98.2%
flip-+98.3%
metadata-eval98.3%
pow198.3%
pow198.3%
pow-prod-up98.3%
metadata-eval98.3%
Applied egg-rr98.3%
unpow298.3%
sqr-neg98.3%
rem-square-sqrt99.8%
sub-neg99.8%
remove-double-neg99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (* -0.0859375 (pow x 4.0)) (* 0.125 (pow x 2.0))))
(t_1 (/ 0.5 (hypot 1.0 x)))
(t_2 (+ 0.5 t_1))
(t_3 (+ 1.0 (sqrt t_2))))
(if (<= x -0.0017)
(* (- 0.5 t_1) (/ 1.0 t_3))
(if (<= x -7e-60)
t_0
(if (<= x 7e-60) 0.0 (if (<= x 0.0024) t_0 (/ (- 1.0 t_2) t_3)))))))
double code(double x) {
double t_0 = (-0.0859375 * pow(x, 4.0)) + (0.125 * pow(x, 2.0));
double t_1 = 0.5 / hypot(1.0, x);
double t_2 = 0.5 + t_1;
double t_3 = 1.0 + sqrt(t_2);
double tmp;
if (x <= -0.0017) {
tmp = (0.5 - t_1) * (1.0 / t_3);
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0024) {
tmp = t_0;
} else {
tmp = (1.0 - t_2) / t_3;
}
return tmp;
}
public static double code(double x) {
double t_0 = (-0.0859375 * Math.pow(x, 4.0)) + (0.125 * Math.pow(x, 2.0));
double t_1 = 0.5 / Math.hypot(1.0, x);
double t_2 = 0.5 + t_1;
double t_3 = 1.0 + Math.sqrt(t_2);
double tmp;
if (x <= -0.0017) {
tmp = (0.5 - t_1) * (1.0 / t_3);
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0024) {
tmp = t_0;
} else {
tmp = (1.0 - t_2) / t_3;
}
return tmp;
}
def code(x): t_0 = (-0.0859375 * math.pow(x, 4.0)) + (0.125 * math.pow(x, 2.0)) t_1 = 0.5 / math.hypot(1.0, x) t_2 = 0.5 + t_1 t_3 = 1.0 + math.sqrt(t_2) tmp = 0 if x <= -0.0017: tmp = (0.5 - t_1) * (1.0 / t_3) elif x <= -7e-60: tmp = t_0 elif x <= 7e-60: tmp = 0.0 elif x <= 0.0024: tmp = t_0 else: tmp = (1.0 - t_2) / t_3 return tmp
function code(x) t_0 = Float64(Float64(-0.0859375 * (x ^ 4.0)) + Float64(0.125 * (x ^ 2.0))) t_1 = Float64(0.5 / hypot(1.0, x)) t_2 = Float64(0.5 + t_1) t_3 = Float64(1.0 + sqrt(t_2)) tmp = 0.0 if (x <= -0.0017) tmp = Float64(Float64(0.5 - t_1) * Float64(1.0 / t_3)); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0024) tmp = t_0; else tmp = Float64(Float64(1.0 - t_2) / t_3); end return tmp end
function tmp_2 = code(x) t_0 = (-0.0859375 * (x ^ 4.0)) + (0.125 * (x ^ 2.0)); t_1 = 0.5 / hypot(1.0, x); t_2 = 0.5 + t_1; t_3 = 1.0 + sqrt(t_2); tmp = 0.0; if (x <= -0.0017) tmp = (0.5 - t_1) * (1.0 / t_3); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0024) tmp = t_0; else tmp = (1.0 - t_2) / t_3; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 + t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[Sqrt[t$95$2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0017], N[(N[(0.5 - t$95$1), $MachinePrecision] * N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -7e-60], t$95$0, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.0024], t$95$0, N[(N[(1.0 - t$95$2), $MachinePrecision] / t$95$3), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}\\
t_1 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
t_2 := 0.5 + t\_1\\
t_3 := 1 + \sqrt{t\_2}\\
\mathbf{if}\;x \leq -0.0017:\\
\;\;\;\;\left(0.5 - t\_1\right) \cdot \frac{1}{t\_3}\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.0024:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_2}{t\_3}\\
\end{array}
\end{array}
if x < -0.00169999999999999991Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
flip--98.3%
div-inv98.2%
metadata-eval98.2%
add-sqr-sqrt99.8%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -0.00169999999999999991 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 0.00239999999999999979Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 100.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
if 0.00239999999999999979 < x Initial program 98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
sub-neg98.2%
flip-+98.3%
metadata-eval98.3%
pow198.3%
pow198.3%
pow-prod-up98.3%
metadata-eval98.3%
Applied egg-rr98.3%
unpow298.3%
sqr-neg98.3%
rem-square-sqrt99.8%
sub-neg99.8%
remove-double-neg99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (* -0.0859375 (pow x 4.0)) (* 0.125 (pow x 2.0))))
(t_1 (/ 0.5 (hypot 1.0 x)))
(t_2 (/ (- 0.5 t_1) (+ 1.0 (sqrt (+ 0.5 t_1))))))
(if (<= x -0.0017)
t_2
(if (<= x -7e-60) t_0 (if (<= x 7e-60) 0.0 (if (<= x 0.0018) t_0 t_2))))))
double code(double x) {
double t_0 = (-0.0859375 * pow(x, 4.0)) + (0.125 * pow(x, 2.0));
double t_1 = 0.5 / hypot(1.0, x);
double t_2 = (0.5 - t_1) / (1.0 + sqrt((0.5 + t_1)));
double tmp;
if (x <= -0.0017) {
tmp = t_2;
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0018) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x) {
double t_0 = (-0.0859375 * Math.pow(x, 4.0)) + (0.125 * Math.pow(x, 2.0));
double t_1 = 0.5 / Math.hypot(1.0, x);
double t_2 = (0.5 - t_1) / (1.0 + Math.sqrt((0.5 + t_1)));
double tmp;
if (x <= -0.0017) {
tmp = t_2;
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0018) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
def code(x): t_0 = (-0.0859375 * math.pow(x, 4.0)) + (0.125 * math.pow(x, 2.0)) t_1 = 0.5 / math.hypot(1.0, x) t_2 = (0.5 - t_1) / (1.0 + math.sqrt((0.5 + t_1))) tmp = 0 if x <= -0.0017: tmp = t_2 elif x <= -7e-60: tmp = t_0 elif x <= 7e-60: tmp = 0.0 elif x <= 0.0018: tmp = t_0 else: tmp = t_2 return tmp
function code(x) t_0 = Float64(Float64(-0.0859375 * (x ^ 4.0)) + Float64(0.125 * (x ^ 2.0))) t_1 = Float64(0.5 / hypot(1.0, x)) t_2 = Float64(Float64(0.5 - t_1) / Float64(1.0 + sqrt(Float64(0.5 + t_1)))) tmp = 0.0 if (x <= -0.0017) tmp = t_2; elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0018) tmp = t_0; else tmp = t_2; end return tmp end
function tmp_2 = code(x) t_0 = (-0.0859375 * (x ^ 4.0)) + (0.125 * (x ^ 2.0)); t_1 = 0.5 / hypot(1.0, x); t_2 = (0.5 - t_1) / (1.0 + sqrt((0.5 + t_1))); tmp = 0.0; if (x <= -0.0017) tmp = t_2; elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0018) tmp = t_0; else tmp = t_2; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(0.5 - t$95$1), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0017], t$95$2, If[LessEqual[x, -7e-60], t$95$0, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.0018], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}\\
t_1 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
t_2 := \frac{0.5 - t\_1}{1 + \sqrt{0.5 + t\_1}}\\
\mathbf{if}\;x \leq -0.0017:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.0018:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if x < -0.00169999999999999991 or 0.0018 < 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%
if -0.00169999999999999991 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 0.0018Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 100.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (* -0.0859375 (pow x 4.0)) (* 0.125 (pow x 2.0))))
(t_1 (/ 0.5 (hypot 1.0 x)))
(t_2 (- 0.5 t_1))
(t_3 (+ 1.0 (sqrt (+ 0.5 t_1)))))
(if (<= x -0.0017)
(* t_2 (/ 1.0 t_3))
(if (<= x -7e-60)
t_0
(if (<= x 7e-60) 0.0 (if (<= x 0.0018) t_0 (/ t_2 t_3)))))))
double code(double x) {
double t_0 = (-0.0859375 * pow(x, 4.0)) + (0.125 * pow(x, 2.0));
double t_1 = 0.5 / hypot(1.0, x);
double t_2 = 0.5 - t_1;
double t_3 = 1.0 + sqrt((0.5 + t_1));
double tmp;
if (x <= -0.0017) {
tmp = t_2 * (1.0 / t_3);
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0018) {
tmp = t_0;
} else {
tmp = t_2 / t_3;
}
return tmp;
}
public static double code(double x) {
double t_0 = (-0.0859375 * Math.pow(x, 4.0)) + (0.125 * Math.pow(x, 2.0));
double t_1 = 0.5 / Math.hypot(1.0, x);
double t_2 = 0.5 - t_1;
double t_3 = 1.0 + Math.sqrt((0.5 + t_1));
double tmp;
if (x <= -0.0017) {
tmp = t_2 * (1.0 / t_3);
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.0018) {
tmp = t_0;
} else {
tmp = t_2 / t_3;
}
return tmp;
}
def code(x): t_0 = (-0.0859375 * math.pow(x, 4.0)) + (0.125 * math.pow(x, 2.0)) t_1 = 0.5 / math.hypot(1.0, x) t_2 = 0.5 - t_1 t_3 = 1.0 + math.sqrt((0.5 + t_1)) tmp = 0 if x <= -0.0017: tmp = t_2 * (1.0 / t_3) elif x <= -7e-60: tmp = t_0 elif x <= 7e-60: tmp = 0.0 elif x <= 0.0018: tmp = t_0 else: tmp = t_2 / t_3 return tmp
function code(x) t_0 = Float64(Float64(-0.0859375 * (x ^ 4.0)) + Float64(0.125 * (x ^ 2.0))) t_1 = Float64(0.5 / hypot(1.0, x)) t_2 = Float64(0.5 - t_1) t_3 = Float64(1.0 + sqrt(Float64(0.5 + t_1))) tmp = 0.0 if (x <= -0.0017) tmp = Float64(t_2 * Float64(1.0 / t_3)); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0018) tmp = t_0; else tmp = Float64(t_2 / t_3); end return tmp end
function tmp_2 = code(x) t_0 = (-0.0859375 * (x ^ 4.0)) + (0.125 * (x ^ 2.0)); t_1 = 0.5 / hypot(1.0, x); t_2 = 0.5 - t_1; t_3 = 1.0 + sqrt((0.5 + t_1)); tmp = 0.0; if (x <= -0.0017) tmp = t_2 * (1.0 / t_3); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.0018) tmp = t_0; else tmp = t_2 / t_3; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(0.5 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[Sqrt[N[(0.5 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.0017], N[(t$95$2 * N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -7e-60], t$95$0, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.0018], t$95$0, N[(t$95$2 / t$95$3), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}\\
t_1 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
t_2 := 0.5 - t\_1\\
t_3 := 1 + \sqrt{0.5 + t\_1}\\
\mathbf{if}\;x \leq -0.0017:\\
\;\;\;\;t\_2 \cdot \frac{1}{t\_3}\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.0018:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_3}\\
\end{array}
\end{array}
if x < -0.00169999999999999991Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
flip--98.3%
div-inv98.2%
metadata-eval98.2%
add-sqr-sqrt99.8%
associate--r+99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -0.00169999999999999991 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 0.0018Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 100.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
if 0.0018 < x Initial program 98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate-*r/98.2%
metadata-eval98.2%
Simplified98.2%
flip--98.3%
metadata-eval98.3%
add-sqr-sqrt99.8%
associate--r+99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Final simplification99.9%
(FPCore (x)
:precision binary64
(let* ((t_0 (- 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x))))))
(t_1 (+ (* -0.0859375 (pow x 4.0)) (* 0.125 (pow x 2.0)))))
(if (<= x -0.00295)
t_0
(if (<= x -7e-60) t_1 (if (<= x 7e-60) 0.0 (if (<= x 0.002) t_1 t_0))))))
double code(double x) {
double t_0 = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x))));
double t_1 = (-0.0859375 * pow(x, 4.0)) + (0.125 * pow(x, 2.0));
double tmp;
if (x <= -0.00295) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.002) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = 1.0 - Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x))));
double t_1 = (-0.0859375 * Math.pow(x, 4.0)) + (0.125 * Math.pow(x, 2.0));
double tmp;
if (x <= -0.00295) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.002) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 - math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))) t_1 = (-0.0859375 * math.pow(x, 4.0)) + (0.125 * math.pow(x, 2.0)) tmp = 0 if x <= -0.00295: tmp = t_0 elif x <= -7e-60: tmp = t_1 elif x <= 7e-60: tmp = 0.0 elif x <= 0.002: tmp = t_1 else: tmp = t_0 return tmp
function code(x) t_0 = Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))) t_1 = Float64(Float64(-0.0859375 * (x ^ 4.0)) + Float64(0.125 * (x ^ 2.0))) tmp = 0.0 if (x <= -0.00295) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.002) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x)))); t_1 = (-0.0859375 * (x ^ 4.0)) + (0.125 * (x ^ 2.0)); tmp = 0.0; if (x <= -0.00295) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.002) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.00295], t$95$0, If[LessEqual[x, -7e-60], t$95$1, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.002], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\\
t_1 := -0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -0.00295:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.002:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -0.00294999999999999993 or 2e-3 < x Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
if -0.00294999999999999993 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 2e-3Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 100.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.1%
(FPCore (x)
:precision binary64
(let* ((t_0 (- 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x))))))
(t_1 (* 0.125 (pow x 2.0))))
(if (<= x -0.00014)
t_0
(if (<= x -7e-60)
t_1
(if (<= x 7e-60) 0.0 (if (<= x 0.000125) t_1 t_0))))))
double code(double x) {
double t_0 = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x))));
double t_1 = 0.125 * pow(x, 2.0);
double tmp;
if (x <= -0.00014) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.000125) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x) {
double t_0 = 1.0 - Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x))));
double t_1 = 0.125 * Math.pow(x, 2.0);
double tmp;
if (x <= -0.00014) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 0.000125) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 - math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))) t_1 = 0.125 * math.pow(x, 2.0) tmp = 0 if x <= -0.00014: tmp = t_0 elif x <= -7e-60: tmp = t_1 elif x <= 7e-60: tmp = 0.0 elif x <= 0.000125: tmp = t_1 else: tmp = t_0 return tmp
function code(x) t_0 = Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))) t_1 = Float64(0.125 * (x ^ 2.0)) tmp = 0.0 if (x <= -0.00014) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.000125) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x)))); t_1 = 0.125 * (x ^ 2.0); tmp = 0.0; if (x <= -0.00014) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 0.000125) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.00014], t$95$0, If[LessEqual[x, -7e-60], t$95$1, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 0.000125], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\\
t_1 := 0.125 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -0.00014:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 0.000125:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.3999999999999999e-4 or 1.25e-4 < x Initial program 98.3%
distribute-lft-in98.3%
metadata-eval98.3%
associate-*r/98.3%
metadata-eval98.3%
Simplified98.3%
if -1.3999999999999999e-4 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 1.25e-4Initial program 5.8%
distribute-lft-in5.8%
metadata-eval5.8%
associate-*r/5.8%
metadata-eval5.8%
Simplified5.8%
Taylor expanded in x around 0 99.1%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification99.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (/ 0.5 (+ 1.0 (sqrt 0.5)))) (t_1 (* 0.125 (pow x 2.0))))
(if (<= x -1.5)
t_0
(if (<= x -7e-60) t_1 (if (<= x 7e-60) 0.0 (if (<= x 1.5) t_1 t_0))))))
double code(double x) {
double t_0 = 0.5 / (1.0 + sqrt(0.5));
double t_1 = 0.125 * pow(x, 2.0);
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_1;
} else {
tmp = 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 / (1.0d0 + sqrt(0.5d0))
t_1 = 0.125d0 * (x ** 2.0d0)
if (x <= (-1.5d0)) then
tmp = t_0
else if (x <= (-7d-60)) then
tmp = t_1
else if (x <= 7d-60) then
tmp = 0.0d0
else if (x <= 1.5d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 0.5 / (1.0 + Math.sqrt(0.5));
double t_1 = 0.125 * Math.pow(x, 2.0);
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = 0.5 / (1.0 + math.sqrt(0.5)) t_1 = 0.125 * math.pow(x, 2.0) tmp = 0 if x <= -1.5: tmp = t_0 elif x <= -7e-60: tmp = t_1 elif x <= 7e-60: tmp = 0.0 elif x <= 1.5: tmp = t_1 else: tmp = t_0 return tmp
function code(x) t_0 = Float64(0.5 / Float64(1.0 + sqrt(0.5))) t_1 = Float64(0.125 * (x ^ 2.0)) tmp = 0.0 if (x <= -1.5) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = 0.5 / (1.0 + sqrt(0.5)); t_1 = 0.125 * (x ^ 2.0); tmp = 0.0; if (x <= -1.5) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.5], t$95$0, If[LessEqual[x, -7e-60], t$95$1, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 1.5], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{1 + \sqrt{0.5}}\\
t_1 := 0.125 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.5:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5 or 1.5 < 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%
Taylor expanded in x around inf 98.2%
if -1.5 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 1.5Initial program 15.3%
distribute-lft-in15.3%
metadata-eval15.3%
associate-*r/15.3%
metadata-eval15.3%
Simplified15.3%
Taylor expanded in x around 0 90.9%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification98.2%
(FPCore (x)
:precision binary64
(let* ((t_0 (* 0.125 (pow x 2.0))))
(if (<= x -1.25)
(/ (- 0.5 (/ -0.5 x)) (+ 1.0 (sqrt (+ 0.5 (/ -0.5 x)))))
(if (<= x -7e-60)
t_0
(if (<= x 7e-60) 0.0 (if (<= x 1.5) t_0 (/ 0.5 (+ 1.0 (sqrt 0.5)))))))))
double code(double x) {
double t_0 = 0.125 * pow(x, 2.0);
double tmp;
if (x <= -1.25) {
tmp = (0.5 - (-0.5 / x)) / (1.0 + sqrt((0.5 + (-0.5 / x))));
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_0;
} else {
tmp = 0.5 / (1.0 + sqrt(0.5));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = 0.125d0 * (x ** 2.0d0)
if (x <= (-1.25d0)) then
tmp = (0.5d0 - ((-0.5d0) / x)) / (1.0d0 + sqrt((0.5d0 + ((-0.5d0) / x))))
else if (x <= (-7d-60)) then
tmp = t_0
else if (x <= 7d-60) then
tmp = 0.0d0
else if (x <= 1.5d0) then
tmp = t_0
else
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 0.125 * Math.pow(x, 2.0);
double tmp;
if (x <= -1.25) {
tmp = (0.5 - (-0.5 / x)) / (1.0 + Math.sqrt((0.5 + (-0.5 / x))));
} else if (x <= -7e-60) {
tmp = t_0;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_0;
} else {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
}
return tmp;
}
def code(x): t_0 = 0.125 * math.pow(x, 2.0) tmp = 0 if x <= -1.25: tmp = (0.5 - (-0.5 / x)) / (1.0 + math.sqrt((0.5 + (-0.5 / x)))) elif x <= -7e-60: tmp = t_0 elif x <= 7e-60: tmp = 0.0 elif x <= 1.5: tmp = t_0 else: tmp = 0.5 / (1.0 + math.sqrt(0.5)) return tmp
function code(x) t_0 = Float64(0.125 * (x ^ 2.0)) tmp = 0.0 if (x <= -1.25) tmp = Float64(Float64(0.5 - Float64(-0.5 / x)) / Float64(1.0 + sqrt(Float64(0.5 + Float64(-0.5 / x))))); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_0; else tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); end return tmp end
function tmp_2 = code(x) t_0 = 0.125 * (x ^ 2.0); tmp = 0.0; if (x <= -1.25) tmp = (0.5 - (-0.5 / x)) / (1.0 + sqrt((0.5 + (-0.5 / x)))); elseif (x <= -7e-60) tmp = t_0; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_0; else tmp = 0.5 / (1.0 + sqrt(0.5)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.25], 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], If[LessEqual[x, -7e-60], t$95$0, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 1.5], t$95$0, N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.125 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{0.5 - \frac{-0.5}{x}}{1 + \sqrt{0.5 + \frac{-0.5}{x}}}\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.5:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\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 97.6%
associate-*r/97.6%
metadata-eval97.6%
Simplified97.6%
flip--97.6%
metadata-eval97.6%
add-sqr-sqrt99.1%
sub-neg99.1%
associate--r+99.1%
metadata-eval99.1%
distribute-neg-frac99.1%
metadata-eval99.1%
sub-neg99.1%
distribute-neg-frac99.1%
metadata-eval99.1%
Applied egg-rr99.1%
if -1.25 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 1.5Initial program 15.3%
distribute-lft-in15.3%
metadata-eval15.3%
associate-*r/15.3%
metadata-eval15.3%
Simplified15.3%
Taylor expanded in x around 0 90.9%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
if 1.5 < 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%
Taylor expanded in x around inf 98.6%
Final simplification98.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (- 1.0 (sqrt 0.5))) (t_1 (* 0.125 (pow x 2.0))))
(if (<= x -1.5)
t_0
(if (<= x -7e-60) t_1 (if (<= x 7e-60) 0.0 (if (<= x 1.5) t_1 t_0))))))
double code(double x) {
double t_0 = 1.0 - sqrt(0.5);
double t_1 = 0.125 * pow(x, 2.0);
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_1;
} else {
tmp = 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 = 1.0d0 - sqrt(0.5d0)
t_1 = 0.125d0 * (x ** 2.0d0)
if (x <= (-1.5d0)) then
tmp = t_0
else if (x <= (-7d-60)) then
tmp = t_1
else if (x <= 7d-60) then
tmp = 0.0d0
else if (x <= 1.5d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x) {
double t_0 = 1.0 - Math.sqrt(0.5);
double t_1 = 0.125 * Math.pow(x, 2.0);
double tmp;
if (x <= -1.5) {
tmp = t_0;
} else if (x <= -7e-60) {
tmp = t_1;
} else if (x <= 7e-60) {
tmp = 0.0;
} else if (x <= 1.5) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x): t_0 = 1.0 - math.sqrt(0.5) t_1 = 0.125 * math.pow(x, 2.0) tmp = 0 if x <= -1.5: tmp = t_0 elif x <= -7e-60: tmp = t_1 elif x <= 7e-60: tmp = 0.0 elif x <= 1.5: tmp = t_1 else: tmp = t_0 return tmp
function code(x) t_0 = Float64(1.0 - sqrt(0.5)) t_1 = Float64(0.125 * (x ^ 2.0)) tmp = 0.0 if (x <= -1.5) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x) t_0 = 1.0 - sqrt(0.5); t_1 = 0.125 * (x ^ 2.0); tmp = 0.0; if (x <= -1.5) tmp = t_0; elseif (x <= -7e-60) tmp = t_1; elseif (x <= 7e-60) tmp = 0.0; elseif (x <= 1.5) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.5], t$95$0, If[LessEqual[x, -7e-60], t$95$1, If[LessEqual[x, 7e-60], 0.0, If[LessEqual[x, 1.5], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \sqrt{0.5}\\
t_1 := 0.125 \cdot {x}^{2}\\
\mathbf{if}\;x \leq -1.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{elif}\;x \leq 1.5:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.5 or 1.5 < 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%
if -1.5 < x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x < 1.5Initial program 15.3%
distribute-lft-in15.3%
metadata-eval15.3%
associate-*r/15.3%
metadata-eval15.3%
Simplified15.3%
Taylor expanded in x around 0 90.9%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification97.4%
(FPCore (x) :precision binary64 (if (or (<= x -7e-60) (not (<= x 7e-60))) (- 1.0 (sqrt 0.5)) 0.0))
double code(double x) {
double tmp;
if ((x <= -7e-60) || !(x <= 7e-60)) {
tmp = 1.0 - sqrt(0.5);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-7d-60)) .or. (.not. (x <= 7d-60))) then
tmp = 1.0d0 - sqrt(0.5d0)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -7e-60) || !(x <= 7e-60)) {
tmp = 1.0 - Math.sqrt(0.5);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -7e-60) or not (x <= 7e-60): tmp = 1.0 - math.sqrt(0.5) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if ((x <= -7e-60) || !(x <= 7e-60)) tmp = Float64(1.0 - sqrt(0.5)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -7e-60) || ~((x <= 7e-60))) tmp = 1.0 - sqrt(0.5); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -7e-60], N[Not[LessEqual[x, 7e-60]], $MachinePrecision]], N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-60} \lor \neg \left(x \leq 7 \cdot 10^{-60}\right):\\
\;\;\;\;1 - \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -6.99999999999999952e-60 or 6.99999999999999952e-60 < x Initial program 84.6%
distribute-lft-in84.6%
metadata-eval84.6%
associate-*r/84.6%
metadata-eval84.6%
Simplified84.6%
Taylor expanded in x around inf 82.0%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
Final simplification89.0%
(FPCore (x) :precision binary64 (if (or (<= x -1.0) (not (<= x 7e-60))) (* 0.5 (- 0.5 (/ -0.5 x))) 0.0))
double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 7e-60)) {
tmp = 0.5 * (0.5 - (-0.5 / x));
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-1.0d0)) .or. (.not. (x <= 7d-60))) then
tmp = 0.5d0 * (0.5d0 - ((-0.5d0) / x))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -1.0) || !(x <= 7e-60)) {
tmp = 0.5 * (0.5 - (-0.5 / x));
} else {
tmp = 0.0;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -1.0) or not (x <= 7e-60): tmp = 0.5 * (0.5 - (-0.5 / x)) else: tmp = 0.0 return tmp
function code(x) tmp = 0.0 if ((x <= -1.0) || !(x <= 7e-60)) tmp = Float64(0.5 * Float64(0.5 - Float64(-0.5 / x))); else tmp = 0.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -1.0) || ~((x <= 7e-60))) tmp = 0.5 * (0.5 - (-0.5 / x)); else tmp = 0.0; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -1.0], N[Not[LessEqual[x, 7e-60]], $MachinePrecision]], N[(0.5 * N[(0.5 - N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 7 \cdot 10^{-60}\right):\\
\;\;\;\;0.5 \cdot \left(0.5 - \frac{-0.5}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < -1 or 6.99999999999999952e-60 < x Initial program 90.0%
distribute-lft-in90.0%
metadata-eval90.0%
associate-*r/90.0%
metadata-eval90.0%
Simplified90.0%
flip--90.0%
div-inv90.0%
metadata-eval90.0%
add-sqr-sqrt91.5%
associate--r+91.4%
metadata-eval91.4%
Applied egg-rr91.4%
Taylor expanded in x around 0 21.3%
Taylor expanded in x around -inf 21.2%
if -1 < x < 6.99999999999999952e-60Initial program 91.4%
distribute-lft-in91.4%
metadata-eval91.4%
associate-*r/91.4%
metadata-eval91.4%
Simplified91.4%
flip--91.4%
div-inv91.4%
metadata-eval91.4%
add-sqr-sqrt91.4%
associate--r+91.5%
metadata-eval91.5%
Applied egg-rr91.5%
Taylor expanded in x around 0 91.0%
Taylor expanded in x around 0 90.4%
Final simplification51.2%
(FPCore (x) :precision binary64 (if (<= x -7e-60) (* 0.5 (- 0.5 (/ 0.5 x))) (if (<= x 7e-60) 0.0 (* 0.5 (- 0.5 (/ -0.5 x))))))
double code(double x) {
double tmp;
if (x <= -7e-60) {
tmp = 0.5 * (0.5 - (0.5 / x));
} else if (x <= 7e-60) {
tmp = 0.0;
} else {
tmp = 0.5 * (0.5 - (-0.5 / x));
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-7d-60)) then
tmp = 0.5d0 * (0.5d0 - (0.5d0 / x))
else if (x <= 7d-60) then
tmp = 0.0d0
else
tmp = 0.5d0 * (0.5d0 - ((-0.5d0) / x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -7e-60) {
tmp = 0.5 * (0.5 - (0.5 / x));
} else if (x <= 7e-60) {
tmp = 0.0;
} else {
tmp = 0.5 * (0.5 - (-0.5 / x));
}
return tmp;
}
def code(x): tmp = 0 if x <= -7e-60: tmp = 0.5 * (0.5 - (0.5 / x)) elif x <= 7e-60: tmp = 0.0 else: tmp = 0.5 * (0.5 - (-0.5 / x)) return tmp
function code(x) tmp = 0.0 if (x <= -7e-60) tmp = Float64(0.5 * Float64(0.5 - Float64(0.5 / x))); elseif (x <= 7e-60) tmp = 0.0; else tmp = Float64(0.5 * Float64(0.5 - Float64(-0.5 / x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -7e-60) tmp = 0.5 * (0.5 - (0.5 / x)); elseif (x <= 7e-60) tmp = 0.0; else tmp = 0.5 * (0.5 - (-0.5 / x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -7e-60], N[(0.5 * N[(0.5 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7e-60], 0.0, N[(0.5 * N[(0.5 - N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-60}:\\
\;\;\;\;0.5 \cdot \left(0.5 - \frac{0.5}{x}\right)\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-60}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(0.5 - \frac{-0.5}{x}\right)\\
\end{array}
\end{array}
if x < -6.99999999999999952e-60Initial program 86.5%
distribute-lft-in86.5%
metadata-eval86.5%
associate-*r/86.5%
metadata-eval86.5%
Simplified86.5%
flip--86.5%
div-inv86.4%
metadata-eval86.4%
add-sqr-sqrt87.8%
associate--r+87.9%
metadata-eval87.9%
Applied egg-rr87.9%
Taylor expanded in x around 0 20.8%
Taylor expanded in x around inf 20.6%
if -6.99999999999999952e-60 < x < 6.99999999999999952e-60Initial program 100.0%
distribute-lft-in100.0%
metadata-eval100.0%
associate-*r/100.0%
metadata-eval100.0%
Simplified100.0%
flip--100.0%
div-inv100.0%
metadata-eval100.0%
add-sqr-sqrt100.0%
associate--r+100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 100.0%
if 6.99999999999999952e-60 < x Initial program 82.8%
distribute-lft-in82.8%
metadata-eval82.8%
associate-*r/82.8%
metadata-eval82.8%
Simplified82.8%
flip--82.8%
div-inv82.8%
metadata-eval82.8%
add-sqr-sqrt84.2%
associate--r+84.1%
metadata-eval84.1%
Applied egg-rr84.1%
Taylor expanded in x around 0 20.1%
Taylor expanded in x around -inf 19.8%
Final simplification51.4%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 90.6%
distribute-lft-in90.6%
metadata-eval90.6%
associate-*r/90.6%
metadata-eval90.6%
Simplified90.6%
flip--90.6%
div-inv90.6%
metadata-eval90.6%
add-sqr-sqrt91.4%
associate--r+91.4%
metadata-eval91.4%
Applied egg-rr91.4%
Taylor expanded in x around 0 51.5%
Taylor expanded in x around 0 41.0%
Final simplification41.0%
herbie shell --seed 2024031
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))