
(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 19 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 (+ y 1.0)) (sqrt y)))
(t_2 (sqrt (+ 1.0 x)))
(t_3 (sqrt (+ 1.0 z)))
(t_4 (- (sqrt (+ 1.0 t)) (sqrt t))))
(if (<= t_1 5e-6)
(+
(+ (* 0.5 (sqrt (/ 1.0 y))) (/ 1.0 (+ (sqrt x) t_2)))
(+ (- t_3 (sqrt z)) t_4))
(+ (+ t_1 (- t_2 (sqrt x))) (+ t_4 (/ 1.0 (+ t_3 (sqrt z))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((y + 1.0)) - sqrt(y);
double t_2 = sqrt((1.0 + x));
double t_3 = sqrt((1.0 + z));
double t_4 = sqrt((1.0 + t)) - sqrt(t);
double tmp;
if (t_1 <= 5e-6) {
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + t_2))) + ((t_3 - sqrt(z)) + t_4);
} else {
tmp = (t_1 + (t_2 - sqrt(x))) + (t_4 + (1.0 / (t_3 + 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) :: tmp
t_1 = sqrt((y + 1.0d0)) - sqrt(y)
t_2 = sqrt((1.0d0 + x))
t_3 = sqrt((1.0d0 + z))
t_4 = sqrt((1.0d0 + t)) - sqrt(t)
if (t_1 <= 5d-6) then
tmp = ((0.5d0 * sqrt((1.0d0 / y))) + (1.0d0 / (sqrt(x) + t_2))) + ((t_3 - sqrt(z)) + t_4)
else
tmp = (t_1 + (t_2 - sqrt(x))) + (t_4 + (1.0d0 / (t_3 + 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((y + 1.0)) - Math.sqrt(y);
double t_2 = Math.sqrt((1.0 + x));
double t_3 = Math.sqrt((1.0 + z));
double t_4 = Math.sqrt((1.0 + t)) - Math.sqrt(t);
double tmp;
if (t_1 <= 5e-6) {
tmp = ((0.5 * Math.sqrt((1.0 / y))) + (1.0 / (Math.sqrt(x) + t_2))) + ((t_3 - Math.sqrt(z)) + t_4);
} else {
tmp = (t_1 + (t_2 - Math.sqrt(x))) + (t_4 + (1.0 / (t_3 + Math.sqrt(z))));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((y + 1.0)) - math.sqrt(y) t_2 = math.sqrt((1.0 + x)) t_3 = math.sqrt((1.0 + z)) t_4 = math.sqrt((1.0 + t)) - math.sqrt(t) tmp = 0 if t_1 <= 5e-6: tmp = ((0.5 * math.sqrt((1.0 / y))) + (1.0 / (math.sqrt(x) + t_2))) + ((t_3 - math.sqrt(z)) + t_4) else: tmp = (t_1 + (t_2 - math.sqrt(x))) + (t_4 + (1.0 / (t_3 + math.sqrt(z)))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) t_2 = sqrt(Float64(1.0 + x)) t_3 = sqrt(Float64(1.0 + z)) t_4 = Float64(sqrt(Float64(1.0 + t)) - sqrt(t)) tmp = 0.0 if (t_1 <= 5e-6) tmp = Float64(Float64(Float64(0.5 * sqrt(Float64(1.0 / y))) + Float64(1.0 / Float64(sqrt(x) + t_2))) + Float64(Float64(t_3 - sqrt(z)) + t_4)); else tmp = Float64(Float64(t_1 + Float64(t_2 - sqrt(x))) + Float64(t_4 + Float64(1.0 / Float64(t_3 + 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((y + 1.0)) - sqrt(y);
t_2 = sqrt((1.0 + x));
t_3 = sqrt((1.0 + z));
t_4 = sqrt((1.0 + t)) - sqrt(t);
tmp = 0.0;
if (t_1 <= 5e-6)
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + t_2))) + ((t_3 - sqrt(z)) + t_4);
else
tmp = (t_1 + (t_2 - sqrt(x))) + (t_4 + (1.0 / (t_3 + 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[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-6], N[(N[(N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$3 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 + N[(t$95$2 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$4 + N[(1.0 / N[(t$95$3 + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{y + 1} - \sqrt{y}\\
t_2 := \sqrt{1 + x}\\
t_3 := \sqrt{1 + z}\\
t_4 := \sqrt{1 + t} - \sqrt{t}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot \sqrt{\frac{1}{y}} + \frac{1}{\sqrt{x} + t\_2}\right) + \left(\left(t\_3 - \sqrt{z}\right) + t\_4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 + \left(t\_2 - \sqrt{x}\right)\right) + \left(t\_4 + \frac{1}{t\_3 + \sqrt{z}}\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 5.00000000000000041e-6Initial program 90.5%
associate-+l+90.5%
sub-neg90.5%
sub-neg90.5%
+-commutative90.5%
+-commutative90.5%
+-commutative90.5%
Simplified90.5%
flip--90.5%
add-sqr-sqrt74.3%
add-sqr-sqrt90.7%
Applied egg-rr90.7%
Taylor expanded in y around inf 95.9%
if 5.00000000000000041e-6 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.7%
associate-+l+96.7%
sub-neg96.7%
sub-neg96.7%
+-commutative96.7%
+-commutative96.7%
+-commutative96.7%
Simplified96.7%
flip--96.9%
div-inv96.9%
add-sqr-sqrt79.1%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
associate-*r/97.6%
*-rgt-identity97.6%
associate--l+97.8%
+-inverses97.8%
metadata-eval97.8%
Simplified97.8%
Final simplification96.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 x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- t_2 (sqrt z)))
(t_4 (sqrt (+ y 1.0)))
(t_5 (+ t_3 (+ (- t_4 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_5 0.9999999999999372)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_3)
(if (<= t_5 2.5)
(+ t_1 (- (+ t_4 (/ 1.0 (+ t_2 (sqrt z)))) (+ (sqrt y) (sqrt x))))
(+
(+ t_3 (- (sqrt (+ 1.0 t)) (sqrt t)))
(- (- 2.0 (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 + x));
double t_2 = sqrt((1.0 + z));
double t_3 = t_2 - sqrt(z);
double t_4 = sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.5) {
tmp = t_1 + ((t_4 + (1.0 / (t_2 + sqrt(z)))) - (sqrt(y) + sqrt(x)));
} else {
tmp = (t_3 + (sqrt((1.0 + t)) - sqrt(t))) + ((2.0 - 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) :: t_5
real(8) :: tmp
t_1 = sqrt((1.0d0 + x))
t_2 = sqrt((1.0d0 + z))
t_3 = t_2 - sqrt(z)
t_4 = sqrt((y + 1.0d0))
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_5 <= 0.9999999999999372d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_3
else if (t_5 <= 2.5d0) then
tmp = t_1 + ((t_4 + (1.0d0 / (t_2 + sqrt(z)))) - (sqrt(y) + sqrt(x)))
else
tmp = (t_3 + (sqrt((1.0d0 + t)) - sqrt(t))) + ((2.0d0 - 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((1.0 + x));
double t_2 = Math.sqrt((1.0 + z));
double t_3 = t_2 - Math.sqrt(z);
double t_4 = Math.sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.5) {
tmp = t_1 + ((t_4 + (1.0 / (t_2 + Math.sqrt(z)))) - (Math.sqrt(y) + Math.sqrt(x)));
} else {
tmp = (t_3 + (Math.sqrt((1.0 + t)) - Math.sqrt(t))) + ((2.0 - 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((1.0 + x)) t_2 = math.sqrt((1.0 + z)) t_3 = t_2 - math.sqrt(z) t_4 = math.sqrt((y + 1.0)) t_5 = t_3 + ((t_4 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_5 <= 0.9999999999999372: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_3 elif t_5 <= 2.5: tmp = t_1 + ((t_4 + (1.0 / (t_2 + math.sqrt(z)))) - (math.sqrt(y) + math.sqrt(x))) else: tmp = (t_3 + (math.sqrt((1.0 + t)) - math.sqrt(t))) + ((2.0 - 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(1.0 + x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(t_2 - sqrt(z)) t_4 = sqrt(Float64(y + 1.0)) t_5 = Float64(t_3 + Float64(Float64(t_4 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_5 <= 0.9999999999999372) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_3); elseif (t_5 <= 2.5) tmp = Float64(t_1 + Float64(Float64(t_4 + Float64(1.0 / Float64(t_2 + sqrt(z)))) - Float64(sqrt(y) + sqrt(x)))); else tmp = Float64(Float64(t_3 + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + Float64(Float64(2.0 - 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((1.0 + x));
t_2 = sqrt((1.0 + z));
t_3 = t_2 - sqrt(z);
t_4 = sqrt((y + 1.0));
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_5 <= 0.9999999999999372)
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
elseif (t_5 <= 2.5)
tmp = t_1 + ((t_4 + (1.0 / (t_2 + sqrt(z)))) - (sqrt(y) + sqrt(x)));
else
tmp = (t_3 + (sqrt((1.0 + t)) - sqrt(t))) + ((2.0 - 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[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(t$95$4 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.9999999999999372], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 2.5], N[(t$95$1 + N[(N[(t$95$4 + N[(1.0 / N[(t$95$2 + N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x}\\
t_2 := \sqrt{1 + z}\\
t_3 := t\_2 - \sqrt{z}\\
t_4 := \sqrt{y + 1}\\
t_5 := t\_3 + \left(\left(t\_4 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_5 \leq 0.9999999999999372:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_3\\
\mathbf{elif}\;t\_5 \leq 2.5:\\
\;\;\;\;t\_1 + \left(\left(t\_4 + \frac{1}{t\_2 + \sqrt{z}}\right) - \left(\sqrt{y} + \sqrt{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(2 - \sqrt{x}\right) - \sqrt{y}\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
flip--66.6%
add-sqr-sqrt43.2%
add-sqr-sqrt68.1%
Applied egg-rr68.1%
Taylor expanded in y around inf 60.4%
Taylor expanded in t around inf 26.5%
if 0.99999999999993716 < (+.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 97.8%
associate-+l+97.8%
sub-neg97.8%
sub-neg97.8%
+-commutative97.8%
+-commutative97.8%
+-commutative97.8%
Simplified97.8%
flip--97.8%
div-inv97.8%
add-sqr-sqrt80.8%
add-sqr-sqrt98.3%
Applied egg-rr98.3%
associate-*r/98.3%
*-rgt-identity98.3%
associate--l+98.6%
+-inverses98.6%
metadata-eval98.6%
Simplified98.6%
Taylor expanded in t around inf 13.5%
associate--l+24.1%
Simplified24.1%
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 97.7%
associate-+l+97.7%
sub-neg97.7%
sub-neg97.7%
+-commutative97.7%
+-commutative97.7%
+-commutative97.7%
Simplified97.7%
Taylor expanded in x around 0 97.5%
associate--l+97.5%
Simplified97.5%
Taylor expanded in y around 0 96.3%
associate--r+96.3%
Simplified96.3%
Final simplification35.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 (+ 1.0 x)))
(t_2 (- (sqrt (+ 1.0 z)) (sqrt z)))
(t_3 (sqrt (+ y 1.0)))
(t_4 (+ t_2 (+ (- t_3 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_4 1.0)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_2)
(if (<= t_4 2.0002)
(- (+ (+ 1.0 t_3) (* 0.5 (sqrt (/ 1.0 z)))) (+ (sqrt y) (sqrt x)))
(+
(+ t_2 (- (sqrt (+ 1.0 t)) (sqrt t)))
(- (- 2.0 (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 + x));
double t_2 = sqrt((1.0 + z)) - sqrt(z);
double t_3 = sqrt((y + 1.0));
double t_4 = t_2 + ((t_3 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_4 <= 1.0) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_2;
} else if (t_4 <= 2.0002) {
tmp = ((1.0 + t_3) + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x));
} else {
tmp = (t_2 + (sqrt((1.0 + t)) - sqrt(t))) + ((2.0 - 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((1.0d0 + x))
t_2 = sqrt((1.0d0 + z)) - sqrt(z)
t_3 = sqrt((y + 1.0d0))
t_4 = t_2 + ((t_3 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_4 <= 1.0d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_2
else if (t_4 <= 2.0002d0) then
tmp = ((1.0d0 + t_3) + (0.5d0 * sqrt((1.0d0 / z)))) - (sqrt(y) + sqrt(x))
else
tmp = (t_2 + (sqrt((1.0d0 + t)) - sqrt(t))) + ((2.0d0 - 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((1.0 + x));
double t_2 = Math.sqrt((1.0 + z)) - Math.sqrt(z);
double t_3 = Math.sqrt((y + 1.0));
double t_4 = t_2 + ((t_3 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_4 <= 1.0) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_2;
} else if (t_4 <= 2.0002) {
tmp = ((1.0 + t_3) + (0.5 * Math.sqrt((1.0 / z)))) - (Math.sqrt(y) + Math.sqrt(x));
} else {
tmp = (t_2 + (Math.sqrt((1.0 + t)) - Math.sqrt(t))) + ((2.0 - 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((1.0 + x)) t_2 = math.sqrt((1.0 + z)) - math.sqrt(z) t_3 = math.sqrt((y + 1.0)) t_4 = t_2 + ((t_3 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_4 <= 1.0: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_2 elif t_4 <= 2.0002: tmp = ((1.0 + t_3) + (0.5 * math.sqrt((1.0 / z)))) - (math.sqrt(y) + math.sqrt(x)) else: tmp = (t_2 + (math.sqrt((1.0 + t)) - math.sqrt(t))) + ((2.0 - 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(1.0 + x)) t_2 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) t_3 = sqrt(Float64(y + 1.0)) t_4 = Float64(t_2 + Float64(Float64(t_3 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_4 <= 1.0) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_2); elseif (t_4 <= 2.0002) tmp = Float64(Float64(Float64(1.0 + t_3) + Float64(0.5 * sqrt(Float64(1.0 / z)))) - Float64(sqrt(y) + sqrt(x))); else tmp = Float64(Float64(t_2 + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + Float64(Float64(2.0 - 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((1.0 + x));
t_2 = sqrt((1.0 + z)) - sqrt(z);
t_3 = sqrt((y + 1.0));
t_4 = t_2 + ((t_3 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_4 <= 1.0)
tmp = (1.0 / (sqrt(x) + t_1)) + t_2;
elseif (t_4 <= 2.0002)
tmp = ((1.0 + t_3) + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x));
else
tmp = (t_2 + (sqrt((1.0 + t)) - sqrt(t))) + ((2.0 - 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[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 + N[(N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 1.0], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], If[LessEqual[t$95$4, 2.0002], N[(N[(N[(1.0 + t$95$3), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x}\\
t_2 := \sqrt{1 + z} - \sqrt{z}\\
t_3 := \sqrt{y + 1}\\
t_4 := t\_2 + \left(\left(t\_3 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_4 \leq 1:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_2\\
\mathbf{elif}\;t\_4 \leq 2.0002:\\
\;\;\;\;\left(\left(1 + t\_3\right) + 0.5 \cdot \sqrt{\frac{1}{z}}\right) - \left(\sqrt{y} + \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(\left(2 - \sqrt{x}\right) - \sqrt{y}\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))) < 1Initial program 88.5%
associate-+l+88.5%
sub-neg88.5%
sub-neg88.5%
+-commutative88.5%
+-commutative88.5%
+-commutative88.5%
Simplified88.5%
flip--88.5%
add-sqr-sqrt61.8%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in y around inf 69.2%
Taylor expanded in t around inf 37.2%
if 1 < (+.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 97.9%
associate-+l+97.9%
sub-neg97.9%
sub-neg97.9%
+-commutative97.9%
+-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in t around inf 5.3%
associate--l+15.0%
Simplified15.0%
Taylor expanded in z around inf 19.6%
associate--l+22.1%
Simplified22.1%
Taylor expanded in x around 0 18.4%
associate-+r+18.4%
Simplified18.4%
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 97.6%
associate-+l+97.6%
sub-neg97.6%
sub-neg97.6%
+-commutative97.6%
+-commutative97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in x around 0 92.9%
associate--l+93.0%
Simplified93.0%
Taylor expanded in y around 0 89.5%
associate--r+89.5%
Simplified89.5%
Final simplification37.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 x)))
(t_2 (+ (sqrt y) (sqrt x)))
(t_3 (sqrt (+ 1.0 z)))
(t_4 (- t_3 (sqrt z)))
(t_5 (sqrt (+ y 1.0)))
(t_6 (+ t_4 (+ (- t_5 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_6 1.0)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_4)
(if (<= t_6 2.0002)
(- (+ (+ 1.0 t_5) (* 0.5 (sqrt (/ 1.0 z)))) t_2)
(+ 1.0 (+ t_5 (- t_3 (+ (sqrt z) t_2))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + x));
double t_2 = sqrt(y) + sqrt(x);
double t_3 = sqrt((1.0 + z));
double t_4 = t_3 - sqrt(z);
double t_5 = sqrt((y + 1.0));
double t_6 = t_4 + ((t_5 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_6 <= 1.0) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_4;
} else if (t_6 <= 2.0002) {
tmp = ((1.0 + t_5) + (0.5 * sqrt((1.0 / z)))) - t_2;
} else {
tmp = 1.0 + (t_5 + (t_3 - (sqrt(z) + t_2)));
}
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((1.0d0 + x))
t_2 = sqrt(y) + sqrt(x)
t_3 = sqrt((1.0d0 + z))
t_4 = t_3 - sqrt(z)
t_5 = sqrt((y + 1.0d0))
t_6 = t_4 + ((t_5 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_6 <= 1.0d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_4
else if (t_6 <= 2.0002d0) then
tmp = ((1.0d0 + t_5) + (0.5d0 * sqrt((1.0d0 / z)))) - t_2
else
tmp = 1.0d0 + (t_5 + (t_3 - (sqrt(z) + t_2)))
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 + x));
double t_2 = Math.sqrt(y) + Math.sqrt(x);
double t_3 = Math.sqrt((1.0 + z));
double t_4 = t_3 - Math.sqrt(z);
double t_5 = Math.sqrt((y + 1.0));
double t_6 = t_4 + ((t_5 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_6 <= 1.0) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_4;
} else if (t_6 <= 2.0002) {
tmp = ((1.0 + t_5) + (0.5 * Math.sqrt((1.0 / z)))) - t_2;
} else {
tmp = 1.0 + (t_5 + (t_3 - (Math.sqrt(z) + t_2)));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((1.0 + x)) t_2 = math.sqrt(y) + math.sqrt(x) t_3 = math.sqrt((1.0 + z)) t_4 = t_3 - math.sqrt(z) t_5 = math.sqrt((y + 1.0)) t_6 = t_4 + ((t_5 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_6 <= 1.0: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_4 elif t_6 <= 2.0002: tmp = ((1.0 + t_5) + (0.5 * math.sqrt((1.0 / z)))) - t_2 else: tmp = 1.0 + (t_5 + (t_3 - (math.sqrt(z) + t_2))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + x)) t_2 = Float64(sqrt(y) + sqrt(x)) t_3 = sqrt(Float64(1.0 + z)) t_4 = Float64(t_3 - sqrt(z)) t_5 = sqrt(Float64(y + 1.0)) t_6 = Float64(t_4 + Float64(Float64(t_5 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_6 <= 1.0) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_4); elseif (t_6 <= 2.0002) tmp = Float64(Float64(Float64(1.0 + t_5) + Float64(0.5 * sqrt(Float64(1.0 / z)))) - t_2); else tmp = Float64(1.0 + Float64(t_5 + Float64(t_3 - Float64(sqrt(z) + t_2)))); 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 + x));
t_2 = sqrt(y) + sqrt(x);
t_3 = sqrt((1.0 + z));
t_4 = t_3 - sqrt(z);
t_5 = sqrt((y + 1.0));
t_6 = t_4 + ((t_5 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_6 <= 1.0)
tmp = (1.0 / (sqrt(x) + t_1)) + t_4;
elseif (t_6 <= 2.0002)
tmp = ((1.0 + t_5) + (0.5 * sqrt((1.0 / z)))) - t_2;
else
tmp = 1.0 + (t_5 + (t_3 - (sqrt(z) + t_2)));
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 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $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[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$4 + N[(N[(t$95$5 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$6, 1.0], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision], If[LessEqual[t$95$6, 2.0002], N[(N[(N[(1.0 + t$95$5), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision], N[(1.0 + N[(t$95$5 + N[(t$95$3 - N[(N[Sqrt[z], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x}\\
t_2 := \sqrt{y} + \sqrt{x}\\
t_3 := \sqrt{1 + z}\\
t_4 := t\_3 - \sqrt{z}\\
t_5 := \sqrt{y + 1}\\
t_6 := t\_4 + \left(\left(t\_5 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_6 \leq 1:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_4\\
\mathbf{elif}\;t\_6 \leq 2.0002:\\
\;\;\;\;\left(\left(1 + t\_5\right) + 0.5 \cdot \sqrt{\frac{1}{z}}\right) - t\_2\\
\mathbf{else}:\\
\;\;\;\;1 + \left(t\_5 + \left(t\_3 - \left(\sqrt{z} + t\_2\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))) < 1Initial program 88.5%
associate-+l+88.5%
sub-neg88.5%
sub-neg88.5%
+-commutative88.5%
+-commutative88.5%
+-commutative88.5%
Simplified88.5%
flip--88.5%
add-sqr-sqrt61.8%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in y around inf 69.2%
Taylor expanded in t around inf 37.2%
if 1 < (+.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 97.9%
associate-+l+97.9%
sub-neg97.9%
sub-neg97.9%
+-commutative97.9%
+-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in t around inf 5.3%
associate--l+15.0%
Simplified15.0%
Taylor expanded in z around inf 19.6%
associate--l+22.1%
Simplified22.1%
Taylor expanded in x around 0 18.4%
associate-+r+18.4%
Simplified18.4%
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 97.6%
associate-+l+97.6%
sub-neg97.6%
sub-neg97.6%
+-commutative97.6%
+-commutative97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in t around inf 55.3%
associate--l+55.3%
Simplified55.3%
Taylor expanded in x around 0 52.6%
associate-+r+52.6%
associate--l+52.6%
associate-+r-52.6%
+-commutative52.6%
Simplified52.6%
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 (+ 1.0 x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- t_2 (sqrt z)))
(t_4 (sqrt (+ y 1.0)))
(t_5 (+ t_3 (+ (- t_4 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_5 1.0)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_3)
(if (<= t_5 2.0002)
(- (+ (+ 1.0 t_4) (* 0.5 (sqrt (/ 1.0 z)))) (+ (sqrt y) (sqrt x)))
(- (+ 2.0 (+ t_2 (* y 0.5))) (+ (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 + x));
double t_2 = sqrt((1.0 + z));
double t_3 = t_2 - sqrt(z);
double t_4 = sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_5 <= 1.0) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = ((1.0 + t_4) + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x));
} else {
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x))
t_2 = sqrt((1.0d0 + z))
t_3 = t_2 - sqrt(z)
t_4 = sqrt((y + 1.0d0))
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_5 <= 1.0d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_3
else if (t_5 <= 2.0002d0) then
tmp = ((1.0d0 + t_4) + (0.5d0 * sqrt((1.0d0 / z)))) - (sqrt(y) + sqrt(x))
else
tmp = (2.0d0 + (t_2 + (y * 0.5d0))) - (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 + x));
double t_2 = Math.sqrt((1.0 + z));
double t_3 = t_2 - Math.sqrt(z);
double t_4 = Math.sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_5 <= 1.0) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = ((1.0 + t_4) + (0.5 * Math.sqrt((1.0 / z)))) - (Math.sqrt(y) + Math.sqrt(x));
} else {
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x)) t_2 = math.sqrt((1.0 + z)) t_3 = t_2 - math.sqrt(z) t_4 = math.sqrt((y + 1.0)) t_5 = t_3 + ((t_4 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_5 <= 1.0: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_3 elif t_5 <= 2.0002: tmp = ((1.0 + t_4) + (0.5 * math.sqrt((1.0 / z)))) - (math.sqrt(y) + math.sqrt(x)) else: tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(t_2 - sqrt(z)) t_4 = sqrt(Float64(y + 1.0)) t_5 = Float64(t_3 + Float64(Float64(t_4 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_5 <= 1.0) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_3); elseif (t_5 <= 2.0002) tmp = Float64(Float64(Float64(1.0 + t_4) + Float64(0.5 * sqrt(Float64(1.0 / z)))) - Float64(sqrt(y) + sqrt(x))); else tmp = Float64(Float64(2.0 + Float64(t_2 + Float64(y * 0.5))) - 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 + x));
t_2 = sqrt((1.0 + z));
t_3 = t_2 - sqrt(z);
t_4 = sqrt((y + 1.0));
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_5 <= 1.0)
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
elseif (t_5 <= 2.0002)
tmp = ((1.0 + t_4) + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x));
else
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(t$95$4 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 1.0], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 2.0002], N[(N[(N[(1.0 + t$95$4), $MachinePrecision] + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(t$95$2 + N[(y * 0.5), $MachinePrecision]), $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{1 + x}\\
t_2 := \sqrt{1 + z}\\
t_3 := t\_2 - \sqrt{z}\\
t_4 := \sqrt{y + 1}\\
t_5 := t\_3 + \left(\left(t\_4 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_5 \leq 1:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_3\\
\mathbf{elif}\;t\_5 \leq 2.0002:\\
\;\;\;\;\left(\left(1 + t\_4\right) + 0.5 \cdot \sqrt{\frac{1}{z}}\right) - \left(\sqrt{y} + \sqrt{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(2 + \left(t\_2 + y \cdot 0.5\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\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))) < 1Initial program 88.5%
associate-+l+88.5%
sub-neg88.5%
sub-neg88.5%
+-commutative88.5%
+-commutative88.5%
+-commutative88.5%
Simplified88.5%
flip--88.5%
add-sqr-sqrt61.8%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in y around inf 69.2%
Taylor expanded in t around inf 37.2%
if 1 < (+.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 97.9%
associate-+l+97.9%
sub-neg97.9%
sub-neg97.9%
+-commutative97.9%
+-commutative97.9%
+-commutative97.9%
Simplified97.9%
Taylor expanded in t around inf 5.3%
associate--l+15.0%
Simplified15.0%
Taylor expanded in z around inf 19.6%
associate--l+22.1%
Simplified22.1%
Taylor expanded in x around 0 18.4%
associate-+r+18.4%
Simplified18.4%
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 97.6%
associate-+l+97.6%
sub-neg97.6%
sub-neg97.6%
+-commutative97.6%
+-commutative97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in t around inf 55.3%
associate--l+55.3%
Simplified55.3%
Taylor expanded in x around 0 52.6%
associate-+r+52.6%
associate--l+52.6%
associate-+r-52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in y around 0 50.6%
Final simplification31.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 (+ 1.0 x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- t_2 (sqrt z)))
(t_4 (sqrt (+ y 1.0)))
(t_5 (+ t_3 (+ (- t_4 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_5 0.9999999999999372)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_3)
(if (<= t_5 2.0002)
(+ 1.0 (- (+ t_4 (* 0.5 (sqrt (/ 1.0 z)))) (+ (sqrt y) (sqrt x))))
(- (+ 2.0 (+ t_2 (* y 0.5))) (+ (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 + x));
double t_2 = sqrt((1.0 + z));
double t_3 = t_2 - sqrt(z);
double t_4 = sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = 1.0 + ((t_4 + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x)));
} else {
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x))
t_2 = sqrt((1.0d0 + z))
t_3 = t_2 - sqrt(z)
t_4 = sqrt((y + 1.0d0))
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_5 <= 0.9999999999999372d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_3
else if (t_5 <= 2.0002d0) then
tmp = 1.0d0 + ((t_4 + (0.5d0 * sqrt((1.0d0 / z)))) - (sqrt(y) + sqrt(x)))
else
tmp = (2.0d0 + (t_2 + (y * 0.5d0))) - (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 + x));
double t_2 = Math.sqrt((1.0 + z));
double t_3 = t_2 - Math.sqrt(z);
double t_4 = Math.sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = 1.0 + ((t_4 + (0.5 * Math.sqrt((1.0 / z)))) - (Math.sqrt(y) + Math.sqrt(x)));
} else {
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x)) t_2 = math.sqrt((1.0 + z)) t_3 = t_2 - math.sqrt(z) t_4 = math.sqrt((y + 1.0)) t_5 = t_3 + ((t_4 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_5 <= 0.9999999999999372: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_3 elif t_5 <= 2.0002: tmp = 1.0 + ((t_4 + (0.5 * math.sqrt((1.0 / z)))) - (math.sqrt(y) + math.sqrt(x))) else: tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(t_2 - sqrt(z)) t_4 = sqrt(Float64(y + 1.0)) t_5 = Float64(t_3 + Float64(Float64(t_4 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_5 <= 0.9999999999999372) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_3); elseif (t_5 <= 2.0002) tmp = Float64(1.0 + Float64(Float64(t_4 + Float64(0.5 * sqrt(Float64(1.0 / z)))) - Float64(sqrt(y) + sqrt(x)))); else tmp = Float64(Float64(2.0 + Float64(t_2 + Float64(y * 0.5))) - 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 + x));
t_2 = sqrt((1.0 + z));
t_3 = t_2 - sqrt(z);
t_4 = sqrt((y + 1.0));
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_5 <= 0.9999999999999372)
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
elseif (t_5 <= 2.0002)
tmp = 1.0 + ((t_4 + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x)));
else
tmp = (2.0 + (t_2 + (y * 0.5))) - (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 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(t$95$4 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.9999999999999372], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 2.0002], N[(1.0 + N[(N[(t$95$4 + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(t$95$2 + N[(y * 0.5), $MachinePrecision]), $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{1 + x}\\
t_2 := \sqrt{1 + z}\\
t_3 := t\_2 - \sqrt{z}\\
t_4 := \sqrt{y + 1}\\
t_5 := t\_3 + \left(\left(t\_4 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_5 \leq 0.9999999999999372:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_3\\
\mathbf{elif}\;t\_5 \leq 2.0002:\\
\;\;\;\;1 + \left(\left(t\_4 + 0.5 \cdot \sqrt{\frac{1}{z}}\right) - \left(\sqrt{y} + \sqrt{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(2 + \left(t\_2 + y \cdot 0.5\right)\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
flip--66.6%
add-sqr-sqrt43.2%
add-sqr-sqrt68.1%
Applied egg-rr68.1%
Taylor expanded in y around inf 60.4%
Taylor expanded in t around inf 26.5%
if 0.99999999999993716 < (+.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 97.8%
associate-+l+97.8%
sub-neg97.8%
sub-neg97.8%
+-commutative97.8%
+-commutative97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in t around inf 4.4%
associate--l+18.4%
Simplified18.4%
Taylor expanded in z around inf 13.0%
associate--l+22.3%
Simplified22.3%
Taylor expanded in x around 0 22.4%
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 97.6%
associate-+l+97.6%
sub-neg97.6%
sub-neg97.6%
+-commutative97.6%
+-commutative97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in t around inf 55.3%
associate--l+55.3%
Simplified55.3%
Taylor expanded in x around 0 52.6%
associate-+r+52.6%
associate--l+52.6%
associate-+r-52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in y around 0 50.6%
Final simplification27.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 (+ 1.0 x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- t_2 (sqrt z)))
(t_4 (sqrt (+ y 1.0)))
(t_5 (+ t_3 (+ (- t_4 (sqrt y)) (- t_1 (sqrt x))))))
(if (<= t_5 0.9999999999999372)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_3)
(if (<= t_5 2.0002)
(+ 1.0 (- (+ t_4 (* 0.5 (sqrt (/ 1.0 z)))) (+ (sqrt y) (sqrt x))))
(- (+ t_2 2.0) (+ (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 + x));
double t_2 = sqrt((1.0 + z));
double t_3 = t_2 - sqrt(z);
double t_4 = sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = 1.0 + ((t_4 + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x)));
} else {
tmp = (t_2 + 2.0) - (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 + x))
t_2 = sqrt((1.0d0 + z))
t_3 = t_2 - sqrt(z)
t_4 = sqrt((y + 1.0d0))
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)))
if (t_5 <= 0.9999999999999372d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_3
else if (t_5 <= 2.0002d0) then
tmp = 1.0d0 + ((t_4 + (0.5d0 * sqrt((1.0d0 / z)))) - (sqrt(y) + sqrt(x)))
else
tmp = (t_2 + 2.0d0) - (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 + x));
double t_2 = Math.sqrt((1.0 + z));
double t_3 = t_2 - Math.sqrt(z);
double t_4 = Math.sqrt((y + 1.0));
double t_5 = t_3 + ((t_4 - Math.sqrt(y)) + (t_1 - Math.sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0002) {
tmp = 1.0 + ((t_4 + (0.5 * Math.sqrt((1.0 / z)))) - (Math.sqrt(y) + Math.sqrt(x)));
} else {
tmp = (t_2 + 2.0) - (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 + x)) t_2 = math.sqrt((1.0 + z)) t_3 = t_2 - math.sqrt(z) t_4 = math.sqrt((y + 1.0)) t_5 = t_3 + ((t_4 - math.sqrt(y)) + (t_1 - math.sqrt(x))) tmp = 0 if t_5 <= 0.9999999999999372: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_3 elif t_5 <= 2.0002: tmp = 1.0 + ((t_4 + (0.5 * math.sqrt((1.0 / z)))) - (math.sqrt(y) + math.sqrt(x))) else: tmp = (t_2 + 2.0) - (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 + x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(t_2 - sqrt(z)) t_4 = sqrt(Float64(y + 1.0)) t_5 = Float64(t_3 + Float64(Float64(t_4 - sqrt(y)) + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_5 <= 0.9999999999999372) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_3); elseif (t_5 <= 2.0002) tmp = Float64(1.0 + Float64(Float64(t_4 + Float64(0.5 * sqrt(Float64(1.0 / z)))) - Float64(sqrt(y) + sqrt(x)))); else tmp = Float64(Float64(t_2 + 2.0) - 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 + x));
t_2 = sqrt((1.0 + z));
t_3 = t_2 - sqrt(z);
t_4 = sqrt((y + 1.0));
t_5 = t_3 + ((t_4 - sqrt(y)) + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_5 <= 0.9999999999999372)
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
elseif (t_5 <= 2.0002)
tmp = 1.0 + ((t_4 + (0.5 * sqrt((1.0 / z)))) - (sqrt(y) + sqrt(x)));
else
tmp = (t_2 + 2.0) - (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 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(N[(t$95$4 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.9999999999999372], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 2.0002], N[(1.0 + N[(N[(t$95$4 + N[(0.5 * N[Sqrt[N[(1.0 / z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + 2.0), $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{1 + x}\\
t_2 := \sqrt{1 + z}\\
t_3 := t\_2 - \sqrt{z}\\
t_4 := \sqrt{y + 1}\\
t_5 := t\_3 + \left(\left(t\_4 - \sqrt{y}\right) + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_5 \leq 0.9999999999999372:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_3\\
\mathbf{elif}\;t\_5 \leq 2.0002:\\
\;\;\;\;1 + \left(\left(t\_4 + 0.5 \cdot \sqrt{\frac{1}{z}}\right) - \left(\sqrt{y} + \sqrt{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + 2\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
flip--66.6%
add-sqr-sqrt43.2%
add-sqr-sqrt68.1%
Applied egg-rr68.1%
Taylor expanded in y around inf 60.4%
Taylor expanded in t around inf 26.5%
if 0.99999999999993716 < (+.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 97.8%
associate-+l+97.8%
sub-neg97.8%
sub-neg97.8%
+-commutative97.8%
+-commutative97.8%
+-commutative97.8%
Simplified97.8%
Taylor expanded in t around inf 4.4%
associate--l+18.4%
Simplified18.4%
Taylor expanded in z around inf 13.0%
associate--l+22.3%
Simplified22.3%
Taylor expanded in x around 0 22.4%
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 97.6%
associate-+l+97.6%
sub-neg97.6%
sub-neg97.6%
+-commutative97.6%
+-commutative97.6%
+-commutative97.6%
Simplified97.6%
Taylor expanded in t around inf 55.3%
associate--l+55.3%
Simplified55.3%
Taylor expanded in x around 0 52.6%
associate-+r+52.6%
associate--l+52.6%
associate-+r-52.6%
+-commutative52.6%
Simplified52.6%
Taylor expanded in y around 0 50.1%
Final simplification27.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 (+ 1.0 x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- t_2 (sqrt z)))
(t_4 (- (sqrt (+ y 1.0)) (sqrt y)))
(t_5 (+ t_3 (+ t_4 (- t_1 (sqrt x))))))
(if (<= t_5 0.9999999999999372)
(+ (/ 1.0 (+ (sqrt x) t_1)) t_3)
(if (<= t_5 2.0)
(+ 1.0 t_4)
(- (+ t_2 2.0) (+ (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 + x));
double t_2 = sqrt((1.0 + z));
double t_3 = t_2 - sqrt(z);
double t_4 = sqrt((y + 1.0)) - sqrt(y);
double t_5 = t_3 + (t_4 + (t_1 - sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0) {
tmp = 1.0 + t_4;
} else {
tmp = (t_2 + 2.0) - (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 + x))
t_2 = sqrt((1.0d0 + z))
t_3 = t_2 - sqrt(z)
t_4 = sqrt((y + 1.0d0)) - sqrt(y)
t_5 = t_3 + (t_4 + (t_1 - sqrt(x)))
if (t_5 <= 0.9999999999999372d0) then
tmp = (1.0d0 / (sqrt(x) + t_1)) + t_3
else if (t_5 <= 2.0d0) then
tmp = 1.0d0 + t_4
else
tmp = (t_2 + 2.0d0) - (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 + x));
double t_2 = Math.sqrt((1.0 + z));
double t_3 = t_2 - Math.sqrt(z);
double t_4 = Math.sqrt((y + 1.0)) - Math.sqrt(y);
double t_5 = t_3 + (t_4 + (t_1 - Math.sqrt(x)));
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = (1.0 / (Math.sqrt(x) + t_1)) + t_3;
} else if (t_5 <= 2.0) {
tmp = 1.0 + t_4;
} else {
tmp = (t_2 + 2.0) - (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 + x)) t_2 = math.sqrt((1.0 + z)) t_3 = t_2 - math.sqrt(z) t_4 = math.sqrt((y + 1.0)) - math.sqrt(y) t_5 = t_3 + (t_4 + (t_1 - math.sqrt(x))) tmp = 0 if t_5 <= 0.9999999999999372: tmp = (1.0 / (math.sqrt(x) + t_1)) + t_3 elif t_5 <= 2.0: tmp = 1.0 + t_4 else: tmp = (t_2 + 2.0) - (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 + x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(t_2 - sqrt(z)) t_4 = Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) t_5 = Float64(t_3 + Float64(t_4 + Float64(t_1 - sqrt(x)))) tmp = 0.0 if (t_5 <= 0.9999999999999372) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_1)) + t_3); elseif (t_5 <= 2.0) tmp = Float64(1.0 + t_4); else tmp = Float64(Float64(t_2 + 2.0) - 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 + x));
t_2 = sqrt((1.0 + z));
t_3 = t_2 - sqrt(z);
t_4 = sqrt((y + 1.0)) - sqrt(y);
t_5 = t_3 + (t_4 + (t_1 - sqrt(x)));
tmp = 0.0;
if (t_5 <= 0.9999999999999372)
tmp = (1.0 / (sqrt(x) + t_1)) + t_3;
elseif (t_5 <= 2.0)
tmp = 1.0 + t_4;
else
tmp = (t_2 + 2.0) - (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 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 + N[(t$95$4 + N[(t$95$1 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.9999999999999372], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision], If[LessEqual[t$95$5, 2.0], N[(1.0 + t$95$4), $MachinePrecision], N[(N[(t$95$2 + 2.0), $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{1 + x}\\
t_2 := \sqrt{1 + z}\\
t_3 := t\_2 - \sqrt{z}\\
t_4 := \sqrt{y + 1} - \sqrt{y}\\
t_5 := t\_3 + \left(t\_4 + \left(t\_1 - \sqrt{x}\right)\right)\\
\mathbf{if}\;t\_5 \leq 0.9999999999999372:\\
\;\;\;\;\frac{1}{\sqrt{x} + t\_1} + t\_3\\
\mathbf{elif}\;t\_5 \leq 2:\\
\;\;\;\;1 + t\_4\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + 2\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
flip--66.6%
add-sqr-sqrt43.2%
add-sqr-sqrt68.1%
Applied egg-rr68.1%
Taylor expanded in y around inf 60.4%
Taylor expanded in t around inf 26.5%
if 0.99999999999993716 < (+.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 98.1%
associate-+l+98.1%
sub-neg98.1%
sub-neg98.1%
+-commutative98.1%
+-commutative98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in t around inf 3.9%
associate--l+18.0%
Simplified18.0%
Taylor expanded in x around 0 3.2%
associate-+r+3.2%
associate--l+22.1%
associate-+r-22.5%
+-commutative22.5%
Simplified22.5%
Taylor expanded in y around inf 47.9%
mul-1-neg47.9%
Simplified47.9%
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 96.5%
associate-+l+96.5%
sub-neg96.5%
sub-neg96.5%
+-commutative96.5%
+-commutative96.5%
+-commutative96.5%
Simplified96.5%
Taylor expanded in t around inf 55.1%
associate--l+55.1%
Simplified55.1%
Taylor expanded in x around 0 52.5%
associate-+r+52.5%
associate--l+52.5%
associate-+r-52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around 0 50.1%
Final simplification45.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 (+ 1.0 x)) (sqrt x)))
(t_2 (sqrt (+ 1.0 z)))
(t_3 (- (sqrt (+ y 1.0)) (sqrt y)))
(t_4 (+ (- t_2 (sqrt z)) (+ t_3 t_1))))
(if (<= t_4 0.9999999999999372)
t_1
(if (<= t_4 2.0)
(+ 1.0 t_3)
(- (+ t_2 2.0) (+ (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 + x)) - sqrt(x);
double t_2 = sqrt((1.0 + z));
double t_3 = sqrt((y + 1.0)) - sqrt(y);
double t_4 = (t_2 - sqrt(z)) + (t_3 + t_1);
double tmp;
if (t_4 <= 0.9999999999999372) {
tmp = t_1;
} else if (t_4 <= 2.0) {
tmp = 1.0 + t_3;
} else {
tmp = (t_2 + 2.0) - (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) :: tmp
t_1 = sqrt((1.0d0 + x)) - sqrt(x)
t_2 = sqrt((1.0d0 + z))
t_3 = sqrt((y + 1.0d0)) - sqrt(y)
t_4 = (t_2 - sqrt(z)) + (t_3 + t_1)
if (t_4 <= 0.9999999999999372d0) then
tmp = t_1
else if (t_4 <= 2.0d0) then
tmp = 1.0d0 + t_3
else
tmp = (t_2 + 2.0d0) - (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 + x)) - Math.sqrt(x);
double t_2 = Math.sqrt((1.0 + z));
double t_3 = Math.sqrt((y + 1.0)) - Math.sqrt(y);
double t_4 = (t_2 - Math.sqrt(z)) + (t_3 + t_1);
double tmp;
if (t_4 <= 0.9999999999999372) {
tmp = t_1;
} else if (t_4 <= 2.0) {
tmp = 1.0 + t_3;
} else {
tmp = (t_2 + 2.0) - (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 + x)) - math.sqrt(x) t_2 = math.sqrt((1.0 + z)) t_3 = math.sqrt((y + 1.0)) - math.sqrt(y) t_4 = (t_2 - math.sqrt(z)) + (t_3 + t_1) tmp = 0 if t_4 <= 0.9999999999999372: tmp = t_1 elif t_4 <= 2.0: tmp = 1.0 + t_3 else: tmp = (t_2 + 2.0) - (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 = Float64(sqrt(Float64(1.0 + x)) - sqrt(x)) t_2 = sqrt(Float64(1.0 + z)) t_3 = Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) t_4 = Float64(Float64(t_2 - sqrt(z)) + Float64(t_3 + t_1)) tmp = 0.0 if (t_4 <= 0.9999999999999372) tmp = t_1; elseif (t_4 <= 2.0) tmp = Float64(1.0 + t_3); else tmp = Float64(Float64(t_2 + 2.0) - 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 + x)) - sqrt(x);
t_2 = sqrt((1.0 + z));
t_3 = sqrt((y + 1.0)) - sqrt(y);
t_4 = (t_2 - sqrt(z)) + (t_3 + t_1);
tmp = 0.0;
if (t_4 <= 0.9999999999999372)
tmp = t_1;
elseif (t_4 <= 2.0)
tmp = 1.0 + t_3;
else
tmp = (t_2 + 2.0) - (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[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$2 - N[Sqrt[z], $MachinePrecision]), $MachinePrecision] + N[(t$95$3 + t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, 0.9999999999999372], t$95$1, If[LessEqual[t$95$4, 2.0], N[(1.0 + t$95$3), $MachinePrecision], N[(N[(t$95$2 + 2.0), $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{1 + x} - \sqrt{x}\\
t_2 := \sqrt{1 + z}\\
t_3 := \sqrt{y + 1} - \sqrt{y}\\
t_4 := \left(t\_2 - \sqrt{z}\right) + \left(t\_3 + t\_1\right)\\
\mathbf{if}\;t\_4 \leq 0.9999999999999372:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_4 \leq 2:\\
\;\;\;\;1 + t\_3\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + 2\right) - \left(\sqrt{x} + \left(\sqrt{y} + \sqrt{z}\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
Taylor expanded in t around inf 3.2%
associate--l+6.4%
Simplified6.4%
Taylor expanded in x around inf 7.0%
neg-mul-17.0%
Simplified7.0%
if 0.99999999999993716 < (+.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 98.1%
associate-+l+98.1%
sub-neg98.1%
sub-neg98.1%
+-commutative98.1%
+-commutative98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in t around inf 3.9%
associate--l+18.0%
Simplified18.0%
Taylor expanded in x around 0 3.2%
associate-+r+3.2%
associate--l+22.1%
associate-+r-22.5%
+-commutative22.5%
Simplified22.5%
Taylor expanded in y around inf 47.9%
mul-1-neg47.9%
Simplified47.9%
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 96.5%
associate-+l+96.5%
sub-neg96.5%
sub-neg96.5%
+-commutative96.5%
+-commutative96.5%
+-commutative96.5%
Simplified96.5%
Taylor expanded in t around inf 55.1%
associate--l+55.1%
Simplified55.1%
Taylor expanded in x around 0 52.5%
associate-+r+52.5%
associate--l+52.5%
associate-+r-52.5%
+-commutative52.5%
Simplified52.5%
Taylor expanded in y around 0 50.1%
Final simplification43.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 x)) (sqrt x)))
(t_2 (- (sqrt (+ 1.0 z)) (sqrt z)))
(t_3 (sqrt (+ y 1.0)))
(t_4 (- t_3 (sqrt y)))
(t_5 (+ t_2 (+ t_4 t_1))))
(if (<= t_5 0.9999999999999372)
t_1
(if (<= t_5 1.9999999999999947) (+ 1.0 t_4) (+ 1.0 (+ t_2 t_3))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + x)) - sqrt(x);
double t_2 = sqrt((1.0 + z)) - sqrt(z);
double t_3 = sqrt((y + 1.0));
double t_4 = t_3 - sqrt(y);
double t_5 = t_2 + (t_4 + t_1);
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = t_1;
} else if (t_5 <= 1.9999999999999947) {
tmp = 1.0 + t_4;
} else {
tmp = 1.0 + (t_2 + t_3);
}
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 + x)) - sqrt(x)
t_2 = sqrt((1.0d0 + z)) - sqrt(z)
t_3 = sqrt((y + 1.0d0))
t_4 = t_3 - sqrt(y)
t_5 = t_2 + (t_4 + t_1)
if (t_5 <= 0.9999999999999372d0) then
tmp = t_1
else if (t_5 <= 1.9999999999999947d0) then
tmp = 1.0d0 + t_4
else
tmp = 1.0d0 + (t_2 + t_3)
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 + x)) - Math.sqrt(x);
double t_2 = Math.sqrt((1.0 + z)) - Math.sqrt(z);
double t_3 = Math.sqrt((y + 1.0));
double t_4 = t_3 - Math.sqrt(y);
double t_5 = t_2 + (t_4 + t_1);
double tmp;
if (t_5 <= 0.9999999999999372) {
tmp = t_1;
} else if (t_5 <= 1.9999999999999947) {
tmp = 1.0 + t_4;
} else {
tmp = 1.0 + (t_2 + t_3);
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((1.0 + x)) - math.sqrt(x) t_2 = math.sqrt((1.0 + z)) - math.sqrt(z) t_3 = math.sqrt((y + 1.0)) t_4 = t_3 - math.sqrt(y) t_5 = t_2 + (t_4 + t_1) tmp = 0 if t_5 <= 0.9999999999999372: tmp = t_1 elif t_5 <= 1.9999999999999947: tmp = 1.0 + t_4 else: tmp = 1.0 + (t_2 + t_3) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(1.0 + x)) - sqrt(x)) t_2 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) t_3 = sqrt(Float64(y + 1.0)) t_4 = Float64(t_3 - sqrt(y)) t_5 = Float64(t_2 + Float64(t_4 + t_1)) tmp = 0.0 if (t_5 <= 0.9999999999999372) tmp = t_1; elseif (t_5 <= 1.9999999999999947) tmp = Float64(1.0 + t_4); else tmp = Float64(1.0 + Float64(t_2 + t_3)); 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 + x)) - sqrt(x);
t_2 = sqrt((1.0 + z)) - sqrt(z);
t_3 = sqrt((y + 1.0));
t_4 = t_3 - sqrt(y);
t_5 = t_2 + (t_4 + t_1);
tmp = 0.0;
if (t_5 <= 0.9999999999999372)
tmp = t_1;
elseif (t_5 <= 1.9999999999999947)
tmp = 1.0 + t_4;
else
tmp = 1.0 + (t_2 + t_3);
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[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 + N[(t$95$4 + t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, 0.9999999999999372], t$95$1, If[LessEqual[t$95$5, 1.9999999999999947], N[(1.0 + t$95$4), $MachinePrecision], N[(1.0 + N[(t$95$2 + t$95$3), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{1 + x} - \sqrt{x}\\
t_2 := \sqrt{1 + z} - \sqrt{z}\\
t_3 := \sqrt{y + 1}\\
t_4 := t\_3 - \sqrt{y}\\
t_5 := t\_2 + \left(t\_4 + t\_1\right)\\
\mathbf{if}\;t\_5 \leq 0.9999999999999372:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_5 \leq 1.9999999999999947:\\
\;\;\;\;1 + t\_4\\
\mathbf{else}:\\
\;\;\;\;1 + \left(t\_2 + t\_3\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))) < 0.99999999999993716Initial program 66.6%
associate-+l+66.6%
sub-neg66.6%
sub-neg66.6%
+-commutative66.6%
+-commutative66.6%
+-commutative66.6%
Simplified66.6%
Taylor expanded in t around inf 3.2%
associate--l+6.4%
Simplified6.4%
Taylor expanded in x around inf 7.0%
neg-mul-17.0%
Simplified7.0%
if 0.99999999999993716 < (+.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))) < 1.9999999999999947Initial program 97.1%
associate-+l+97.1%
sub-neg97.1%
sub-neg97.1%
+-commutative97.1%
+-commutative97.1%
+-commutative97.1%
Simplified97.1%
Taylor expanded in t around inf 3.6%
associate--l+20.8%
Simplified20.8%
Taylor expanded in x around 0 2.8%
associate-+r+2.8%
associate--l+28.2%
associate-+r-24.0%
+-commutative24.0%
Simplified24.0%
Taylor expanded in y around inf 50.9%
mul-1-neg50.9%
Simplified50.9%
if 1.9999999999999947 < (+.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.4%
associate-+l+98.4%
sub-neg98.4%
sub-neg98.4%
+-commutative98.4%
+-commutative98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in t around inf 23.3%
associate--l+29.3%
Simplified29.3%
Taylor expanded in x around 0 21.9%
associate-+r+21.9%
associate--l+28.0%
associate-+r-32.3%
+-commutative32.3%
Simplified32.3%
Taylor expanded in z around inf 39.0%
Final simplification40.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)))
(t_2 (- (sqrt (+ y 1.0)) (sqrt y)))
(t_3 (sqrt (+ 1.0 x)))
(t_4 (- (sqrt (+ 1.0 z)) (sqrt z))))
(if (<= t_2 5e-6)
(+
(+ (* 0.5 (sqrt (/ 1.0 y))) (/ 1.0 (+ (sqrt x) t_3)))
(+ t_4 (- t_1 (sqrt t))))
(+ (+ t_2 (- t_3 (sqrt x))) (+ t_4 (/ 1.0 (+ t_1 (sqrt t))))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((1.0 + t));
double t_2 = sqrt((y + 1.0)) - sqrt(y);
double t_3 = sqrt((1.0 + x));
double t_4 = sqrt((1.0 + z)) - sqrt(z);
double tmp;
if (t_2 <= 5e-6) {
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + t_3))) + (t_4 + (t_1 - sqrt(t)));
} else {
tmp = (t_2 + (t_3 - sqrt(x))) + (t_4 + (1.0 / (t_1 + 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) :: tmp
t_1 = sqrt((1.0d0 + t))
t_2 = sqrt((y + 1.0d0)) - sqrt(y)
t_3 = sqrt((1.0d0 + x))
t_4 = sqrt((1.0d0 + z)) - sqrt(z)
if (t_2 <= 5d-6) then
tmp = ((0.5d0 * sqrt((1.0d0 / y))) + (1.0d0 / (sqrt(x) + t_3))) + (t_4 + (t_1 - sqrt(t)))
else
tmp = (t_2 + (t_3 - sqrt(x))) + (t_4 + (1.0d0 / (t_1 + 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((1.0 + t));
double t_2 = Math.sqrt((y + 1.0)) - Math.sqrt(y);
double t_3 = Math.sqrt((1.0 + x));
double t_4 = Math.sqrt((1.0 + z)) - Math.sqrt(z);
double tmp;
if (t_2 <= 5e-6) {
tmp = ((0.5 * Math.sqrt((1.0 / y))) + (1.0 / (Math.sqrt(x) + t_3))) + (t_4 + (t_1 - Math.sqrt(t)));
} else {
tmp = (t_2 + (t_3 - Math.sqrt(x))) + (t_4 + (1.0 / (t_1 + Math.sqrt(t))));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((1.0 + t)) t_2 = math.sqrt((y + 1.0)) - math.sqrt(y) t_3 = math.sqrt((1.0 + x)) t_4 = math.sqrt((1.0 + z)) - math.sqrt(z) tmp = 0 if t_2 <= 5e-6: tmp = ((0.5 * math.sqrt((1.0 / y))) + (1.0 / (math.sqrt(x) + t_3))) + (t_4 + (t_1 - math.sqrt(t))) else: tmp = (t_2 + (t_3 - math.sqrt(x))) + (t_4 + (1.0 / (t_1 + math.sqrt(t)))) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = sqrt(Float64(1.0 + t)) t_2 = Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) t_3 = sqrt(Float64(1.0 + x)) t_4 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) tmp = 0.0 if (t_2 <= 5e-6) tmp = Float64(Float64(Float64(0.5 * sqrt(Float64(1.0 / y))) + Float64(1.0 / Float64(sqrt(x) + t_3))) + Float64(t_4 + Float64(t_1 - sqrt(t)))); else tmp = Float64(Float64(t_2 + Float64(t_3 - sqrt(x))) + Float64(t_4 + Float64(1.0 / Float64(t_1 + 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((1.0 + t));
t_2 = sqrt((y + 1.0)) - sqrt(y);
t_3 = sqrt((1.0 + x));
t_4 = sqrt((1.0 + z)) - sqrt(z);
tmp = 0.0;
if (t_2 <= 5e-6)
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + t_3))) + (t_4 + (t_1 - sqrt(t)));
else
tmp = (t_2 + (t_3 - sqrt(x))) + (t_4 + (1.0 / (t_1 + 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[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 5e-6], N[(N[(N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$4 + N[(t$95$1 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + N[(t$95$3 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$4 + N[(1.0 / N[(t$95$1 + N[Sqrt[t], $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 + t}\\
t_2 := \sqrt{y + 1} - \sqrt{y}\\
t_3 := \sqrt{1 + x}\\
t_4 := \sqrt{1 + z} - \sqrt{z}\\
\mathbf{if}\;t\_2 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot \sqrt{\frac{1}{y}} + \frac{1}{\sqrt{x} + t\_3}\right) + \left(t\_4 + \left(t\_1 - \sqrt{t}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + \left(t\_3 - \sqrt{x}\right)\right) + \left(t\_4 + \frac{1}{t\_1 + \sqrt{t}}\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 5.00000000000000041e-6Initial program 90.5%
associate-+l+90.5%
sub-neg90.5%
sub-neg90.5%
+-commutative90.5%
+-commutative90.5%
+-commutative90.5%
Simplified90.5%
flip--90.5%
add-sqr-sqrt74.3%
add-sqr-sqrt90.7%
Applied egg-rr90.7%
Taylor expanded in y around inf 95.9%
if 5.00000000000000041e-6 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.7%
associate-+l+96.7%
sub-neg96.7%
sub-neg96.7%
+-commutative96.7%
+-commutative96.7%
+-commutative96.7%
Simplified96.7%
flip--96.6%
div-inv96.6%
add-sqr-sqrt78.7%
add-sqr-sqrt97.4%
Applied egg-rr97.4%
associate-*r/97.4%
*-rgt-identity97.4%
associate--l+97.7%
+-inverses97.7%
metadata-eval97.7%
Simplified97.7%
Final simplification96.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 t)))
(t_2 (sqrt (+ y 1.0)))
(t_3 (- (sqrt (+ 1.0 z)) (sqrt z))))
(if (<= (- t_2 (sqrt y)) 5e-6)
(+
(+ (* 0.5 (sqrt (/ 1.0 y))) (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))))
(+ t_3 (- t_1 (sqrt t))))
(+
(+ t_3 (/ 1.0 (+ t_1 (sqrt t))))
(+ 1.0 (- t_2 (+ (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((1.0 + t));
double t_2 = sqrt((y + 1.0));
double t_3 = sqrt((1.0 + z)) - sqrt(z);
double tmp;
if ((t_2 - sqrt(y)) <= 5e-6) {
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + sqrt((1.0 + x))))) + (t_3 + (t_1 - sqrt(t)));
} else {
tmp = (t_3 + (1.0 / (t_1 + sqrt(t)))) + (1.0 + (t_2 - (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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = sqrt((1.0d0 + t))
t_2 = sqrt((y + 1.0d0))
t_3 = sqrt((1.0d0 + z)) - sqrt(z)
if ((t_2 - sqrt(y)) <= 5d-6) then
tmp = ((0.5d0 * sqrt((1.0d0 / y))) + (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x))))) + (t_3 + (t_1 - sqrt(t)))
else
tmp = (t_3 + (1.0d0 / (t_1 + sqrt(t)))) + (1.0d0 + (t_2 - (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((1.0 + t));
double t_2 = Math.sqrt((y + 1.0));
double t_3 = Math.sqrt((1.0 + z)) - Math.sqrt(z);
double tmp;
if ((t_2 - Math.sqrt(y)) <= 5e-6) {
tmp = ((0.5 * Math.sqrt((1.0 / y))) + (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x))))) + (t_3 + (t_1 - Math.sqrt(t)));
} else {
tmp = (t_3 + (1.0 / (t_1 + Math.sqrt(t)))) + (1.0 + (t_2 - (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((1.0 + t)) t_2 = math.sqrt((y + 1.0)) t_3 = math.sqrt((1.0 + z)) - math.sqrt(z) tmp = 0 if (t_2 - math.sqrt(y)) <= 5e-6: tmp = ((0.5 * math.sqrt((1.0 / y))) + (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x))))) + (t_3 + (t_1 - math.sqrt(t))) else: tmp = (t_3 + (1.0 / (t_1 + math.sqrt(t)))) + (1.0 + (t_2 - (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(1.0 + t)) t_2 = sqrt(Float64(y + 1.0)) t_3 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) tmp = 0.0 if (Float64(t_2 - sqrt(y)) <= 5e-6) tmp = Float64(Float64(Float64(0.5 * sqrt(Float64(1.0 / y))) + Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x))))) + Float64(t_3 + Float64(t_1 - sqrt(t)))); else tmp = Float64(Float64(t_3 + Float64(1.0 / Float64(t_1 + sqrt(t)))) + Float64(1.0 + Float64(t_2 - Float64(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((1.0 + t));
t_2 = sqrt((y + 1.0));
t_3 = sqrt((1.0 + z)) - sqrt(z);
tmp = 0.0;
if ((t_2 - sqrt(y)) <= 5e-6)
tmp = ((0.5 * sqrt((1.0 / y))) + (1.0 / (sqrt(x) + sqrt((1.0 + x))))) + (t_3 + (t_1 - sqrt(t)));
else
tmp = (t_3 + (1.0 / (t_1 + sqrt(t)))) + (1.0 + (t_2 - (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[(1.0 + t), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 5e-6], N[(N[(N[(0.5 * N[Sqrt[N[(1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$3 + N[(t$95$1 - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$3 + N[(1.0 / N[(t$95$1 + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(t$95$2 - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $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 + t}\\
t_2 := \sqrt{y + 1}\\
t_3 := \sqrt{1 + z} - \sqrt{z}\\
\mathbf{if}\;t\_2 - \sqrt{y} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot \sqrt{\frac{1}{y}} + \frac{1}{\sqrt{x} + \sqrt{1 + x}}\right) + \left(t\_3 + \left(t\_1 - \sqrt{t}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_3 + \frac{1}{t\_1 + \sqrt{t}}\right) + \left(1 + \left(t\_2 - \left(\sqrt{y} + \sqrt{x}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 5.00000000000000041e-6Initial program 90.5%
associate-+l+90.5%
sub-neg90.5%
sub-neg90.5%
+-commutative90.5%
+-commutative90.5%
+-commutative90.5%
Simplified90.5%
flip--90.5%
add-sqr-sqrt74.3%
add-sqr-sqrt90.7%
Applied egg-rr90.7%
Taylor expanded in y around inf 95.9%
if 5.00000000000000041e-6 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.7%
associate-+l+96.7%
sub-neg96.7%
sub-neg96.7%
+-commutative96.7%
+-commutative96.7%
+-commutative96.7%
Simplified96.7%
Taylor expanded in x around 0 49.1%
associate--l+49.1%
Simplified49.1%
flip--96.6%
div-inv96.6%
add-sqr-sqrt78.7%
add-sqr-sqrt97.4%
Applied egg-rr49.5%
associate-*r/97.4%
*-rgt-identity97.4%
associate--l+97.7%
+-inverses97.7%
metadata-eval97.7%
Simplified49.7%
Final simplification70.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 (+ 1.0 z)) (sqrt z))) (t_2 (sqrt (+ y 1.0))))
(if (<= (- t_2 (sqrt y)) 0.0)
(+ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) t_1)
(+
(+ t_1 (/ 1.0 (+ (sqrt (+ 1.0 t)) (sqrt t))))
(+ 1.0 (- t_2 (+ (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((1.0 + z)) - sqrt(z);
double t_2 = sqrt((y + 1.0));
double tmp;
if ((t_2 - sqrt(y)) <= 0.0) {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) + t_1;
} else {
tmp = (t_1 + (1.0 / (sqrt((1.0 + t)) + sqrt(t)))) + (1.0 + (t_2 - (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) :: t_2
real(8) :: tmp
t_1 = sqrt((1.0d0 + z)) - sqrt(z)
t_2 = sqrt((y + 1.0d0))
if ((t_2 - sqrt(y)) <= 0.0d0) then
tmp = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) + t_1
else
tmp = (t_1 + (1.0d0 / (sqrt((1.0d0 + t)) + sqrt(t)))) + (1.0d0 + (t_2 - (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((1.0 + z)) - Math.sqrt(z);
double t_2 = Math.sqrt((y + 1.0));
double tmp;
if ((t_2 - Math.sqrt(y)) <= 0.0) {
tmp = (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) + t_1;
} else {
tmp = (t_1 + (1.0 / (Math.sqrt((1.0 + t)) + Math.sqrt(t)))) + (1.0 + (t_2 - (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((1.0 + z)) - math.sqrt(z) t_2 = math.sqrt((y + 1.0)) tmp = 0 if (t_2 - math.sqrt(y)) <= 0.0: tmp = (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) + t_1 else: tmp = (t_1 + (1.0 / (math.sqrt((1.0 + t)) + math.sqrt(t)))) + (1.0 + (t_2 - (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 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) t_2 = sqrt(Float64(y + 1.0)) tmp = 0.0 if (Float64(t_2 - sqrt(y)) <= 0.0) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) + t_1); else tmp = Float64(Float64(t_1 + Float64(1.0 / Float64(sqrt(Float64(1.0 + t)) + sqrt(t)))) + Float64(1.0 + Float64(t_2 - Float64(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((1.0 + z)) - sqrt(z);
t_2 = sqrt((y + 1.0));
tmp = 0.0;
if ((t_2 - sqrt(y)) <= 0.0)
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) + t_1;
else
tmp = (t_1 + (1.0 / (sqrt((1.0 + t)) + sqrt(t)))) + (1.0 + (t_2 - (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[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(t$95$1 + N[(1.0 / N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] + N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(t$95$2 - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $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} - \sqrt{z}\\
t_2 := \sqrt{y + 1}\\
\mathbf{if}\;t\_2 - \sqrt{y} \leq 0:\\
\;\;\;\;\frac{1}{\sqrt{x} + \sqrt{1 + x}} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 + \frac{1}{\sqrt{1 + t} + \sqrt{t}}\right) + \left(1 + \left(t\_2 - \left(\sqrt{y} + \sqrt{x}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 0.0Initial program 90.8%
associate-+l+90.8%
sub-neg90.8%
sub-neg90.8%
+-commutative90.8%
+-commutative90.8%
+-commutative90.8%
Simplified90.8%
flip--90.8%
add-sqr-sqrt74.4%
add-sqr-sqrt91.0%
Applied egg-rr91.0%
Taylor expanded in y around inf 92.8%
Taylor expanded in t around inf 53.4%
if 0.0 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.4%
associate-+l+96.4%
sub-neg96.4%
sub-neg96.4%
+-commutative96.4%
+-commutative96.4%
+-commutative96.4%
Simplified96.4%
Taylor expanded in x around 0 49.4%
associate--l+49.5%
Simplified49.5%
flip--96.3%
div-inv96.3%
add-sqr-sqrt78.2%
add-sqr-sqrt97.0%
Applied egg-rr49.8%
associate-*r/97.0%
*-rgt-identity97.0%
associate--l+97.4%
+-inverses97.4%
metadata-eval97.4%
Simplified50.0%
Final simplification51.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 (+ 1.0 z)) (sqrt z))) (t_2 (sqrt (+ y 1.0))))
(if (<= (- t_2 (sqrt y)) 0.0)
(+ (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))) t_1)
(+
(+ t_1 (- (sqrt (+ 1.0 t)) (sqrt t)))
(+ 1.0 (- t_2 (+ (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((1.0 + z)) - sqrt(z);
double t_2 = sqrt((y + 1.0));
double tmp;
if ((t_2 - sqrt(y)) <= 0.0) {
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) + t_1;
} else {
tmp = (t_1 + (sqrt((1.0 + t)) - sqrt(t))) + (1.0 + (t_2 - (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) :: t_2
real(8) :: tmp
t_1 = sqrt((1.0d0 + z)) - sqrt(z)
t_2 = sqrt((y + 1.0d0))
if ((t_2 - sqrt(y)) <= 0.0d0) then
tmp = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) + t_1
else
tmp = (t_1 + (sqrt((1.0d0 + t)) - sqrt(t))) + (1.0d0 + (t_2 - (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((1.0 + z)) - Math.sqrt(z);
double t_2 = Math.sqrt((y + 1.0));
double tmp;
if ((t_2 - Math.sqrt(y)) <= 0.0) {
tmp = (1.0 / (Math.sqrt(x) + Math.sqrt((1.0 + x)))) + t_1;
} else {
tmp = (t_1 + (Math.sqrt((1.0 + t)) - Math.sqrt(t))) + (1.0 + (t_2 - (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((1.0 + z)) - math.sqrt(z) t_2 = math.sqrt((y + 1.0)) tmp = 0 if (t_2 - math.sqrt(y)) <= 0.0: tmp = (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) + t_1 else: tmp = (t_1 + (math.sqrt((1.0 + t)) - math.sqrt(t))) + (1.0 + (t_2 - (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 = Float64(sqrt(Float64(1.0 + z)) - sqrt(z)) t_2 = sqrt(Float64(y + 1.0)) tmp = 0.0 if (Float64(t_2 - sqrt(y)) <= 0.0) tmp = Float64(Float64(1.0 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) + t_1); else tmp = Float64(Float64(t_1 + Float64(sqrt(Float64(1.0 + t)) - sqrt(t))) + Float64(1.0 + Float64(t_2 - Float64(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((1.0 + z)) - sqrt(z);
t_2 = sqrt((y + 1.0));
tmp = 0.0;
if ((t_2 - sqrt(y)) <= 0.0)
tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) + t_1;
else
tmp = (t_1 + (sqrt((1.0 + t)) - sqrt(t))) + (1.0 + (t_2 - (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[(N[Sqrt[N[(1.0 + z), $MachinePrecision]], $MachinePrecision] - N[Sqrt[z], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$2 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(t$95$1 + N[(N[Sqrt[N[(1.0 + t), $MachinePrecision]], $MachinePrecision] - N[Sqrt[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(t$95$2 - N[(N[Sqrt[y], $MachinePrecision] + N[Sqrt[x], $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} - \sqrt{z}\\
t_2 := \sqrt{y + 1}\\
\mathbf{if}\;t\_2 - \sqrt{y} \leq 0:\\
\;\;\;\;\frac{1}{\sqrt{x} + \sqrt{1 + x}} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 + \left(\sqrt{1 + t} - \sqrt{t}\right)\right) + \left(1 + \left(t\_2 - \left(\sqrt{y} + \sqrt{x}\right)\right)\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 0.0Initial program 90.8%
associate-+l+90.8%
sub-neg90.8%
sub-neg90.8%
+-commutative90.8%
+-commutative90.8%
+-commutative90.8%
Simplified90.8%
flip--90.8%
add-sqr-sqrt74.4%
add-sqr-sqrt91.0%
Applied egg-rr91.0%
Taylor expanded in y around inf 92.8%
Taylor expanded in t around inf 53.4%
if 0.0 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.4%
associate-+l+96.4%
sub-neg96.4%
sub-neg96.4%
+-commutative96.4%
+-commutative96.4%
+-commutative96.4%
Simplified96.4%
Taylor expanded in x around 0 49.4%
associate--l+49.5%
Simplified49.5%
Final simplification51.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 (+ y 1.0))))
(if (<= (- t_1 (sqrt y)) 0.0)
(- (sqrt (+ 1.0 x)) (sqrt x))
(- (+ 1.0 t_1) (+ (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((y + 1.0));
double tmp;
if ((t_1 - sqrt(y)) <= 0.0) {
tmp = sqrt((1.0 + x)) - sqrt(x);
} else {
tmp = (1.0 + t_1) - (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((y + 1.0d0))
if ((t_1 - sqrt(y)) <= 0.0d0) then
tmp = sqrt((1.0d0 + x)) - sqrt(x)
else
tmp = (1.0d0 + t_1) - (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((y + 1.0));
double tmp;
if ((t_1 - Math.sqrt(y)) <= 0.0) {
tmp = Math.sqrt((1.0 + x)) - Math.sqrt(x);
} else {
tmp = (1.0 + t_1) - (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((y + 1.0)) tmp = 0 if (t_1 - math.sqrt(y)) <= 0.0: tmp = math.sqrt((1.0 + x)) - math.sqrt(x) else: tmp = (1.0 + t_1) - (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(y + 1.0)) tmp = 0.0 if (Float64(t_1 - sqrt(y)) <= 0.0) tmp = Float64(sqrt(Float64(1.0 + x)) - sqrt(x)); else tmp = Float64(Float64(1.0 + t_1) - Float64(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((y + 1.0));
tmp = 0.0;
if ((t_1 - sqrt(y)) <= 0.0)
tmp = sqrt((1.0 + x)) - sqrt(x);
else
tmp = (1.0 + t_1) - (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[(y + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$1 - N[Sqrt[y], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + t$95$1), $MachinePrecision] - N[(N[Sqrt[y], $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{y + 1}\\
\mathbf{if}\;t\_1 - \sqrt{y} \leq 0:\\
\;\;\;\;\sqrt{1 + x} - \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + t\_1\right) - \left(\sqrt{y} + \sqrt{x}\right)\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 0.0Initial program 90.8%
associate-+l+90.8%
sub-neg90.8%
sub-neg90.8%
+-commutative90.8%
+-commutative90.8%
+-commutative90.8%
Simplified90.8%
Taylor expanded in t around inf 3.6%
associate--l+21.5%
Simplified21.5%
Taylor expanded in x around inf 21.2%
neg-mul-121.2%
Simplified21.2%
if 0.0 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.4%
associate-+l+96.4%
sub-neg96.4%
sub-neg96.4%
+-commutative96.4%
+-commutative96.4%
+-commutative96.4%
Simplified96.4%
Taylor expanded in t around inf 19.9%
associate--l+24.1%
Simplified24.1%
Taylor expanded in z around inf 19.9%
+-commutative19.9%
Simplified19.9%
Taylor expanded in x around 0 17.7%
+-commutative17.7%
Simplified17.7%
Final simplification19.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 (+ y 1.0)) (sqrt y)))) (if (<= t_1 1e-7) (- (sqrt (+ 1.0 x)) (sqrt x)) (+ 1.0 t_1))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = sqrt((y + 1.0)) - sqrt(y);
double tmp;
if (t_1 <= 1e-7) {
tmp = sqrt((1.0 + x)) - sqrt(x);
} else {
tmp = 1.0 + t_1;
}
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((y + 1.0d0)) - sqrt(y)
if (t_1 <= 1d-7) then
tmp = sqrt((1.0d0 + x)) - sqrt(x)
else
tmp = 1.0d0 + t_1
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((y + 1.0)) - Math.sqrt(y);
double tmp;
if (t_1 <= 1e-7) {
tmp = Math.sqrt((1.0 + x)) - Math.sqrt(x);
} else {
tmp = 1.0 + t_1;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = math.sqrt((y + 1.0)) - math.sqrt(y) tmp = 0 if t_1 <= 1e-7: tmp = math.sqrt((1.0 + x)) - math.sqrt(x) else: tmp = 1.0 + t_1 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) tmp = 0.0 if (t_1 <= 1e-7) tmp = Float64(sqrt(Float64(1.0 + x)) - sqrt(x)); else tmp = Float64(1.0 + t_1); 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((y + 1.0)) - sqrt(y);
tmp = 0.0;
if (t_1 <= 1e-7)
tmp = sqrt((1.0 + x)) - sqrt(x);
else
tmp = 1.0 + t_1;
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[(N[Sqrt[N[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-7], N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(1.0 + t$95$1), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \sqrt{y + 1} - \sqrt{y}\\
\mathbf{if}\;t\_1 \leq 10^{-7}:\\
\;\;\;\;\sqrt{1 + x} - \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;1 + t\_1\\
\end{array}
\end{array}
if (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) < 9.9999999999999995e-8Initial program 90.8%
associate-+l+90.8%
sub-neg90.8%
sub-neg90.8%
+-commutative90.8%
+-commutative90.8%
+-commutative90.8%
Simplified90.8%
Taylor expanded in t around inf 3.6%
associate--l+21.5%
Simplified21.5%
Taylor expanded in x around inf 21.2%
neg-mul-121.2%
Simplified21.2%
if 9.9999999999999995e-8 < (-.f64 (sqrt.f64 (+.f64 y #s(literal 1 binary64))) (sqrt.f64 y)) Initial program 96.4%
associate-+l+96.4%
sub-neg96.4%
sub-neg96.4%
+-commutative96.4%
+-commutative96.4%
+-commutative96.4%
Simplified96.4%
Taylor expanded in t around inf 19.9%
associate--l+24.1%
Simplified24.1%
Taylor expanded in x around 0 18.4%
associate-+r+18.4%
associate--l+26.8%
associate-+r-31.6%
+-commutative31.6%
Simplified31.6%
Taylor expanded in y around inf 44.0%
mul-1-neg44.0%
Simplified44.0%
Final simplification33.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- (sqrt (+ 1.0 x)) (sqrt x)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return sqrt((1.0 + x)) - 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((1.0d0 + x)) - 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((1.0 + x)) - Math.sqrt(x);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return math.sqrt((1.0 + x)) - math.sqrt(x)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(sqrt(Float64(1.0 + x)) - sqrt(x)) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = sqrt((1.0 + x)) - 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[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\sqrt{1 + x} - \sqrt{x}
\end{array}
Initial program 93.9%
associate-+l+93.9%
sub-neg93.9%
sub-neg93.9%
+-commutative93.9%
+-commutative93.9%
+-commutative93.9%
Simplified93.9%
Taylor expanded in t around inf 12.6%
associate--l+22.9%
Simplified22.9%
Taylor expanded in x around inf 15.7%
neg-mul-115.7%
Simplified15.7%
Final simplification15.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- (sqrt (+ y 1.0)) (sqrt y)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return sqrt((y + 1.0)) - sqrt(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 = sqrt((y + 1.0d0)) - sqrt(y)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return Math.sqrt((y + 1.0)) - Math.sqrt(y);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return math.sqrt((y + 1.0)) - math.sqrt(y)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(sqrt(Float64(y + 1.0)) - sqrt(y)) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = sqrt((y + 1.0)) - sqrt(y);
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[(y + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[y], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\sqrt{y + 1} - \sqrt{y}
\end{array}
Initial program 93.9%
associate-+l+93.9%
sub-neg93.9%
sub-neg93.9%
+-commutative93.9%
+-commutative93.9%
+-commutative93.9%
Simplified93.9%
Taylor expanded in t around inf 12.6%
associate--l+22.9%
Simplified22.9%
Taylor expanded in z around inf 12.6%
+-commutative12.6%
Simplified12.6%
Taylor expanded in x around inf 14.8%
Final simplification14.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (sqrt y))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return sqrt(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 = sqrt(y)
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return Math.sqrt(y);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return math.sqrt(y)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return sqrt(y) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = sqrt(y);
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[Sqrt[y], $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\sqrt{y}
\end{array}
Initial program 93.9%
associate-+l+93.9%
sub-neg93.9%
sub-neg93.9%
+-commutative93.9%
+-commutative93.9%
+-commutative93.9%
Simplified93.9%
Taylor expanded in x around 0 36.9%
associate--l+50.5%
Simplified50.5%
flip-+48.9%
add-sqr-sqrt48.9%
add-sqr-sqrt40.1%
Applied egg-rr40.1%
Taylor expanded in y around inf 7.0%
(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 2024191
(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))))