
(FPCore (x y z t) :precision binary64 (+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
return (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((sqrt((x + 1.0d0)) - sqrt(x)) + (sqrt((y + 1.0d0)) - sqrt(y))) + (sqrt((z + 1.0d0)) - sqrt(z))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
return (((Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (Math.sqrt((y + 1.0)) - Math.sqrt(y))) + (Math.sqrt((z + 1.0)) - Math.sqrt(z))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t): return (((math.sqrt((x + 1.0)) - math.sqrt(x)) + (math.sqrt((y + 1.0)) - math.sqrt(y))) + (math.sqrt((z + 1.0)) - math.sqrt(z))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(sqrt(Float64(y + 1.0)) - sqrt(y))) + Float64(sqrt(Float64(z + 1.0)) - sqrt(z))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t))) end
function tmp = code(x, y, z, t) tmp = (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 23 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
return (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((sqrt((x + 1.0d0)) - sqrt(x)) + (sqrt((y + 1.0d0)) - sqrt(y))) + (sqrt((z + 1.0d0)) - sqrt(z))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
return (((Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (Math.sqrt((y + 1.0)) - Math.sqrt(y))) + (Math.sqrt((z + 1.0)) - Math.sqrt(z))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t): return (((math.sqrt((x + 1.0)) - math.sqrt(x)) + (math.sqrt((y + 1.0)) - math.sqrt(y))) + (math.sqrt((z + 1.0)) - math.sqrt(z))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(sqrt(Float64(y + 1.0)) - sqrt(y))) + Float64(sqrt(Float64(z + 1.0)) - sqrt(z))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t))) end
function tmp = code(x, y, z, t) tmp = (((sqrt((x + 1.0)) - sqrt(x)) + (sqrt((y + 1.0)) - sqrt(y))) + (sqrt((z + 1.0)) - sqrt(z))) + (sqrt((t + 1.0)) - sqrt(t)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\sqrt{x + 1} - \sqrt{x}\right) + \left(\sqrt{y + 1} - \sqrt{y}\right)\right) + \left(\sqrt{z + 1} - \sqrt{z}\right)\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (sqrt (+ 1.0 t)))
(t_4 (- t_3 (sqrt t)))
(t_5 (sqrt (+ 1.0 z)))
(t_6 (- t_5 (sqrt z)))
(t_7 (- t_1 (sqrt x)))
(t_8 (+ t_4 (+ (+ t_7 (- t_2 (sqrt y))) t_6))))
(if (<= t_8 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_8 1.002)
(+ t_4 (+ t_6 (fma 0.5 (sqrt (/ 1.0 y)) t_7)))
(if (<= t_8 3.0)
(-
(+ (+ 1.0 t_2) (fma x 0.5 (/ 1.0 (+ (sqrt z) t_5))))
(+ (sqrt x) (sqrt y)))
(+
(+
(+ t_1 t_5)
(- 1.0 (+ (sqrt x) (+ (sqrt z) (+ (sqrt y) (sqrt t))))))
t_3))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = sqrt((1.0 + t));
double t_4 = t_3 - sqrt(t);
double t_5 = sqrt((1.0 + z));
double t_6 = t_5 - sqrt(z);
double t_7 = t_1 - sqrt(x);
double t_8 = t_4 + ((t_7 + (t_2 - sqrt(y))) + t_6);
double tmp;
if (t_8 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_8 <= 1.002) {
tmp = t_4 + (t_6 + fma(0.5, sqrt((1.0 / y)), t_7));
} else if (t_8 <= 3.0) {
tmp = ((1.0 + t_2) + fma(x, 0.5, (1.0 / (sqrt(z) + t_5)))) - (sqrt(x) + sqrt(y));
} else {
tmp = ((t_1 + t_5) + (1.0 - (sqrt(x) + (sqrt(z) + (sqrt(y) + sqrt(t)))))) + t_3;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = sqrt(Float64(1.0 + t)) t_4 = Float64(t_3 - sqrt(t)) t_5 = sqrt(Float64(1.0 + z)) t_6 = Float64(t_5 - sqrt(z)) t_7 = Float64(t_1 - sqrt(x)) t_8 = Float64(t_4 + Float64(Float64(t_7 + Float64(t_2 - sqrt(y))) + t_6)) tmp = 0.0 if (t_8 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_8 <= 1.002) tmp = Float64(t_4 + Float64(t_6 + fma(0.5, sqrt(Float64(1.0 / y)), t_7))); elseif (t_8 <= 3.0) tmp = Float64(Float64(Float64(1.0 + t_2) + fma(x, 0.5, Float64(1.0 / Float64(sqrt(z) + t_5)))) - Float64(sqrt(x) + sqrt(y))); else tmp = Float64(Float64(Float64(t_1 + t_5) + Float64(1.0 - Float64(sqrt(x) + Float64(sqrt(z) + Float64(sqrt(y) + sqrt(t)))))) + t_3); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$5 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$8 = N[(t$95$4 + N[(N[(t$95$7 + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$6), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$8, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$8, 1.002], N[(t$95$4 + N[(t$95$6 + N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$7), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$8, 3.0], N[(N[(N[(1.0 + t$95$2), $MachinePrecision] + N[(x * 0.5 + N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 + t$95$5), $MachinePrecision] + N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[z], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \sqrt{1 + t}\\
t_4 := t\_3 - \sqrt{t}\\
t_5 := \sqrt{1 + z}\\
t_6 := t\_5 - \sqrt{z}\\
t_7 := t\_1 - \sqrt{x}\\
t_8 := t\_4 + \left(\left(t\_7 + \left(t\_2 - \sqrt{y}\right)\right) + t\_6\right)\\
\mathbf{if}\;t\_8 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_8 \leq 1.002:\\
\;\;\;\;t\_4 + \left(t\_6 + \mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_7\right)\right)\\
\mathbf{elif}\;t\_8 \leq 3:\\
\;\;\;\;\left(\left(1 + t\_2\right) + \mathsf{fma}\left(x, 0.5, \frac{1}{\sqrt{z} + t\_5}\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(t\_1 + t\_5\right) + \left(1 - \left(\sqrt{x} + \left(\sqrt{z} + \left(\sqrt{y} + \sqrt{t}\right)\right)\right)\right)\right) + t\_3\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
Taylor expanded in y around inf
+-commutativeN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6469.1
Simplified69.1%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 3Initial program 96.8%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.6
Applied egg-rr97.6%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6428.0
Simplified28.0%
Taylor expanded in x around 0
--lowering--.f64N/A
Simplified24.1%
if 3 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.7%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
Simplified90.7%
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
+-lowering-+.f64N/A
Applied egg-rr90.7%
Final simplification42.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (sqrt (+ 1.0 t)))
(t_4 (sqrt (+ 1.0 z)))
(t_5 (/ 1.0 (+ (sqrt z) t_4)))
(t_6 (- t_1 (sqrt x)))
(t_7
(+ (- t_3 (sqrt t)) (+ (+ t_6 (- t_2 (sqrt y))) (- t_4 (sqrt z))))))
(if (<= t_7 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_7 1.002)
(+ t_6 (fma 0.5 (sqrt (/ 1.0 y)) t_5))
(if (<= t_7 3.0)
(- (+ (+ 1.0 t_2) (fma x 0.5 t_5)) (+ (sqrt x) (sqrt y)))
(+
(+
(+ t_1 t_4)
(- 1.0 (+ (sqrt x) (+ (sqrt z) (+ (sqrt y) (sqrt t))))))
t_3))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = sqrt((1.0 + t));
double t_4 = sqrt((1.0 + z));
double t_5 = 1.0 / (sqrt(z) + t_4);
double t_6 = t_1 - sqrt(x);
double t_7 = (t_3 - sqrt(t)) + ((t_6 + (t_2 - sqrt(y))) + (t_4 - sqrt(z)));
double tmp;
if (t_7 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_7 <= 1.002) {
tmp = t_6 + fma(0.5, sqrt((1.0 / y)), t_5);
} else if (t_7 <= 3.0) {
tmp = ((1.0 + t_2) + fma(x, 0.5, t_5)) - (sqrt(x) + sqrt(y));
} else {
tmp = ((t_1 + t_4) + (1.0 - (sqrt(x) + (sqrt(z) + (sqrt(y) + sqrt(t)))))) + t_3;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = sqrt(Float64(1.0 + t)) t_4 = sqrt(Float64(1.0 + z)) t_5 = Float64(1.0 / Float64(sqrt(z) + t_4)) t_6 = Float64(t_1 - sqrt(x)) t_7 = Float64(Float64(t_3 - sqrt(t)) + Float64(Float64(t_6 + Float64(t_2 - sqrt(y))) + Float64(t_4 - sqrt(z)))) tmp = 0.0 if (t_7 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_7 <= 1.002) tmp = Float64(t_6 + fma(0.5, sqrt(Float64(1.0 / y)), t_5)); elseif (t_7 <= 3.0) tmp = Float64(Float64(Float64(1.0 + t_2) + fma(x, 0.5, t_5)) - Float64(sqrt(x) + sqrt(y))); else tmp = Float64(Float64(Float64(t_1 + t_4) + Float64(1.0 - Float64(sqrt(x) + Float64(sqrt(z) + Float64(sqrt(y) + sqrt(t)))))) + t_3); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(N[(t$95$3 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$6 + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$7, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 1.002], N[(t$95$6 + N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 3.0], N[(N[(N[(1.0 + t$95$2), $MachinePrecision] + N[(x * 0.5 + t$95$5), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 + t$95$4), $MachinePrecision] + N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[z], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \sqrt{1 + t}\\
t_4 := \sqrt{1 + z}\\
t_5 := \frac{1}{\sqrt{z} + t\_4}\\
t_6 := t\_1 - \sqrt{x}\\
t_7 := \left(t\_3 - \sqrt{t}\right) + \left(\left(t\_6 + \left(t\_2 - \sqrt{y}\right)\right) + \left(t\_4 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_7 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_7 \leq 1.002:\\
\;\;\;\;t\_6 + \mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_5\right)\\
\mathbf{elif}\;t\_7 \leq 3:\\
\;\;\;\;\left(\left(1 + t\_2\right) + \mathsf{fma}\left(x, 0.5, t\_5\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(t\_1 + t\_4\right) + \left(1 - \left(\sqrt{x} + \left(\sqrt{z} + \left(\sqrt{y} + \sqrt{t}\right)\right)\right)\right)\right) + t\_3\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6493.2
Applied egg-rr93.2%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.6
Simplified29.6%
Taylor expanded in y around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6457.7
Simplified57.7%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 3Initial program 96.8%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.6
Applied egg-rr97.6%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6428.0
Simplified28.0%
Taylor expanded in x around 0
--lowering--.f64N/A
Simplified24.1%
if 3 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.7%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
Simplified90.7%
associate-+l+N/A
+-commutativeN/A
+-commutativeN/A
+-lowering-+.f64N/A
Applied egg-rr90.7%
Final simplification39.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ 1.0 y)))
(t_2 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_3 (sqrt (+ 1.0 z)))
(t_4 (/ 1.0 (+ (sqrt z) t_3)))
(t_5 (- (sqrt (+ x 1.0)) (sqrt x)))
(t_6 (+ t_2 (+ (+ t_5 (- t_1 (sqrt y))) (- t_3 (sqrt z))))))
(if (<= t_6 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 1.002)
(+ t_5 (fma 0.5 (sqrt (/ 1.0 y)) t_4))
(if (<= t_6 2.99)
(- (+ (+ 1.0 t_1) (fma x 0.5 t_4)) (+ (sqrt x) (sqrt y)))
(+
t_2
(+ 1.0 (+ t_1 (- t_3 (+ (sqrt x) (+ (sqrt y) (sqrt z))))))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + y));
double t_2 = sqrt((1.0 + t)) - sqrt(t);
double t_3 = sqrt((1.0 + z));
double t_4 = 1.0 / (sqrt(z) + t_3);
double t_5 = sqrt((x + 1.0)) - sqrt(x);
double t_6 = t_2 + ((t_5 + (t_1 - sqrt(y))) + (t_3 - sqrt(z)));
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 1.002) {
tmp = t_5 + fma(0.5, sqrt((1.0 / y)), t_4);
} else if (t_6 <= 2.99) {
tmp = ((1.0 + t_1) + fma(x, 0.5, t_4)) - (sqrt(x) + sqrt(y));
} else {
tmp = t_2 + (1.0 + (t_1 + (t_3 - (sqrt(x) + (sqrt(y) + sqrt(z))))));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + y)) t_2 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_3 = sqrt(Float64(1.0 + z)) t_4 = Float64(1.0 / Float64(sqrt(z) + t_3)) t_5 = Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) t_6 = Float64(t_2 + Float64(Float64(t_5 + Float64(t_1 - sqrt(y))) + Float64(t_3 - sqrt(z)))) tmp = 0.0 if (t_6 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 1.002) tmp = Float64(t_5 + fma(0.5, sqrt(Float64(1.0 / y)), t_4)); elseif (t_6 <= 2.99) tmp = Float64(Float64(Float64(1.0 + t_1) + fma(x, 0.5, t_4)) - Float64(sqrt(x) + sqrt(y))); else tmp = Float64(t_2 + Float64(1.0 + Float64(t_1 + Float64(t_3 - Float64(sqrt(x) + Float64(sqrt(y) + sqrt(z))))))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$2 + N[(N[(t$95$5 + N[(t$95$1 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 1.002], N[(t$95$5 + N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.99], N[(N[(N[(1.0 + t$95$1), $MachinePrecision] + N[(x * 0.5 + t$95$4), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 + N[(1.0 + N[(t$95$1 + N[(t$95$3 - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + y}\\
t_2 := \sqrt{1 + t} - \sqrt{t}\\
t_3 := \sqrt{1 + z}\\
t_4 := \frac{1}{\sqrt{z} + t\_3}\\
t_5 := \sqrt{x + 1} - \sqrt{x}\\
t_6 := t\_2 + \left(\left(t\_5 + \left(t\_1 - \sqrt{y}\right)\right) + \left(t\_3 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_6 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 1.002:\\
\;\;\;\;t\_5 + \mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_4\right)\\
\mathbf{elif}\;t\_6 \leq 2.99:\\
\;\;\;\;\left(\left(1 + t\_1\right) + \mathsf{fma}\left(x, 0.5, t\_4\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 + \left(1 + \left(t\_1 + \left(t\_3 - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6493.2
Applied egg-rr93.2%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.6
Simplified29.6%
Taylor expanded in y around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6457.7
Simplified57.7%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.9900000000000002Initial program 95.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6496.7
Applied egg-rr96.7%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6427.0
Simplified27.0%
Taylor expanded in x around 0
--lowering--.f64N/A
Simplified22.8%
if 2.9900000000000002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.9%
Taylor expanded in x around 0
associate--l+N/A
+-lowering-+.f64N/A
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6469.1
Simplified69.1%
Final simplification46.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ 1.0 y)))
(t_2 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_3 (sqrt (+ 1.0 z)))
(t_4 (- t_3 (sqrt z)))
(t_5 (/ 1.0 (+ (sqrt z) t_3)))
(t_6 (- (sqrt (+ x 1.0)) (sqrt x)))
(t_7 (+ t_2 (+ (+ t_6 (- t_1 (sqrt y))) t_4))))
(if (<= t_7 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_7 1.002)
(+ t_6 (fma 0.5 (sqrt (/ 1.0 y)) t_5))
(if (<= t_7 2.9995)
(- (+ (+ 1.0 t_1) (fma x 0.5 t_5)) (+ (sqrt x) (sqrt y)))
(+ t_2 (+ t_4 (- (fma x 0.5 2.0) (sqrt y)))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + y));
double t_2 = sqrt((1.0 + t)) - sqrt(t);
double t_3 = sqrt((1.0 + z));
double t_4 = t_3 - sqrt(z);
double t_5 = 1.0 / (sqrt(z) + t_3);
double t_6 = sqrt((x + 1.0)) - sqrt(x);
double t_7 = t_2 + ((t_6 + (t_1 - sqrt(y))) + t_4);
double tmp;
if (t_7 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_7 <= 1.002) {
tmp = t_6 + fma(0.5, sqrt((1.0 / y)), t_5);
} else if (t_7 <= 2.9995) {
tmp = ((1.0 + t_1) + fma(x, 0.5, t_5)) - (sqrt(x) + sqrt(y));
} else {
tmp = t_2 + (t_4 + (fma(x, 0.5, 2.0) - sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + y)) t_2 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_3 = sqrt(Float64(1.0 + z)) t_4 = Float64(t_3 - sqrt(z)) t_5 = Float64(1.0 / Float64(sqrt(z) + t_3)) t_6 = Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) t_7 = Float64(t_2 + Float64(Float64(t_6 + Float64(t_1 - sqrt(y))) + t_4)) tmp = 0.0 if (t_7 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_7 <= 1.002) tmp = Float64(t_6 + fma(0.5, sqrt(Float64(1.0 / y)), t_5)); elseif (t_7 <= 2.9995) tmp = Float64(Float64(Float64(1.0 + t_1) + fma(x, 0.5, t_5)) - Float64(sqrt(x) + sqrt(y))); else tmp = Float64(t_2 + Float64(t_4 + Float64(fma(x, 0.5, 2.0) - sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$7 = N[(t$95$2 + N[(N[(t$95$6 + N[(t$95$1 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$7, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 1.002], N[(t$95$6 + N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 2.9995], N[(N[(N[(1.0 + t$95$1), $MachinePrecision] + N[(x * 0.5 + t$95$5), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 + N[(t$95$4 + N[(N[(x * 0.5 + 2.0), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + y}\\
t_2 := \sqrt{1 + t} - \sqrt{t}\\
t_3 := \sqrt{1 + z}\\
t_4 := t\_3 - \sqrt{z}\\
t_5 := \frac{1}{\sqrt{z} + t\_3}\\
t_6 := \sqrt{x + 1} - \sqrt{x}\\
t_7 := t\_2 + \left(\left(t\_6 + \left(t\_1 - \sqrt{y}\right)\right) + t\_4\right)\\
\mathbf{if}\;t\_7 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_7 \leq 1.002:\\
\;\;\;\;t\_6 + \mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_5\right)\\
\mathbf{elif}\;t\_7 \leq 2.9995:\\
\;\;\;\;\left(\left(1 + t\_1\right) + \mathsf{fma}\left(x, 0.5, t\_5\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 + \left(t\_4 + \left(\mathsf{fma}\left(x, 0.5, 2\right) - \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6493.2
Applied egg-rr93.2%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.6
Simplified29.6%
Taylor expanded in y around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6457.7
Simplified57.7%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.99949999999999983Initial program 95.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6496.7
Applied egg-rr96.7%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6426.9
Simplified26.9%
Taylor expanded in x around 0
--lowering--.f64N/A
Simplified22.8%
if 2.99949999999999983 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6484.8
Simplified84.8%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6465.7
Simplified65.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6463.9
Simplified63.9%
Final simplification45.1%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_4 (sqrt (+ 1.0 z)))
(t_5 (- t_4 (sqrt z)))
(t_6 (+ t_3 (+ (+ (- t_1 (sqrt x)) (- t_2 (sqrt y))) t_5))))
(if (<= t_6 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 1.002)
(+ t_3 (- (fma 0.5 (sqrt (/ 1.0 y)) t_1) (sqrt x)))
(if (<= t_6 2.9995)
(-
(+ (+ 1.0 t_2) (fma x 0.5 (/ 1.0 (+ (sqrt z) t_4))))
(+ (sqrt x) (sqrt y)))
(+ t_3 (+ t_5 (- (fma x 0.5 2.0) (sqrt y)))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = sqrt((1.0 + t)) - sqrt(t);
double t_4 = sqrt((1.0 + z));
double t_5 = t_4 - sqrt(z);
double t_6 = t_3 + (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) + t_5);
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 1.002) {
tmp = t_3 + (fma(0.5, sqrt((1.0 / y)), t_1) - sqrt(x));
} else if (t_6 <= 2.9995) {
tmp = ((1.0 + t_2) + fma(x, 0.5, (1.0 / (sqrt(z) + t_4)))) - (sqrt(x) + sqrt(y));
} else {
tmp = t_3 + (t_5 + (fma(x, 0.5, 2.0) - sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_4 = sqrt(Float64(1.0 + z)) t_5 = Float64(t_4 - sqrt(z)) t_6 = Float64(t_3 + Float64(Float64(Float64(t_1 - sqrt(x)) + Float64(t_2 - sqrt(y))) + t_5)) tmp = 0.0 if (t_6 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 1.002) tmp = Float64(t_3 + Float64(fma(0.5, sqrt(Float64(1.0 / y)), t_1) - sqrt(x))); elseif (t_6 <= 2.9995) tmp = Float64(Float64(Float64(1.0 + t_2) + fma(x, 0.5, Float64(1.0 / Float64(sqrt(z) + t_4)))) - Float64(sqrt(x) + sqrt(y))); else tmp = Float64(t_3 + Float64(t_5 + Float64(fma(x, 0.5, 2.0) - sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 1.002], N[(t$95$3 + N[(N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.9995], N[(N[(N[(1.0 + t$95$2), $MachinePrecision] + N[(x * 0.5 + N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 + N[(t$95$5 + N[(N[(x * 0.5 + 2.0), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \sqrt{1 + t} - \sqrt{t}\\
t_4 := \sqrt{1 + z}\\
t_5 := t\_4 - \sqrt{z}\\
t_6 := t\_3 + \left(\left(\left(t\_1 - \sqrt{x}\right) + \left(t\_2 - \sqrt{y}\right)\right) + t\_5\right)\\
\mathbf{if}\;t\_6 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 1.002:\\
\;\;\;\;t\_3 + \left(\mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_1\right) - \sqrt{x}\right)\\
\mathbf{elif}\;t\_6 \leq 2.9995:\\
\;\;\;\;\left(\left(1 + t\_2\right) + \mathsf{fma}\left(x, 0.5, \frac{1}{\sqrt{z} + t\_4}\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3 + \left(t\_5 + \left(\mathsf{fma}\left(x, 0.5, 2\right) - \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6417.2
Simplified17.2%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6439.6
Simplified39.6%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.99949999999999983Initial program 95.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6496.7
Applied egg-rr96.7%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6426.9
Simplified26.9%
Taylor expanded in x around 0
--lowering--.f64N/A
Simplified22.8%
if 2.99949999999999983 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6484.8
Simplified84.8%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6465.7
Simplified65.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6463.9
Simplified63.9%
Final simplification41.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_4 (sqrt (+ 1.0 z)))
(t_5 (- t_4 (sqrt z)))
(t_6 (+ t_3 (+ (+ (- t_1 (sqrt x)) (- t_2 (sqrt y))) t_5))))
(if (<= t_6 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 1.002)
(+ t_3 (- (fma 0.5 (sqrt (/ 1.0 y)) t_1) (sqrt x)))
(if (<= t_6 2.9995)
(+ t_1 (- (+ t_2 (/ 1.0 (+ (sqrt z) t_4))) (sqrt y)))
(+ t_3 (+ t_5 (- (fma x 0.5 2.0) (sqrt y)))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = sqrt((1.0 + t)) - sqrt(t);
double t_4 = sqrt((1.0 + z));
double t_5 = t_4 - sqrt(z);
double t_6 = t_3 + (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) + t_5);
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 1.002) {
tmp = t_3 + (fma(0.5, sqrt((1.0 / y)), t_1) - sqrt(x));
} else if (t_6 <= 2.9995) {
tmp = t_1 + ((t_2 + (1.0 / (sqrt(z) + t_4))) - sqrt(y));
} else {
tmp = t_3 + (t_5 + (fma(x, 0.5, 2.0) - sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_4 = sqrt(Float64(1.0 + z)) t_5 = Float64(t_4 - sqrt(z)) t_6 = Float64(t_3 + Float64(Float64(Float64(t_1 - sqrt(x)) + Float64(t_2 - sqrt(y))) + t_5)) tmp = 0.0 if (t_6 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 1.002) tmp = Float64(t_3 + Float64(fma(0.5, sqrt(Float64(1.0 / y)), t_1) - sqrt(x))); elseif (t_6 <= 2.9995) tmp = Float64(t_1 + Float64(Float64(t_2 + Float64(1.0 / Float64(sqrt(z) + t_4))) - sqrt(y))); else tmp = Float64(t_3 + Float64(t_5 + Float64(fma(x, 0.5, 2.0) - sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 1.002], N[(t$95$3 + N[(N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision] + t$95$1), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.9995], N[(t$95$1 + N[(N[(t$95$2 + N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 + N[(t$95$5 + N[(N[(x * 0.5 + 2.0), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \sqrt{1 + t} - \sqrt{t}\\
t_4 := \sqrt{1 + z}\\
t_5 := t\_4 - \sqrt{z}\\
t_6 := t\_3 + \left(\left(\left(t\_1 - \sqrt{x}\right) + \left(t\_2 - \sqrt{y}\right)\right) + t\_5\right)\\
\mathbf{if}\;t\_6 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 1.002:\\
\;\;\;\;t\_3 + \left(\mathsf{fma}\left(0.5, \sqrt{\frac{1}{y}}, t\_1\right) - \sqrt{x}\right)\\
\mathbf{elif}\;t\_6 \leq 2.9995:\\
\;\;\;\;t\_1 + \left(\left(t\_2 + \frac{1}{\sqrt{z} + t\_4}\right) - \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3 + \left(t\_5 + \left(\mathsf{fma}\left(x, 0.5, 2\right) - \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 92.9%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6417.2
Simplified17.2%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6439.6
Simplified39.6%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.99949999999999983Initial program 95.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6496.7
Applied egg-rr96.7%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6426.9
Simplified26.9%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6428.1
Simplified28.1%
if 2.99949999999999983 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6484.8
Simplified84.8%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6465.7
Simplified65.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6463.9
Simplified63.9%
Final simplification43.5%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_4 (sqrt (+ 1.0 z)))
(t_5 (- t_4 (sqrt z)))
(t_6 (+ t_3 (+ (+ (- t_1 (sqrt x)) (- t_2 (sqrt y))) t_5))))
(if (<= t_6 0.2)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 1.002)
(fma 0.5 (+ x (sqrt (/ 1.0 y))) (- 1.0 (sqrt x)))
(if (<= t_6 2.9995)
(+ t_1 (- (+ t_2 (/ 1.0 (+ (sqrt z) t_4))) (sqrt y)))
(+ t_3 (+ t_5 (- (fma x 0.5 2.0) (sqrt y)))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = sqrt((1.0 + t)) - sqrt(t);
double t_4 = sqrt((1.0 + z));
double t_5 = t_4 - sqrt(z);
double t_6 = t_3 + (((t_1 - sqrt(x)) + (t_2 - sqrt(y))) + t_5);
double tmp;
if (t_6 <= 0.2) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 1.002) {
tmp = fma(0.5, (x + sqrt((1.0 / y))), (1.0 - sqrt(x)));
} else if (t_6 <= 2.9995) {
tmp = t_1 + ((t_2 + (1.0 / (sqrt(z) + t_4))) - sqrt(y));
} else {
tmp = t_3 + (t_5 + (fma(x, 0.5, 2.0) - sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_4 = sqrt(Float64(1.0 + z)) t_5 = Float64(t_4 - sqrt(z)) t_6 = Float64(t_3 + Float64(Float64(Float64(t_1 - sqrt(x)) + Float64(t_2 - sqrt(y))) + t_5)) tmp = 0.0 if (t_6 <= 0.2) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 1.002) tmp = fma(0.5, Float64(x + sqrt(Float64(1.0 / y))), Float64(1.0 - sqrt(x))); elseif (t_6 <= 2.9995) tmp = Float64(t_1 + Float64(Float64(t_2 + Float64(1.0 / Float64(sqrt(z) + t_4))) - sqrt(y))); else tmp = Float64(t_3 + Float64(t_5 + Float64(fma(x, 0.5, 2.0) - sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 0.2], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 1.002], N[(0.5 * N[(x + N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.9995], N[(t$95$1 + N[(N[(t$95$2 + N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 + N[(t$95$5 + N[(N[(x * 0.5 + 2.0), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \sqrt{1 + t} - \sqrt{t}\\
t_4 := \sqrt{1 + z}\\
t_5 := t\_4 - \sqrt{z}\\
t_6 := t\_3 + \left(\left(\left(t\_1 - \sqrt{x}\right) + \left(t\_2 - \sqrt{y}\right)\right) + t\_5\right)\\
\mathbf{if}\;t\_6 \leq 0.2:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 1.002:\\
\;\;\;\;\mathsf{fma}\left(0.5, x + \sqrt{\frac{1}{y}}, 1 - \sqrt{x}\right)\\
\mathbf{elif}\;t\_6 \leq 2.9995:\\
\;\;\;\;t\_1 + \left(\left(t\_2 + \frac{1}{\sqrt{z} + t\_4}\right) - \sqrt{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3 + \left(t\_5 + \left(\mathsf{fma}\left(x, 0.5, 2\right) - \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 0.20000000000000001Initial program 19.5%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified9.5%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6436.4
Simplified36.4%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6457.0
Simplified57.0%
if 0.20000000000000001 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.002Initial program 93.1%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6430.1
Simplified30.1%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
distribute-lft-outN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6430.5
Simplified30.5%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6430.5
Simplified30.5%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6430.2
Simplified30.2%
if 1.002 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.99949999999999983Initial program 95.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6496.7
Applied egg-rr96.7%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6426.9
Simplified26.9%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6428.1
Simplified28.1%
if 2.99949999999999983 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6484.8
Simplified84.8%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6465.7
Simplified65.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6463.9
Simplified63.9%
Final simplification41.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- t_2 (sqrt y)))
(t_4 (sqrt (+ 1.0 t)))
(t_5 (sqrt (+ 1.0 z)))
(t_6
(+ (- t_4 (sqrt t)) (+ (+ (- t_1 (sqrt x)) t_3) (- t_5 (sqrt z))))))
(if (<= t_6 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 2.0)
(+ t_1 (- t_3 (sqrt x)))
(if (<= t_6 3.0)
(- (+ t_5 (+ 1.0 t_2)) (+ (sqrt x) (+ (sqrt y) (sqrt z))))
(+
(fma x 0.5 t_4)
(- 3.0 (+ (sqrt z) (+ (sqrt t) (+ (sqrt x) (sqrt y)))))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = t_2 - sqrt(y);
double t_4 = sqrt((1.0 + t));
double t_5 = sqrt((1.0 + z));
double t_6 = (t_4 - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_5 - sqrt(z)));
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 2.0) {
tmp = t_1 + (t_3 - sqrt(x));
} else if (t_6 <= 3.0) {
tmp = (t_5 + (1.0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)));
} else {
tmp = fma(x, 0.5, t_4) + (3.0 - (sqrt(z) + (sqrt(t) + (sqrt(x) + sqrt(y)))));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(t_2 - sqrt(y)) t_4 = sqrt(Float64(1.0 + t)) t_5 = sqrt(Float64(1.0 + z)) t_6 = Float64(Float64(t_4 - sqrt(t)) + Float64(Float64(Float64(t_1 - sqrt(x)) + t_3) + Float64(t_5 - sqrt(z)))) tmp = 0.0 if (t_6 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 2.0) tmp = Float64(t_1 + Float64(t_3 - sqrt(x))); elseif (t_6 <= 3.0) tmp = Float64(Float64(t_5 + Float64(1.0 + t_2)) - Float64(sqrt(x) + Float64(sqrt(y) + sqrt(z)))); else tmp = Float64(fma(x, 0.5, t_4) + Float64(3.0 - Float64(sqrt(z) + Float64(sqrt(t) + Float64(sqrt(x) + sqrt(y)))))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(N[(t$95$4 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] + N[(t$95$5 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.0], N[(t$95$1 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 3.0], N[(N[(t$95$5 + N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5 + t$95$4), $MachinePrecision] + N[(3.0 - N[(N[Sqrt[z], $MachinePrecision] + N[(N[Sqrt[t], $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := t\_2 - \sqrt{y}\\
t_4 := \sqrt{1 + t}\\
t_5 := \sqrt{1 + z}\\
t_6 := \left(t\_4 - \sqrt{t}\right) + \left(\left(\left(t\_1 - \sqrt{x}\right) + t\_3\right) + \left(t\_5 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_6 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 2:\\
\;\;\;\;t\_1 + \left(t\_3 - \sqrt{x}\right)\\
\mathbf{elif}\;t\_6 \leq 3:\\
\;\;\;\;\left(t\_5 + \left(1 + t\_2\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5, t\_4\right) + \left(3 - \left(\sqrt{z} + \left(\sqrt{t} + \left(\sqrt{x} + \sqrt{y}\right)\right)\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2Initial program 96.1%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.0
Simplified23.0%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6425.7
Simplified25.7%
if 2 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 3Initial program 95.4%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6424.6
Simplified24.6%
Taylor expanded in x around 0
--lowering--.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6419.6
Simplified19.6%
if 3 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6497.7
Simplified97.7%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6490.6
Simplified90.6%
Taylor expanded in z around 0
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
associate-+r+N/A
associate-+r+N/A
+-lowering-+.f64N/A
Simplified86.3%
Final simplification31.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (+ (sqrt y) (sqrt z)))
(t_3 (sqrt (+ 1.0 y)))
(t_4 (- t_3 (sqrt y)))
(t_5 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_6 (sqrt (+ 1.0 z)))
(t_7 (+ t_5 (+ (+ (- t_1 (sqrt x)) t_4) (- t_6 (sqrt z))))))
(if (<= t_7 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_7 2.0)
(+ t_1 (- t_4 (sqrt x)))
(if (<= t_7 2.99998)
(- (+ t_6 (+ 1.0 t_3)) (+ (sqrt x) t_2))
(+ t_5 (- (fma x 0.5 (- 3.0 (sqrt x))) t_2)))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt(y) + sqrt(z);
double t_3 = sqrt((1.0 + y));
double t_4 = t_3 - sqrt(y);
double t_5 = sqrt((1.0 + t)) - sqrt(t);
double t_6 = sqrt((1.0 + z));
double t_7 = t_5 + (((t_1 - sqrt(x)) + t_4) + (t_6 - sqrt(z)));
double tmp;
if (t_7 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_7 <= 2.0) {
tmp = t_1 + (t_4 - sqrt(x));
} else if (t_7 <= 2.99998) {
tmp = (t_6 + (1.0 + t_3)) - (sqrt(x) + t_2);
} else {
tmp = t_5 + (fma(x, 0.5, (3.0 - sqrt(x))) - t_2);
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = Float64(sqrt(y) + sqrt(z)) t_3 = sqrt(Float64(1.0 + y)) t_4 = Float64(t_3 - sqrt(y)) t_5 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_6 = sqrt(Float64(1.0 + z)) t_7 = Float64(t_5 + Float64(Float64(Float64(t_1 - sqrt(x)) + t_4) + Float64(t_6 - sqrt(z)))) tmp = 0.0 if (t_7 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_7 <= 2.0) tmp = Float64(t_1 + Float64(t_4 - sqrt(x))); elseif (t_7 <= 2.99998) tmp = Float64(Float64(t_6 + Float64(1.0 + t_3)) - Float64(sqrt(x) + t_2)); else tmp = Float64(t_5 + Float64(fma(x, 0.5, Float64(3.0 - sqrt(x))) - t_2)); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$5 + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision] + N[(t$95$6 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$7, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 2.0], N[(t$95$1 + N[(t$95$4 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$7, 2.99998], N[(N[(t$95$6 + N[(1.0 + t$95$3), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision], N[(t$95$5 + N[(N[(x * 0.5 + N[(3.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{y} + \sqrt{z}\\
t_3 := \sqrt{1 + y}\\
t_4 := t\_3 - \sqrt{y}\\
t_5 := \sqrt{1 + t} - \sqrt{t}\\
t_6 := \sqrt{1 + z}\\
t_7 := t\_5 + \left(\left(\left(t\_1 - \sqrt{x}\right) + t\_4\right) + \left(t\_6 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_7 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_7 \leq 2:\\
\;\;\;\;t\_1 + \left(t\_4 - \sqrt{x}\right)\\
\mathbf{elif}\;t\_7 \leq 2.99998:\\
\;\;\;\;\left(t\_6 + \left(1 + t\_3\right)\right) - \left(\sqrt{x} + t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_5 + \left(\mathsf{fma}\left(x, 0.5, 3 - \sqrt{x}\right) - t\_2\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2Initial program 96.1%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.0
Simplified23.0%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6425.7
Simplified25.7%
if 2 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2.9999799999999999Initial program 83.6%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6427.3
Simplified27.3%
Taylor expanded in x around 0
--lowering--.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6420.5
Simplified20.5%
if 2.9999799999999999 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 98.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6484.5
Simplified84.5%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6466.1
Simplified66.1%
Taylor expanded in z around 0
associate--r+N/A
--lowering--.f64N/A
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6441.5
Simplified41.5%
Final simplification31.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- t_2 (sqrt y)))
(t_4 (sqrt (+ 1.0 t)))
(t_5 (sqrt (+ 1.0 z)))
(t_6
(+ (- t_4 (sqrt t)) (+ (+ (- t_1 (sqrt x)) t_3) (- t_5 (sqrt z))))))
(if (<= t_6 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_6 2.0)
(+ t_1 (- t_3 (sqrt x)))
(if (<= t_6 3.0)
(- (+ t_5 (+ 1.0 t_2)) (+ (sqrt x) (+ (sqrt y) (sqrt z))))
(+ (+ (+ t_1 t_5) t_4) (- 1.0 (+ (sqrt x) (sqrt t)))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = t_2 - sqrt(y);
double t_4 = sqrt((1.0 + t));
double t_5 = sqrt((1.0 + z));
double t_6 = (t_4 - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_5 - sqrt(z)));
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_6 <= 2.0) {
tmp = t_1 + (t_3 - sqrt(x));
} else if (t_6 <= 3.0) {
tmp = (t_5 + (1.0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)));
} else {
tmp = ((t_1 + t_5) + t_4) + (1.0 - (sqrt(x) + sqrt(t)));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_1 = sqrt((x + 1.0d0))
t_2 = sqrt((1.0d0 + y))
t_3 = t_2 - sqrt(y)
t_4 = sqrt((1.0d0 + t))
t_5 = sqrt((1.0d0 + z))
t_6 = (t_4 - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_5 - sqrt(z)))
if (t_6 <= 5d-8) then
tmp = 0.5d0 * (sqrt((1.0d0 / t)) + sqrt((1.0d0 / x)))
else if (t_6 <= 2.0d0) then
tmp = t_1 + (t_3 - sqrt(x))
else if (t_6 <= 3.0d0) then
tmp = (t_5 + (1.0d0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)))
else
tmp = ((t_1 + t_5) + t_4) + (1.0d0 - (sqrt(x) + sqrt(t)))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((x + 1.0));
double t_2 = Math.sqrt((1.0 + y));
double t_3 = t_2 - Math.sqrt(y);
double t_4 = Math.sqrt((1.0 + t));
double t_5 = Math.sqrt((1.0 + z));
double t_6 = (t_4 - Math.sqrt(t)) + (((t_1 - Math.sqrt(x)) + t_3) + (t_5 - Math.sqrt(z)));
double tmp;
if (t_6 <= 5e-8) {
tmp = 0.5 * (Math.sqrt((1.0 / t)) + Math.sqrt((1.0 / x)));
} else if (t_6 <= 2.0) {
tmp = t_1 + (t_3 - Math.sqrt(x));
} else if (t_6 <= 3.0) {
tmp = (t_5 + (1.0 + t_2)) - (Math.sqrt(x) + (Math.sqrt(y) + Math.sqrt(z)));
} else {
tmp = ((t_1 + t_5) + t_4) + (1.0 - (Math.sqrt(x) + Math.sqrt(t)));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((x + 1.0)) t_2 = math.sqrt((1.0 + y)) t_3 = t_2 - math.sqrt(y) t_4 = math.sqrt((1.0 + t)) t_5 = math.sqrt((1.0 + z)) t_6 = (t_4 - math.sqrt(t)) + (((t_1 - math.sqrt(x)) + t_3) + (t_5 - math.sqrt(z))) tmp = 0 if t_6 <= 5e-8: tmp = 0.5 * (math.sqrt((1.0 / t)) + math.sqrt((1.0 / x))) elif t_6 <= 2.0: tmp = t_1 + (t_3 - math.sqrt(x)) elif t_6 <= 3.0: tmp = (t_5 + (1.0 + t_2)) - (math.sqrt(x) + (math.sqrt(y) + math.sqrt(z))) else: tmp = ((t_1 + t_5) + t_4) + (1.0 - (math.sqrt(x) + math.sqrt(t))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(t_2 - sqrt(y)) t_4 = sqrt(Float64(1.0 + t)) t_5 = sqrt(Float64(1.0 + z)) t_6 = Float64(Float64(t_4 - sqrt(t)) + Float64(Float64(Float64(t_1 - sqrt(x)) + t_3) + Float64(t_5 - sqrt(z)))) tmp = 0.0 if (t_6 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_6 <= 2.0) tmp = Float64(t_1 + Float64(t_3 - sqrt(x))); elseif (t_6 <= 3.0) tmp = Float64(Float64(t_5 + Float64(1.0 + t_2)) - Float64(sqrt(x) + Float64(sqrt(y) + sqrt(z)))); else tmp = Float64(Float64(Float64(t_1 + t_5) + t_4) + Float64(1.0 - Float64(sqrt(x) + sqrt(t)))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = sqrt((x + 1.0));
t_2 = sqrt((1.0 + y));
t_3 = t_2 - sqrt(y);
t_4 = sqrt((1.0 + t));
t_5 = sqrt((1.0 + z));
t_6 = (t_4 - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_5 - sqrt(z)));
tmp = 0.0;
if (t_6 <= 5e-8)
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
elseif (t_6 <= 2.0)
tmp = t_1 + (t_3 - sqrt(x));
elseif (t_6 <= 3.0)
tmp = (t_5 + (1.0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)));
else
tmp = ((t_1 + t_5) + t_4) + (1.0 - (sqrt(x) + sqrt(t)));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(N[(t$95$4 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] + N[(t$95$5 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 2.0], N[(t$95$1 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$6, 3.0], N[(N[(t$95$5 + N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 + t$95$5), $MachinePrecision] + t$95$4), $MachinePrecision] + N[(1.0 - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := t\_2 - \sqrt{y}\\
t_4 := \sqrt{1 + t}\\
t_5 := \sqrt{1 + z}\\
t_6 := \left(t\_4 - \sqrt{t}\right) + \left(\left(\left(t\_1 - \sqrt{x}\right) + t\_3\right) + \left(t\_5 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_6 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_6 \leq 2:\\
\;\;\;\;t\_1 + \left(t\_3 - \sqrt{x}\right)\\
\mathbf{elif}\;t\_6 \leq 3:\\
\;\;\;\;\left(t\_5 + \left(1 + t\_2\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(t\_1 + t\_5\right) + t\_4\right) + \left(1 - \left(\sqrt{x} + \sqrt{t}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2Initial program 96.1%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.0
Simplified23.0%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6425.7
Simplified25.7%
if 2 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 3Initial program 95.4%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6424.6
Simplified24.6%
Taylor expanded in x around 0
--lowering--.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6419.6
Simplified19.6%
if 3 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.7%
Taylor expanded in y around 0
sub-negN/A
+-commutativeN/A
associate-+l+N/A
+-lowering-+.f64N/A
Simplified90.7%
Taylor expanded in t around inf
sqrt-lowering-sqrt.f6479.0
Simplified79.0%
Final simplification31.1%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (- (sqrt (+ 1.0 y)) (sqrt y)))
(t_3 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_4 (- (sqrt (+ 1.0 z)) (sqrt z)))
(t_5 (+ t_3 (+ (+ (- t_1 (sqrt x)) t_2) t_4))))
(if (<= t_5 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_5 1.99999999995)
(+ t_1 (- t_2 (sqrt x)))
(+ t_3 (+ t_4 (- (fma x 0.5 2.0) (sqrt y))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y)) - sqrt(y);
double t_3 = sqrt((1.0 + t)) - sqrt(t);
double t_4 = sqrt((1.0 + z)) - sqrt(z);
double t_5 = t_3 + (((t_1 - sqrt(x)) + t_2) + t_4);
double tmp;
if (t_5 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_5 <= 1.99999999995) {
tmp = t_1 + (t_2 - sqrt(x));
} else {
tmp = t_3 + (t_4 + (fma(x, 0.5, 2.0) - sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = Float64(sqrt(Float64(1.0 + y)) - sqrt(y)) t_3 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_4 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) t_5 = Float64(t_3 + Float64(Float64(Float64(t_1 - sqrt(x)) + t_2) + t_4)) tmp = 0.0 if (t_5 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_5 <= 1.99999999995) tmp = Float64(t_1 + Float64(t_2 - sqrt(x))); else tmp = Float64(t_3 + Float64(t_4 + Float64(fma(x, 0.5, 2.0) - sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 1.99999999995], N[(t$95$1 + N[(t$95$2 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$3 + N[(t$95$4 + N[(N[(x * 0.5 + 2.0), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y} - \sqrt{y}\\
t_3 := \sqrt{1 + t} - \sqrt{t}\\
t_4 := \sqrt{1 + z} - \sqrt{z}\\
t_5 := t\_3 + \left(\left(\left(t\_1 - \sqrt{x}\right) + t\_2\right) + t\_4\right)\\
\mathbf{if}\;t\_5 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_5 \leq 1.99999999995:\\
\;\;\;\;t\_1 + \left(t\_2 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_3 + \left(t\_4 + \left(\mathsf{fma}\left(x, 0.5, 2\right) - \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.99999999995Initial program 93.7%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6419.6
Simplified19.6%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.7
Simplified29.7%
if 1.99999999995 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 96.9%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6466.6
Simplified66.6%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6440.7
Simplified40.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6439.6
Simplified39.6%
Final simplification38.0%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- t_2 (sqrt y)))
(t_4 (sqrt (+ 1.0 z)))
(t_5
(+
(- (sqrt (+ 1.0 t)) (sqrt t))
(+ (+ (- t_1 (sqrt x)) t_3) (- t_4 (sqrt z))))))
(if (<= t_5 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_5 2.0)
(+ t_1 (- t_3 (sqrt x)))
(- (+ t_4 (+ 1.0 t_2)) (+ (sqrt x) (+ (sqrt y) (sqrt z))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = t_2 - sqrt(y);
double t_4 = sqrt((1.0 + z));
double t_5 = (sqrt((1.0 + t)) - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_4 - sqrt(z)));
double tmp;
if (t_5 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_5 <= 2.0) {
tmp = t_1 + (t_3 - sqrt(x));
} else {
tmp = (t_4 + (1.0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_1 = sqrt((x + 1.0d0))
t_2 = sqrt((1.0d0 + y))
t_3 = t_2 - sqrt(y)
t_4 = sqrt((1.0d0 + z))
t_5 = (sqrt((1.0d0 + t)) - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_4 - sqrt(z)))
if (t_5 <= 5d-8) then
tmp = 0.5d0 * (sqrt((1.0d0 / t)) + sqrt((1.0d0 / x)))
else if (t_5 <= 2.0d0) then
tmp = t_1 + (t_3 - sqrt(x))
else
tmp = (t_4 + (1.0d0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((x + 1.0));
double t_2 = Math.sqrt((1.0 + y));
double t_3 = t_2 - Math.sqrt(y);
double t_4 = Math.sqrt((1.0 + z));
double t_5 = (Math.sqrt((1.0 + t)) - Math.sqrt(t)) + (((t_1 - Math.sqrt(x)) + t_3) + (t_4 - Math.sqrt(z)));
double tmp;
if (t_5 <= 5e-8) {
tmp = 0.5 * (Math.sqrt((1.0 / t)) + Math.sqrt((1.0 / x)));
} else if (t_5 <= 2.0) {
tmp = t_1 + (t_3 - Math.sqrt(x));
} else {
tmp = (t_4 + (1.0 + t_2)) - (Math.sqrt(x) + (Math.sqrt(y) + Math.sqrt(z)));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((x + 1.0)) t_2 = math.sqrt((1.0 + y)) t_3 = t_2 - math.sqrt(y) t_4 = math.sqrt((1.0 + z)) t_5 = (math.sqrt((1.0 + t)) - math.sqrt(t)) + (((t_1 - math.sqrt(x)) + t_3) + (t_4 - math.sqrt(z))) tmp = 0 if t_5 <= 5e-8: tmp = 0.5 * (math.sqrt((1.0 / t)) + math.sqrt((1.0 / x))) elif t_5 <= 2.0: tmp = t_1 + (t_3 - math.sqrt(x)) else: tmp = (t_4 + (1.0 + t_2)) - (math.sqrt(x) + (math.sqrt(y) + math.sqrt(z))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(t_2 - sqrt(y)) t_4 = sqrt(Float64(1.0 + z)) t_5 = Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(Float64(Float64(t_1 - sqrt(x)) + t_3) + Float64(t_4 - sqrt(z)))) tmp = 0.0 if (t_5 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_5 <= 2.0) tmp = Float64(t_1 + Float64(t_3 - sqrt(x))); else tmp = Float64(Float64(t_4 + Float64(1.0 + t_2)) - Float64(sqrt(x) + Float64(sqrt(y) + sqrt(z)))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = sqrt((x + 1.0));
t_2 = sqrt((1.0 + y));
t_3 = t_2 - sqrt(y);
t_4 = sqrt((1.0 + z));
t_5 = (sqrt((1.0 + t)) - sqrt(t)) + (((t_1 - sqrt(x)) + t_3) + (t_4 - sqrt(z)));
tmp = 0.0;
if (t_5 <= 5e-8)
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
elseif (t_5 <= 2.0)
tmp = t_1 + (t_3 - sqrt(x));
else
tmp = (t_4 + (1.0 + t_2)) - (sqrt(x) + (sqrt(y) + sqrt(z)));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] + N[(t$95$4 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 2.0], N[(t$95$1 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$4 + N[(1.0 + t$95$2), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := t\_2 - \sqrt{y}\\
t_4 := \sqrt{1 + z}\\
t_5 := \left(\sqrt{1 + t} - \sqrt{t}\right) + \left(\left(\left(t\_1 - \sqrt{x}\right) + t\_3\right) + \left(t\_4 - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_5 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_5 \leq 2:\\
\;\;\;\;t\_1 + \left(t\_3 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_4 + \left(1 + t\_2\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 4.9999999999999998e-8Initial program 5.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified3.4%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6435.3
Simplified35.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6463.6
Simplified63.6%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 2Initial program 96.1%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.0
Simplified23.0%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6425.7
Simplified25.7%
if 2 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 96.0%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6424.2
Simplified24.2%
Taylor expanded in x around 0
--lowering--.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6420.6
Simplified20.6%
Final simplification25.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ 1.0 z)))
(t_2 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_3 (sqrt (+ 1.0 y)))
(t_4 (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- t_3 (sqrt y))))
(t_5 (+ t_4 (- t_1 (sqrt z)))))
(if (<= t_5 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_5 2.0002)
(+ t_2 (+ t_4 (* 0.5 (sqrt (/ 1.0 z)))))
(+ t_2 (+ 1.0 (+ t_3 (- t_1 (+ (sqrt x) (+ (sqrt y) (sqrt z)))))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + z));
double t_2 = sqrt((1.0 + t)) - sqrt(t);
double t_3 = sqrt((1.0 + y));
double t_4 = (sqrt((x + 1.0)) - sqrt(x)) + (t_3 - sqrt(y));
double t_5 = t_4 + (t_1 - sqrt(z));
double tmp;
if (t_5 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_5 <= 2.0002) {
tmp = t_2 + (t_4 + (0.5 * sqrt((1.0 / z))));
} else {
tmp = t_2 + (1.0 + (t_3 + (t_1 - (sqrt(x) + (sqrt(y) + sqrt(z))))));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_1 = sqrt((1.0d0 + z))
t_2 = sqrt((1.0d0 + t)) - sqrt(t)
t_3 = sqrt((1.0d0 + y))
t_4 = (sqrt((x + 1.0d0)) - sqrt(x)) + (t_3 - sqrt(y))
t_5 = t_4 + (t_1 - sqrt(z))
if (t_5 <= 5d-8) then
tmp = 0.5d0 * (sqrt((1.0d0 / t)) + sqrt((1.0d0 / x)))
else if (t_5 <= 2.0002d0) then
tmp = t_2 + (t_4 + (0.5d0 * sqrt((1.0d0 / z))))
else
tmp = t_2 + (1.0d0 + (t_3 + (t_1 - (sqrt(x) + (sqrt(y) + sqrt(z))))))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((1.0 + z));
double t_2 = Math.sqrt((1.0 + t)) - Math.sqrt(t);
double t_3 = Math.sqrt((1.0 + y));
double t_4 = (Math.sqrt((x + 1.0)) - Math.sqrt(x)) + (t_3 - Math.sqrt(y));
double t_5 = t_4 + (t_1 - Math.sqrt(z));
double tmp;
if (t_5 <= 5e-8) {
tmp = 0.5 * (Math.sqrt((1.0 / t)) + Math.sqrt((1.0 / x)));
} else if (t_5 <= 2.0002) {
tmp = t_2 + (t_4 + (0.5 * Math.sqrt((1.0 / z))));
} else {
tmp = t_2 + (1.0 + (t_3 + (t_1 - (Math.sqrt(x) + (Math.sqrt(y) + Math.sqrt(z))))));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((1.0 + z)) t_2 = math.sqrt((1.0 + t)) - math.sqrt(t) t_3 = math.sqrt((1.0 + y)) t_4 = (math.sqrt((x + 1.0)) - math.sqrt(x)) + (t_3 - math.sqrt(y)) t_5 = t_4 + (t_1 - math.sqrt(z)) tmp = 0 if t_5 <= 5e-8: tmp = 0.5 * (math.sqrt((1.0 / t)) + math.sqrt((1.0 / x))) elif t_5 <= 2.0002: tmp = t_2 + (t_4 + (0.5 * math.sqrt((1.0 / z)))) else: tmp = t_2 + (1.0 + (t_3 + (t_1 - (math.sqrt(x) + (math.sqrt(y) + math.sqrt(z)))))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + z)) t_2 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_3 = sqrt(Float64(1.0 + y)) t_4 = Float64(Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) + Float64(t_3 - sqrt(y))) t_5 = Float64(t_4 + Float64(t_1 - sqrt(z))) tmp = 0.0 if (t_5 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_5 <= 2.0002) tmp = Float64(t_2 + Float64(t_4 + Float64(0.5 * sqrt(Float64(1.0 / z))))); else tmp = Float64(t_2 + Float64(1.0 + Float64(t_3 + Float64(t_1 - Float64(sqrt(x) + Float64(sqrt(y) + sqrt(z))))))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = sqrt((1.0 + z));
t_2 = sqrt((1.0 + t)) - sqrt(t);
t_3 = sqrt((1.0 + y));
t_4 = (sqrt((x + 1.0)) - sqrt(x)) + (t_3 - sqrt(y));
t_5 = t_4 + (t_1 - sqrt(z));
tmp = 0.0;
if (t_5 <= 5e-8)
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
elseif (t_5 <= 2.0002)
tmp = t_2 + (t_4 + (0.5 * sqrt((1.0 / z))));
else
tmp = t_2 + (1.0 + (t_3 + (t_1 - (sqrt(x) + (sqrt(y) + sqrt(z))))));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 + N[(t$95$1 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 2.0002], N[(t$95$2 + N[(t$95$4 + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 + N[(1.0 + N[(t$95$3 + N[(t$95$1 - N[(N[Sqrt[x], $MachinePrecision] + N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + z}\\
t_2 := \sqrt{1 + t} - \sqrt{t}\\
t_3 := \sqrt{1 + y}\\
t_4 := \left(\sqrt{x + 1} - \sqrt{x}\right) + \left(t\_3 - \sqrt{y}\right)\\
t_5 := t\_4 + \left(t\_1 - \sqrt{z}\right)\\
\mathbf{if}\;t\_5 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_5 \leq 2.0002:\\
\;\;\;\;t\_2 + \left(t\_4 + 0.5 \cdot \sqrt{\frac{1}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2 + \left(1 + \left(t\_3 + \left(t\_1 - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\right)\right)\right)\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 4.9999999999999998e-8Initial program 30.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified4.2%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6425.6
Simplified25.6%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6444.5
Simplified44.5%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 2.00019999999999998Initial program 96.1%
Taylor expanded in z around inf
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6454.0
Simplified54.0%
if 2.00019999999999998 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) Initial program 98.1%
Taylor expanded in x around 0
associate--l+N/A
+-lowering-+.f64N/A
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6496.7
Simplified96.7%
Final simplification59.6%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (sqrt (+ x 1.0)) (sqrt x)))
(t_2
(+
(- (sqrt (+ 1.0 t)) (sqrt t))
(+
(+ t_1 (- (sqrt (+ 1.0 y)) (sqrt y)))
(- (sqrt (+ 1.0 z)) (sqrt z))))))
(if (<= t_2 0.2)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_2 1.5) (fma 0.5 (+ x (sqrt (/ 1.0 y))) (- 1.0 (sqrt x))) t_1))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0)) - sqrt(x);
double t_2 = (sqrt((1.0 + t)) - sqrt(t)) + ((t_1 + (sqrt((1.0 + y)) - sqrt(y))) + (sqrt((1.0 + z)) - sqrt(z)));
double tmp;
if (t_2 <= 0.2) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_2 <= 1.5) {
tmp = fma(0.5, (x + sqrt((1.0 / y))), (1.0 - sqrt(x)));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) t_2 = Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(Float64(t_1 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y))) + Float64(sqrt(Float64(1.0 + z)) - sqrt(z)))) tmp = 0.0 if (t_2 <= 0.2) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_2 <= 1.5) tmp = fma(0.5, Float64(x + sqrt(Float64(1.0 / y))), Float64(1.0 - sqrt(x))); else tmp = t_1; end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$1 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.2], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1.5], N[(0.5 * N[(x + N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1} - \sqrt{x}\\
t_2 := \left(\sqrt{1 + t} - \sqrt{t}\right) + \left(\left(t\_1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\sqrt{1 + z} - \sqrt{z}\right)\right)\\
\mathbf{if}\;t\_2 \leq 0.2:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_2 \leq 1.5:\\
\;\;\;\;\mathsf{fma}\left(0.5, x + \sqrt{\frac{1}{y}}, 1 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 0.20000000000000001Initial program 19.5%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified9.5%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6436.4
Simplified36.4%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6457.0
Simplified57.0%
if 0.20000000000000001 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.5Initial program 93.2%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6429.3
Simplified29.3%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
distribute-lft-outN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6429.7
Simplified29.7%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6429.7
Simplified29.7%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6429.4
Simplified29.4%
if 1.5 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.0%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.6
Applied egg-rr97.6%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6427.5
Simplified27.5%
Taylor expanded in x around inf
mul-1-negN/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f6413.1
Simplified13.1%
Final simplification18.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ 1.0 z)))
(t_2 (sqrt (+ x 1.0)))
(t_3 (- (sqrt (+ 1.0 y)) (sqrt y)))
(t_4 (+ (+ (- t_2 (sqrt x)) t_3) (- t_1 (sqrt z)))))
(if (<= t_4 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_4 2.0)
(+ t_2 (- t_3 (sqrt x)))
(- (- (+ t_1 (fma x 0.5 2.0)) (+ (sqrt x) (sqrt z))) (sqrt y))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + z));
double t_2 = sqrt((x + 1.0));
double t_3 = sqrt((1.0 + y)) - sqrt(y);
double t_4 = ((t_2 - sqrt(x)) + t_3) + (t_1 - sqrt(z));
double tmp;
if (t_4 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_4 <= 2.0) {
tmp = t_2 + (t_3 - sqrt(x));
} else {
tmp = ((t_1 + fma(x, 0.5, 2.0)) - (sqrt(x) + sqrt(z))) - sqrt(y);
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + z)) t_2 = sqrt(Float64(x + 1.0)) t_3 = Float64(sqrt(Float64(1.0 + y)) - sqrt(y)) t_4 = Float64(Float64(Float64(t_2 - sqrt(x)) + t_3) + Float64(t_1 - sqrt(z))) tmp = 0.0 if (t_4 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_4 <= 2.0) tmp = Float64(t_2 + Float64(t_3 - sqrt(x))); else tmp = Float64(Float64(Float64(t_1 + fma(x, 0.5, 2.0)) - Float64(sqrt(x) + sqrt(z))) - sqrt(y)); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(t$95$2 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] + N[(t$95$1 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2.0], N[(t$95$2 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$1 + N[(x * 0.5 + 2.0), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + z}\\
t_2 := \sqrt{x + 1}\\
t_3 := \sqrt{1 + y} - \sqrt{y}\\
t_4 := \left(\left(t\_2 - \sqrt{x}\right) + t\_3\right) + \left(t\_1 - \sqrt{z}\right)\\
\mathbf{if}\;t\_4 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_4 \leq 2:\\
\;\;\;\;t\_2 + \left(t\_3 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(t\_1 + \mathsf{fma}\left(x, 0.5, 2\right)\right) - \left(\sqrt{x} + \sqrt{z}\right)\right) - \sqrt{y}\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 4.9999999999999998e-8Initial program 30.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified4.2%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6425.6
Simplified25.6%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6444.5
Simplified44.5%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 2Initial program 96.6%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.1
Simplified29.1%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.4
Simplified23.4%
if 2 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) Initial program 95.3%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6495.2
Simplified95.2%
Taylor expanded in y around 0
--lowering--.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6488.9
Simplified88.9%
Taylor expanded in t around inf
associate--r+N/A
+-commutativeN/A
associate--r+N/A
associate--r+N/A
--lowering--.f64N/A
Simplified44.4%
Final simplification28.0%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (sqrt (+ 1.0 t)) (sqrt t)))
(t_2 (sqrt (+ x 1.0)))
(t_3 (sqrt (+ 1.0 y)))
(t_4 (+ (- t_2 (sqrt x)) (- t_3 (sqrt y)))))
(if (<= t_4 0.2)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_4 1.9999)
(+ (- (+ (fma x 0.5 1.0) (/ 1.0 (+ (sqrt y) t_3))) (sqrt x)) t_1)
(+
t_1
(-
(+ (+ 1.0 t_2) (fma y 0.5 (/ 1.0 (+ (sqrt z) (sqrt (+ 1.0 z))))))
(+ (sqrt x) (sqrt y))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + t)) - sqrt(t);
double t_2 = sqrt((x + 1.0));
double t_3 = sqrt((1.0 + y));
double t_4 = (t_2 - sqrt(x)) + (t_3 - sqrt(y));
double tmp;
if (t_4 <= 0.2) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_4 <= 1.9999) {
tmp = ((fma(x, 0.5, 1.0) + (1.0 / (sqrt(y) + t_3))) - sqrt(x)) + t_1;
} else {
tmp = t_1 + (((1.0 + t_2) + fma(y, 0.5, (1.0 / (sqrt(z) + sqrt((1.0 + z)))))) - (sqrt(x) + sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) t_2 = sqrt(Float64(x + 1.0)) t_3 = sqrt(Float64(1.0 + y)) t_4 = Float64(Float64(t_2 - sqrt(x)) + Float64(t_3 - sqrt(y))) tmp = 0.0 if (t_4 <= 0.2) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_4 <= 1.9999) tmp = Float64(Float64(Float64(fma(x, 0.5, 1.0) + Float64(1.0 / Float64(sqrt(y) + t_3))) - sqrt(x)) + t_1); else tmp = Float64(t_1 + Float64(Float64(Float64(1.0 + t_2) + fma(y, 0.5, Float64(1.0 / Float64(sqrt(z) + sqrt(Float64(1.0 + z)))))) - Float64(sqrt(x) + sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$2 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 0.2], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 1.9999], N[(N[(N[(N[(x * 0.5 + 1.0), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[y], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(t$95$1 + N[(N[(N[(1.0 + t$95$2), $MachinePrecision] + N[(y * 0.5 + N[(1.0 / N[(N[Sqrt[z], $MachinePrecision] + N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + t} - \sqrt{t}\\
t_2 := \sqrt{x + 1}\\
t_3 := \sqrt{1 + y}\\
t_4 := \left(t\_2 - \sqrt{x}\right) + \left(t\_3 - \sqrt{y}\right)\\
\mathbf{if}\;t\_4 \leq 0.2:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_4 \leq 1.9999:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(x, 0.5, 1\right) + \frac{1}{\sqrt{y} + t\_3}\right) - \sqrt{x}\right) + t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(\left(\left(1 + t\_2\right) + \mathsf{fma}\left(y, 0.5, \frac{1}{\sqrt{z} + \sqrt{1 + z}}\right)\right) - \left(\sqrt{x} + \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) < 0.20000000000000001Initial program 76.9%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified5.6%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.3
Simplified13.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6418.1
Simplified18.1%
if 0.20000000000000001 < (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) < 1.99990000000000001Initial program 96.8%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6453.3
Simplified53.3%
flip--N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-commutativeN/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f6453.7
Applied egg-rr53.7%
Taylor expanded in z around inf
--lowering--.f64N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6431.0
Simplified31.0%
if 1.99990000000000001 < (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) Initial program 96.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.8
Applied egg-rr97.8%
Taylor expanded in y around 0
--lowering--.f64N/A
Simplified98.3%
Final simplification47.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (- t_2 (sqrt y)))
(t_4 (+ (+ (- t_1 (sqrt x)) t_3) (- (sqrt (+ 1.0 z)) (sqrt z)))))
(if (<= t_4 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_4 2.5)
(+ t_1 (- t_3 (sqrt x)))
(+ (+ 1.0 t_2) (- t_1 (+ (sqrt x) (sqrt y))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = t_2 - sqrt(y);
double t_4 = ((t_1 - sqrt(x)) + t_3) + (sqrt((1.0 + z)) - sqrt(z));
double tmp;
if (t_4 <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_4 <= 2.5) {
tmp = t_1 + (t_3 - sqrt(x));
} else {
tmp = (1.0 + t_2) + (t_1 - (sqrt(x) + sqrt(y)));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_1 = sqrt((x + 1.0d0))
t_2 = sqrt((1.0d0 + y))
t_3 = t_2 - sqrt(y)
t_4 = ((t_1 - sqrt(x)) + t_3) + (sqrt((1.0d0 + z)) - sqrt(z))
if (t_4 <= 5d-8) then
tmp = 0.5d0 * (sqrt((1.0d0 / t)) + sqrt((1.0d0 / x)))
else if (t_4 <= 2.5d0) then
tmp = t_1 + (t_3 - sqrt(x))
else
tmp = (1.0d0 + t_2) + (t_1 - (sqrt(x) + sqrt(y)))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((x + 1.0));
double t_2 = Math.sqrt((1.0 + y));
double t_3 = t_2 - Math.sqrt(y);
double t_4 = ((t_1 - Math.sqrt(x)) + t_3) + (Math.sqrt((1.0 + z)) - Math.sqrt(z));
double tmp;
if (t_4 <= 5e-8) {
tmp = 0.5 * (Math.sqrt((1.0 / t)) + Math.sqrt((1.0 / x)));
} else if (t_4 <= 2.5) {
tmp = t_1 + (t_3 - Math.sqrt(x));
} else {
tmp = (1.0 + t_2) + (t_1 - (Math.sqrt(x) + Math.sqrt(y)));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((x + 1.0)) t_2 = math.sqrt((1.0 + y)) t_3 = t_2 - math.sqrt(y) t_4 = ((t_1 - math.sqrt(x)) + t_3) + (math.sqrt((1.0 + z)) - math.sqrt(z)) tmp = 0 if t_4 <= 5e-8: tmp = 0.5 * (math.sqrt((1.0 / t)) + math.sqrt((1.0 / x))) elif t_4 <= 2.5: tmp = t_1 + (t_3 - math.sqrt(x)) else: tmp = (1.0 + t_2) + (t_1 - (math.sqrt(x) + math.sqrt(y))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(t_2 - sqrt(y)) t_4 = Float64(Float64(Float64(t_1 - sqrt(x)) + t_3) + Float64(sqrt(Float64(1.0 + z)) - sqrt(z))) tmp = 0.0 if (t_4 <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_4 <= 2.5) tmp = Float64(t_1 + Float64(t_3 - sqrt(x))); else tmp = Float64(Float64(1.0 + t_2) + Float64(t_1 - Float64(sqrt(x) + sqrt(y)))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = sqrt((x + 1.0));
t_2 = sqrt((1.0 + y));
t_3 = t_2 - sqrt(y);
t_4 = ((t_1 - sqrt(x)) + t_3) + (sqrt((1.0 + z)) - sqrt(z));
tmp = 0.0;
if (t_4 <= 5e-8)
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
elseif (t_4 <= 2.5)
tmp = t_1 + (t_3 - sqrt(x));
else
tmp = (1.0 + t_2) + (t_1 - (sqrt(x) + sqrt(y)));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 2.5], N[(t$95$1 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$2), $MachinePrecision] + N[(t$95$1 - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := t\_2 - \sqrt{y}\\
t_4 := \left(\left(t\_1 - \sqrt{x}\right) + t\_3\right) + \left(\sqrt{1 + z} - \sqrt{z}\right)\\
\mathbf{if}\;t\_4 \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_4 \leq 2.5:\\
\;\;\;\;t\_1 + \left(t\_3 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + t\_2\right) + \left(t\_1 - \left(\sqrt{x} + \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 4.9999999999999998e-8Initial program 30.8%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified4.2%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6425.6
Simplified25.6%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6444.5
Simplified44.5%
if 4.9999999999999998e-8 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) < 2.5Initial program 96.1%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6429.5
Simplified29.5%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6423.8
Simplified23.8%
if 2.5 < (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) Initial program 98.1%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6443.7
Simplified43.7%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6443.7
Simplified43.7%
Taylor expanded in z around 0
Simplified43.6%
Final simplification27.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0)))
(t_2 (sqrt (+ 1.0 y)))
(t_3 (+ (- t_1 (sqrt x)) (- t_2 (sqrt y)))))
(if (<= t_3 0.2)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(if (<= t_3 1.002)
(fma 0.5 (+ x (sqrt (/ 1.0 y))) (- 1.0 (sqrt x)))
(+ t_1 (- t_2 (+ (sqrt x) (sqrt y))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double t_2 = sqrt((1.0 + y));
double t_3 = (t_1 - sqrt(x)) + (t_2 - sqrt(y));
double tmp;
if (t_3 <= 0.2) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else if (t_3 <= 1.002) {
tmp = fma(0.5, (x + sqrt((1.0 / y))), (1.0 - sqrt(x)));
} else {
tmp = t_1 + (t_2 - (sqrt(x) + sqrt(y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) t_2 = sqrt(Float64(1.0 + y)) t_3 = Float64(Float64(t_1 - sqrt(x)) + Float64(t_2 - sqrt(y))) tmp = 0.0 if (t_3 <= 0.2) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); elseif (t_3 <= 1.002) tmp = fma(0.5, Float64(x + sqrt(Float64(1.0 / y))), Float64(1.0 - sqrt(x))); else tmp = Float64(t_1 + Float64(t_2 - Float64(sqrt(x) + sqrt(y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, 0.2], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 1.002], N[(0.5 * N[(x + N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(t$95$2 - N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
t_2 := \sqrt{1 + y}\\
t_3 := \left(t\_1 - \sqrt{x}\right) + \left(t\_2 - \sqrt{y}\right)\\
\mathbf{if}\;t\_3 \leq 0.2:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{elif}\;t\_3 \leq 1.002:\\
\;\;\;\;\mathsf{fma}\left(0.5, x + \sqrt{\frac{1}{y}}, 1 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(t\_2 - \left(\sqrt{x} + \sqrt{y}\right)\right)\\
\end{array}
\end{array}
if (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) < 0.20000000000000001Initial program 76.9%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified5.6%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6413.3
Simplified13.3%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6418.1
Simplified18.1%
if 0.20000000000000001 < (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) < 1.002Initial program 96.7%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6451.5
Simplified51.5%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
distribute-lft-outN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6452.4
Simplified52.4%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6430.1
Simplified30.1%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6420.9
Simplified20.9%
if 1.002 < (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) Initial program 96.7%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6426.5
Simplified26.5%
Taylor expanded in z around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6436.3
Simplified36.3%
Final simplification25.0%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (sqrt (+ x 1.0)) (sqrt x))))
(if (<=
(+
(- (sqrt (+ 1.0 t)) (sqrt t))
(+
(+ t_1 (- (sqrt (+ 1.0 y)) (sqrt y)))
(- (sqrt (+ 1.0 z)) (sqrt z))))
1.5)
(fma 0.5 (+ x (sqrt (/ 1.0 y))) (- 1.0 (sqrt x)))
t_1)))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0)) - sqrt(x);
double tmp;
if (((sqrt((1.0 + t)) - sqrt(t)) + ((t_1 + (sqrt((1.0 + y)) - sqrt(y))) + (sqrt((1.0 + z)) - sqrt(z)))) <= 1.5) {
tmp = fma(0.5, (x + sqrt((1.0 / y))), (1.0 - sqrt(x)));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) tmp = 0.0 if (Float64(Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) + Float64(Float64(t_1 + Float64(sqrt(Float64(1.0 + y)) - sqrt(y))) + Float64(sqrt(Float64(1.0 + z)) - sqrt(z)))) <= 1.5) tmp = fma(0.5, Float64(x + sqrt(Float64(1.0 / y))), Float64(1.0 - sqrt(x))); else tmp = t_1; end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$1 + N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.5], N[(0.5 * N[(x + N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1} - \sqrt{x}\\
\mathbf{if}\;\left(\sqrt{1 + t} - \sqrt{t}\right) + \left(\left(t\_1 + \left(\sqrt{1 + y} - \sqrt{y}\right)\right) + \left(\sqrt{1 + z} - \sqrt{z}\right)\right) \leq 1.5:\\
\;\;\;\;\mathsf{fma}\left(0.5, x + \sqrt{\frac{1}{y}}, 1 - \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) < 1.5Initial program 80.0%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6425.0
Simplified25.0%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
distribute-lft-outN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6425.3
Simplified25.3%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6425.3
Simplified25.3%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6425.1
Simplified25.1%
if 1.5 < (+.f64 (+.f64 (+.f64 (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y))) (-.f64 (sqrt.f64 (+.f64 z #s(literal 1 binary64))) (sqrt.f64 z))) (-.f64 (sqrt.f64 (+.f64 t #s(literal 1 binary64))) (sqrt.f64 t))) Initial program 97.0%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.6
Applied egg-rr97.6%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6427.5
Simplified27.5%
Taylor expanded in x around inf
mul-1-negN/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f6413.1
Simplified13.1%
Final simplification16.3%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (+ x 1.0))))
(if (<= (- t_1 (sqrt x)) 5e-8)
(* 0.5 (+ (sqrt (/ 1.0 t)) (sqrt (/ 1.0 x))))
(+ t_1 (- (- (sqrt (+ 1.0 y)) (sqrt y)) (sqrt x))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((x + 1.0));
double tmp;
if ((t_1 - sqrt(x)) <= 5e-8) {
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
} else {
tmp = t_1 + ((sqrt((1.0 + y)) - sqrt(y)) - sqrt(x));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = sqrt((x + 1.0d0))
if ((t_1 - sqrt(x)) <= 5d-8) then
tmp = 0.5d0 * (sqrt((1.0d0 / t)) + sqrt((1.0d0 / x)))
else
tmp = t_1 + ((sqrt((1.0d0 + y)) - sqrt(y)) - sqrt(x))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((x + 1.0));
double tmp;
if ((t_1 - Math.sqrt(x)) <= 5e-8) {
tmp = 0.5 * (Math.sqrt((1.0 / t)) + Math.sqrt((1.0 / x)));
} else {
tmp = t_1 + ((Math.sqrt((1.0 + y)) - Math.sqrt(y)) - Math.sqrt(x));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((x + 1.0)) tmp = 0 if (t_1 - math.sqrt(x)) <= 5e-8: tmp = 0.5 * (math.sqrt((1.0 / t)) + math.sqrt((1.0 / x))) else: tmp = t_1 + ((math.sqrt((1.0 + y)) - math.sqrt(y)) - math.sqrt(x)) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(x + 1.0)) tmp = 0.0 if (Float64(t_1 - sqrt(x)) <= 5e-8) tmp = Float64(0.5 * Float64(sqrt(Float64(1.0 / t)) + sqrt(Float64(1.0 / x)))); else tmp = Float64(t_1 + Float64(Float64(sqrt(Float64(1.0 + y)) - sqrt(y)) - sqrt(x))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = sqrt((x + 1.0));
tmp = 0.0;
if ((t_1 - sqrt(x)) <= 5e-8)
tmp = 0.5 * (sqrt((1.0 / t)) + sqrt((1.0 / x)));
else
tmp = t_1 + ((sqrt((1.0 + y)) - sqrt(y)) - sqrt(x));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 5e-8], N[(0.5 * N[(N[Sqrt[N[(1.0 / t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(N[Sqrt[N[(1.0 + y), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{x + 1}\\
\mathbf{if}\;t\_1 - \sqrt{x} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{\frac{1}{t}} + \sqrt{\frac{1}{x}}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 + \left(\left(\sqrt{1 + y} - \sqrt{y}\right) - \sqrt{x}\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) < 4.9999999999999998e-8Initial program 88.0%
Taylor expanded in t around inf
associate--l+N/A
+-commutativeN/A
+-commutativeN/A
associate--r+N/A
associate-+l-N/A
--lowering--.f64N/A
Simplified19.1%
Taylor expanded in t around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f649.4
Simplified9.4%
Taylor expanded in x around inf
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f6412.2
Simplified12.2%
if 4.9999999999999998e-8 < (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x)) Initial program 96.0%
Taylor expanded in z around inf
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6438.3
Simplified38.3%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-commutativeN/A
associate--r+N/A
--lowering--.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6436.5
Simplified36.5%
Final simplification25.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return sqrt((x + 1.0)) - sqrt(x);
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = sqrt((x + 1.0d0)) - sqrt(x)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return math.sqrt((x + 1.0)) - math.sqrt(x)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = sqrt((x + 1.0)) - sqrt(x);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\sqrt{x + 1} - \sqrt{x}
\end{array}
Initial program 92.5%
flip--N/A
/-lowering-/.f64N/A
rem-square-sqrtN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6493.4
Applied egg-rr93.4%
Taylor expanded in t around inf
associate--l+N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6427.0
Simplified27.0%
Taylor expanded in x around inf
mul-1-negN/A
neg-lowering-neg.f64N/A
sqrt-lowering-sqrt.f6416.0
Simplified16.0%
Final simplification16.0%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* 0.5 (sqrt (/ 1.0 y))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 0.5 * sqrt((1.0 / y));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 0.5d0 * sqrt((1.0d0 / y))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 0.5 * Math.sqrt((1.0 / y));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 0.5 * math.sqrt((1.0 / y))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(0.5 * sqrt(Float64(1.0 / y))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 0.5 * sqrt((1.0 / y));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
0.5 \cdot \sqrt{\frac{1}{y}}
\end{array}
Initial program 92.5%
Taylor expanded in x around 0
+-commutativeN/A
associate--l+N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f6455.3
Simplified55.3%
Taylor expanded in y around inf
--lowering--.f64N/A
+-commutativeN/A
distribute-lft-outN/A
accelerator-lowering-fma.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f64N/A
sqrt-lowering-sqrt.f6429.0
Simplified29.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
sqrt-lowering-sqrt.f64N/A
/-lowering-/.f647.3
Simplified7.3%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (sqrt z))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return sqrt(z);
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = sqrt(z)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return Math.sqrt(z);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return math.sqrt(z)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return sqrt(z) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = sqrt(z);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[Sqrt[z], $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\sqrt{z}
\end{array}
Initial program 92.5%
Taylor expanded in t around inf
+-commutativeN/A
associate--l+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f64N/A
sqrt-lowering-sqrt.f6418.3
Simplified18.3%
Taylor expanded in y around inf
sqrt-lowering-sqrt.f6418.2
Simplified18.2%
Taylor expanded in z around inf
sqrt-lowering-sqrt.f646.8
Simplified6.8%
(FPCore (x y z t)
:precision binary64
(+
(+
(+
(/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))
(/ 1.0 (+ (sqrt (+ y 1.0)) (sqrt y))))
(/ 1.0 (+ (sqrt (+ z 1.0)) (sqrt z))))
(- (sqrt (+ t 1.0)) (sqrt t))))
double code(double x, double y, double z, double t) {
return (((1.0 / (sqrt((x + 1.0)) + sqrt(x))) + (1.0 / (sqrt((y + 1.0)) + sqrt(y)))) + (1.0 / (sqrt((z + 1.0)) + sqrt(z)))) + (sqrt((t + 1.0)) - sqrt(t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))) + (1.0d0 / (sqrt((y + 1.0d0)) + sqrt(y)))) + (1.0d0 / (sqrt((z + 1.0d0)) + sqrt(z)))) + (sqrt((t + 1.0d0)) - sqrt(t))
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x))) + (1.0 / (Math.sqrt((y + 1.0)) + Math.sqrt(y)))) + (1.0 / (Math.sqrt((z + 1.0)) + Math.sqrt(z)))) + (Math.sqrt((t + 1.0)) - Math.sqrt(t));
}
def code(x, y, z, t): return (((1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))) + (1.0 / (math.sqrt((y + 1.0)) + math.sqrt(y)))) + (1.0 / (math.sqrt((z + 1.0)) + math.sqrt(z)))) + (math.sqrt((t + 1.0)) - math.sqrt(t))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x))) + Float64(1.0 / Float64(sqrt(Float64(y + 1.0)) + sqrt(y)))) + Float64(1.0 / Float64(sqrt(Float64(z + 1.0)) + sqrt(z)))) + Float64(sqrt(Float64(t + 1.0)) - sqrt(t))) end
function tmp = code(x, y, z, t) tmp = (((1.0 / (sqrt((x + 1.0)) + sqrt(x))) + (1.0 / (sqrt((y + 1.0)) + sqrt(y)))) + (1.0 / (sqrt((z + 1.0)) + sqrt(z)))) + (sqrt((t + 1.0)) - sqrt(t)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[N[(z + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sqrt[N[(t + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}} + \frac{1}{\sqrt{y + 1} + \sqrt{y}}\right) + \frac{1}{\sqrt{z + 1} + \sqrt{z}}\right) + \left(\sqrt{t + 1} - \sqrt{t}\right)
\end{array}
herbie shell --seed 2024204
(FPCore (x y z t)
:name "Main:z from "
:precision binary64
:alt
(! :herbie-platform default (+ (+ (+ (/ 1 (+ (sqrt (+ x 1)) (sqrt x))) (/ 1 (+ (sqrt (+ y 1)) (sqrt y)))) (/ 1 (+ (sqrt (+ z 1)) (sqrt z)))) (- (sqrt (+ t 1)) (sqrt t))))
(+ (+ (+ (- (sqrt (+ x 1.0)) (sqrt x)) (- (sqrt (+ y 1.0)) (sqrt y))) (- (sqrt (+ z 1.0)) (sqrt z))) (- (sqrt (+ t 1.0)) (sqrt t))))