
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))
double code(double x, double y, double z) {
return 2.0 * sqrt((((x * y) + (x * z)) + (y * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((((x * y) + (x * z)) + (y * z)))
end function
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((((x * y) + (x * z)) + (y * z)));
}
def code(x, y, z): return 2.0 * math.sqrt((((x * y) + (x * z)) + (y * z)))
function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(Float64(x * y) + Float64(x * z)) + Float64(y * z)))) end
function tmp = code(x, y, z) tmp = 2.0 * sqrt((((x * y) + (x * z)) + (y * z))); end
code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(N[(x * y), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \sqrt{\left(x \cdot y + x \cdot z\right) + y \cdot z}
\end{array}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(if (<= y -126000.0)
(* 2.0 (pow (exp (* 0.25 (- (log (- (- z) x)) (log (/ -1.0 y))))) 2.0))
(if (<= y -5.5e-277)
(* 2.0 (sqrt (fma x y (* z (+ y x)))))
(* 2.0 (* (sqrt z) (sqrt (fma x (/ y z) (+ y x))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -126000.0) {
tmp = 2.0 * pow(exp((0.25 * (log((-z - x)) - log((-1.0 / y))))), 2.0);
} else if (y <= -5.5e-277) {
tmp = 2.0 * sqrt(fma(x, y, (z * (y + x))));
} else {
tmp = 2.0 * (sqrt(z) * sqrt(fma(x, (y / z), (y + x))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -126000.0) tmp = Float64(2.0 * (exp(Float64(0.25 * Float64(log(Float64(Float64(-z) - x)) - log(Float64(-1.0 / y))))) ^ 2.0)); elseif (y <= -5.5e-277) tmp = Float64(2.0 * sqrt(fma(x, y, Float64(z * Float64(y + x))))); else tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(fma(x, Float64(y / z), Float64(y + x))))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -126000.0], N[(2.0 * N[Power[N[Exp[N[(0.25 * N[(N[Log[N[((-z) - x), $MachinePrecision]], $MachinePrecision] - N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.5e-277], N[(2.0 * N[Sqrt[N[(x * y + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[N[(x * N[(y / z), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -126000:\\
\;\;\;\;2 \cdot {\left(e^{0.25 \cdot \left(\log \left(\left(-z\right) - x\right) - \log \left(\frac{-1}{y}\right)\right)}\right)}^{2}\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{-277}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot \left(y + x\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{\mathsf{fma}\left(x, \frac{y}{z}, y + x\right)}\right)\\
\end{array}
\end{array}
if y < -126000Initial program 64.3%
+-commutative64.3%
*-commutative64.3%
+-commutative64.3%
*-commutative64.3%
*-commutative64.3%
associate-+l+64.3%
+-commutative64.3%
*-commutative64.3%
fma-define64.3%
+-commutative64.3%
distribute-lft-out64.8%
Simplified64.8%
fma-undefine64.4%
+-commutative64.4%
+-commutative64.4%
+-commutative64.4%
distribute-rgt-in64.3%
associate-+l+64.3%
*-commutative64.3%
distribute-lft-in64.3%
+-commutative64.3%
fma-undefine64.8%
add-sqr-sqrt64.2%
pow264.2%
pow1/264.2%
sqrt-pow164.3%
metadata-eval64.3%
Applied egg-rr64.3%
Taylor expanded in y around -inf 80.9%
if -126000 < y < -5.49999999999999952e-277Initial program 85.3%
+-commutative85.3%
*-commutative85.3%
+-commutative85.3%
*-commutative85.3%
*-commutative85.3%
associate-+l+85.3%
+-commutative85.3%
*-commutative85.3%
fma-define85.3%
+-commutative85.3%
distribute-lft-out85.4%
Simplified85.4%
if -5.49999999999999952e-277 < y Initial program 73.2%
associate-+l+73.2%
+-commutative73.2%
distribute-rgt-in73.3%
Simplified73.3%
add-cbrt-cube40.6%
pow340.7%
+-commutative40.7%
Applied egg-rr40.7%
Taylor expanded in z around inf 65.3%
associate-+r+65.3%
+-commutative65.3%
associate-/l*59.6%
Simplified59.6%
sqrt-prod51.5%
*-commutative51.5%
+-commutative51.5%
fma-define51.5%
+-commutative51.5%
Applied egg-rr51.5%
Final simplification66.9%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -3.15e-291) (* 2.0 (pow (exp (* 0.25 (- (log (- (- y) z)) (log (/ -1.0 x))))) 2.0)) (* 2.0 (* (sqrt (+ y x)) (sqrt z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -3.15e-291) {
tmp = 2.0 * pow(exp((0.25 * (log((-y - z)) - log((-1.0 / x))))), 2.0);
} else {
tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-3.15d-291)) then
tmp = 2.0d0 * (exp((0.25d0 * (log((-y - z)) - log(((-1.0d0) / x))))) ** 2.0d0)
else
tmp = 2.0d0 * (sqrt((y + x)) * sqrt(z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.15e-291) {
tmp = 2.0 * Math.pow(Math.exp((0.25 * (Math.log((-y - z)) - Math.log((-1.0 / x))))), 2.0);
} else {
tmp = 2.0 * (Math.sqrt((y + x)) * Math.sqrt(z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -3.15e-291: tmp = 2.0 * math.pow(math.exp((0.25 * (math.log((-y - z)) - math.log((-1.0 / x))))), 2.0) else: tmp = 2.0 * (math.sqrt((y + x)) * math.sqrt(z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -3.15e-291) tmp = Float64(2.0 * (exp(Float64(0.25 * Float64(log(Float64(Float64(-y) - z)) - log(Float64(-1.0 / x))))) ^ 2.0)); else tmp = Float64(2.0 * Float64(sqrt(Float64(y + x)) * sqrt(z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -3.15e-291)
tmp = 2.0 * (exp((0.25 * (log((-y - z)) - log((-1.0 / x))))) ^ 2.0);
else
tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -3.15e-291], N[(2.0 * N[Power[N[Exp[N[(0.25 * N[(N[Log[N[((-y) - z), $MachinePrecision]], $MachinePrecision] - N[Log[N[(-1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(y + x), $MachinePrecision]], $MachinePrecision] * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.15 \cdot 10^{-291}:\\
\;\;\;\;2 \cdot {\left(e^{0.25 \cdot \left(\log \left(\left(-y\right) - z\right) - \log \left(\frac{-1}{x}\right)\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\
\end{array}
\end{array}
if y < -3.14999999999999996e-291Initial program 74.4%
+-commutative74.4%
*-commutative74.4%
+-commutative74.4%
*-commutative74.4%
*-commutative74.4%
associate-+l+74.4%
+-commutative74.4%
*-commutative74.4%
fma-define74.4%
+-commutative74.4%
distribute-lft-out74.6%
Simplified74.6%
fma-undefine74.5%
+-commutative74.5%
+-commutative74.5%
+-commutative74.5%
distribute-rgt-in74.4%
associate-+l+74.4%
*-commutative74.4%
distribute-lft-in74.4%
+-commutative74.4%
fma-undefine74.6%
add-sqr-sqrt74.1%
pow274.1%
pow1/274.1%
sqrt-pow174.2%
metadata-eval74.2%
Applied egg-rr74.2%
Taylor expanded in x around -inf 52.6%
if -3.14999999999999996e-291 < y Initial program 74.1%
associate-+l+74.1%
+-commutative74.1%
distribute-rgt-in74.1%
Simplified74.1%
Taylor expanded in z around inf 50.2%
*-commutative50.2%
sqrt-prod50.9%
Applied egg-rr50.9%
Final simplification51.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function.
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (+ (* y x) (* z x)) (* y z))))
(if (or (<= t_0 0.0) (not (<= t_0 2e+305)))
(* 2.0 (* (sqrt z) (sqrt (fma x (/ y z) (+ y x)))))
(* 2.0 (sqrt (fma x y (* z (+ y x))))))))assert(x < y && y < z);
double code(double x, double y, double z) {
double t_0 = ((y * x) + (z * x)) + (y * z);
double tmp;
if ((t_0 <= 0.0) || !(t_0 <= 2e+305)) {
tmp = 2.0 * (sqrt(z) * sqrt(fma(x, (y / z), (y + x))));
} else {
tmp = 2.0 * sqrt(fma(x, y, (z * (y + x))));
}
return tmp;
}
x, y, z = sort([x, y, z]) function code(x, y, z) t_0 = Float64(Float64(Float64(y * x) + Float64(z * x)) + Float64(y * z)) tmp = 0.0 if ((t_0 <= 0.0) || !(t_0 <= 2e+305)) tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(fma(x, Float64(y / z), Float64(y + x))))); else tmp = Float64(2.0 * sqrt(fma(x, y, Float64(z * Float64(y + x))))); end return tmp end
NOTE: x, y, and z should be sorted in increasing order before calling this function.
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y * x), $MachinePrecision] + N[(z * x), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, 0.0], N[Not[LessEqual[t$95$0, 2e+305]], $MachinePrecision]], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[N[(x * N[(y / z), $MachinePrecision] + N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(x * y + N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
t_0 := \left(y \cdot x + z \cdot x\right) + y \cdot z\\
\mathbf{if}\;t\_0 \leq 0 \lor \neg \left(t\_0 \leq 2 \cdot 10^{+305}\right):\\
\;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{\mathsf{fma}\left(x, \frac{y}{z}, y + x\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{\mathsf{fma}\left(x, y, z \cdot \left(y + x\right)\right)}\\
\end{array}
\end{array}
if (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)) < 0.0 or 1.9999999999999999e305 < (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)) Initial program 6.3%
associate-+l+6.3%
+-commutative6.3%
distribute-rgt-in6.5%
Simplified6.5%
add-cbrt-cube5.9%
pow35.9%
+-commutative5.9%
Applied egg-rr5.9%
Taylor expanded in z around inf 6.6%
associate-+r+6.6%
+-commutative6.6%
associate-/l*7.1%
Simplified7.1%
sqrt-prod38.7%
*-commutative38.7%
+-commutative38.7%
fma-define38.7%
+-commutative38.7%
Applied egg-rr38.7%
if 0.0 < (+.f64 (+.f64 (*.f64 x y) (*.f64 x z)) (*.f64 y z)) < 1.9999999999999999e305Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
+-commutative99.8%
*-commutative99.8%
*-commutative99.8%
associate-+l+99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
+-commutative99.8%
distribute-lft-out99.8%
Simplified99.8%
Final simplification83.1%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.35e-278) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (* (sqrt (+ y x)) (sqrt z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.35e-278) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.35d-278) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * (sqrt((y + x)) * sqrt(z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.35e-278) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * (Math.sqrt((y + x)) * Math.sqrt(z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.35e-278: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * (math.sqrt((y + x)) * math.sqrt(z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.35e-278) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * Float64(sqrt(Float64(y + x)) * sqrt(z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.35e-278)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * (sqrt((y + x)) * sqrt(z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.35e-278], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[N[(y + x), $MachinePrecision]], $MachinePrecision] * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-278}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{y + x} \cdot \sqrt{z}\right)\\
\end{array}
\end{array}
if y < 1.3500000000000001e-278Initial program 74.1%
associate-+l+74.1%
+-commutative74.1%
distribute-rgt-in74.2%
Simplified74.2%
Taylor expanded in x around inf 57.9%
+-commutative57.9%
Simplified57.9%
if 1.3500000000000001e-278 < y Initial program 74.4%
associate-+l+74.4%
+-commutative74.4%
distribute-rgt-in74.5%
Simplified74.5%
Taylor expanded in z around inf 47.8%
*-commutative47.8%
sqrt-prod50.7%
Applied egg-rr50.7%
Final simplification54.6%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y 1.4e-278) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (* (sqrt z) (sqrt y)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= 1.4e-278) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * (sqrt(z) * sqrt(y));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.4d-278) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * (sqrt(z) * sqrt(y))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.4e-278) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * (Math.sqrt(z) * Math.sqrt(y));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= 1.4e-278: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * (math.sqrt(z) * math.sqrt(y)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= 1.4e-278) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * Float64(sqrt(z) * sqrt(y))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= 1.4e-278)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * (sqrt(z) * sqrt(y));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, 1.4e-278], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[Sqrt[z], $MachinePrecision] * N[Sqrt[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.4 \cdot 10^{-278}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\sqrt{z} \cdot \sqrt{y}\right)\\
\end{array}
\end{array}
if y < 1.40000000000000004e-278Initial program 74.1%
associate-+l+74.1%
+-commutative74.1%
distribute-rgt-in74.2%
Simplified74.2%
Taylor expanded in x around inf 57.9%
+-commutative57.9%
Simplified57.9%
if 1.40000000000000004e-278 < y Initial program 74.4%
associate-+l+74.4%
+-commutative74.4%
distribute-rgt-in74.5%
Simplified74.5%
Taylor expanded in z around inf 47.8%
*-commutative47.8%
sqrt-prod50.7%
Applied egg-rr50.7%
Taylor expanded in x around 0 36.4%
Final simplification48.2%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -4.4e-281) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* z (* y (+ 1.0 (/ x y))))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -4.4e-281) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((z * (y * (1.0 + (x / y)))));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-4.4d-281)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((z * (y * (1.0d0 + (x / y)))))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.4e-281) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((z * (y * (1.0 + (x / y)))));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -4.4e-281: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((z * (y * (1.0 + (x / y))))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -4.4e-281) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(y * Float64(1.0 + Float64(x / y)))))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -4.4e-281)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((z * (y * (1.0 + (x / y)))));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -4.4e-281], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(y * N[(1.0 + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.4 \cdot 10^{-281}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(y \cdot \left(1 + \frac{x}{y}\right)\right)}\\
\end{array}
\end{array}
if y < -4.40000000000000008e-281Initial program 74.8%
associate-+l+74.8%
+-commutative74.8%
distribute-rgt-in74.8%
Simplified74.8%
Taylor expanded in x around inf 56.7%
+-commutative56.7%
Simplified56.7%
if -4.40000000000000008e-281 < y Initial program 73.7%
associate-+l+73.7%
+-commutative73.7%
distribute-rgt-in73.8%
Simplified73.8%
Taylor expanded in z around inf 50.2%
Taylor expanded in y around inf 45.1%
Final simplification50.7%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -5.5e-277) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* z (+ y x))))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((z * (y + x)));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.5d-277)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((z * (y + x)))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((z * (y + x)));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -5.5e-277: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((z * (y + x))) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -5.5e-277) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(z * Float64(y + x)))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -5.5e-277)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((z * (y + x)));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -5.5e-277], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-277}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{z \cdot \left(y + x\right)}\\
\end{array}
\end{array}
if y < -5.49999999999999952e-277Initial program 75.3%
associate-+l+75.3%
+-commutative75.3%
distribute-rgt-in75.4%
Simplified75.4%
Taylor expanded in x around inf 57.1%
+-commutative57.1%
Simplified57.1%
if -5.49999999999999952e-277 < y Initial program 73.2%
associate-+l+73.2%
+-commutative73.2%
distribute-rgt-in73.3%
Simplified73.3%
Taylor expanded in z around inf 49.9%
Final simplification53.4%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -5.5e-277) (* 2.0 (sqrt (* x (+ y z)))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * sqrt((x * (y + z)));
} else {
tmp = 2.0 * sqrt((y * z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.5d-277)) then
tmp = 2.0d0 * sqrt((x * (y + z)))
else
tmp = 2.0d0 * sqrt((y * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * Math.sqrt((x * (y + z)));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -5.5e-277: tmp = 2.0 * math.sqrt((x * (y + z))) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -5.5e-277) tmp = Float64(2.0 * sqrt(Float64(x * Float64(y + z)))); else tmp = Float64(2.0 * sqrt(Float64(y * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -5.5e-277)
tmp = 2.0 * sqrt((x * (y + z)));
else
tmp = 2.0 * sqrt((y * z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -5.5e-277], N[(2.0 * N[Sqrt[N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-277}:\\
\;\;\;\;2 \cdot \sqrt{x \cdot \left(y + z\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -5.49999999999999952e-277Initial program 75.3%
associate-+l+75.3%
+-commutative75.3%
distribute-rgt-in75.4%
Simplified75.4%
Taylor expanded in x around inf 57.1%
+-commutative57.1%
Simplified57.1%
if -5.49999999999999952e-277 < y Initial program 73.2%
associate-+l+73.2%
+-commutative73.2%
distribute-rgt-in73.3%
Simplified73.3%
Taylor expanded in x around 0 23.5%
*-commutative23.5%
Simplified23.5%
Final simplification39.8%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (+ (* z (+ y x)) (* y x)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt(((z * (y + x)) + (y * x)));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt(((z * (y + x)) + (y * x)))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt(((z * (y + x)) + (y * x)));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt(((z * (y + x)) + (y * x)))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(Float64(z * Float64(y + x)) + Float64(y * x)))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt(((z * (y + x)) + (y * x)));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(N[(z * N[(y + x), $MachinePrecision]), $MachinePrecision] + N[(y * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{z \cdot \left(y + x\right) + y \cdot x}
\end{array}
Initial program 74.2%
associate-+l+74.2%
+-commutative74.2%
distribute-rgt-in74.3%
Simplified74.3%
Final simplification74.3%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (if (<= y -5.5e-277) (* 2.0 (sqrt (* y x))) (* 2.0 (sqrt (* y z)))))
assert(x < y && y < z);
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * sqrt((y * x));
} else {
tmp = 2.0 * sqrt((y * z));
}
return tmp;
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-5.5d-277)) then
tmp = 2.0d0 * sqrt((y * x))
else
tmp = 2.0d0 * sqrt((y * z))
end if
code = tmp
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e-277) {
tmp = 2.0 * Math.sqrt((y * x));
} else {
tmp = 2.0 * Math.sqrt((y * z));
}
return tmp;
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): tmp = 0 if y <= -5.5e-277: tmp = 2.0 * math.sqrt((y * x)) else: tmp = 2.0 * math.sqrt((y * z)) return tmp
x, y, z = sort([x, y, z]) function code(x, y, z) tmp = 0.0 if (y <= -5.5e-277) tmp = Float64(2.0 * sqrt(Float64(y * x))); else tmp = Float64(2.0 * sqrt(Float64(y * z))); end return tmp end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp_2 = code(x, y, z)
tmp = 0.0;
if (y <= -5.5e-277)
tmp = 2.0 * sqrt((y * x));
else
tmp = 2.0 * sqrt((y * z));
end
tmp_2 = tmp;
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := If[LessEqual[y, -5.5e-277], N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(2.0 * N[Sqrt[N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-277}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot x}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \sqrt{y \cdot z}\\
\end{array}
\end{array}
if y < -5.49999999999999952e-277Initial program 75.3%
associate-+l+75.3%
+-commutative75.3%
distribute-rgt-in75.4%
Simplified75.4%
Taylor expanded in z around 0 36.9%
if -5.49999999999999952e-277 < y Initial program 73.2%
associate-+l+73.2%
+-commutative73.2%
distribute-rgt-in73.3%
Simplified73.3%
Taylor expanded in x around 0 23.5%
*-commutative23.5%
Simplified23.5%
Final simplification30.0%
NOTE: x, y, and z should be sorted in increasing order before calling this function. (FPCore (x y z) :precision binary64 (* 2.0 (sqrt (* y x))))
assert(x < y && y < z);
double code(double x, double y, double z) {
return 2.0 * sqrt((y * x));
}
NOTE: x, y, and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 * sqrt((y * x))
end function
assert x < y && y < z;
public static double code(double x, double y, double z) {
return 2.0 * Math.sqrt((y * x));
}
[x, y, z] = sort([x, y, z]) def code(x, y, z): return 2.0 * math.sqrt((y * x))
x, y, z = sort([x, y, z]) function code(x, y, z) return Float64(2.0 * sqrt(Float64(y * x))) end
x, y, z = num2cell(sort([x, y, z])){:}
function tmp = code(x, y, z)
tmp = 2.0 * sqrt((y * x));
end
NOTE: x, y, and z should be sorted in increasing order before calling this function. code[x_, y_, z_] := N[(2.0 * N[Sqrt[N[(y * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z] = \mathsf{sort}([x, y, z])\\
\\
2 \cdot \sqrt{y \cdot x}
\end{array}
Initial program 74.2%
associate-+l+74.2%
+-commutative74.2%
distribute-rgt-in74.3%
Simplified74.3%
Taylor expanded in z around 0 30.8%
Final simplification30.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0
(+
(* 0.25 (* (* (pow y -0.75) (* (pow z -0.75) x)) (+ y z)))
(* (pow z 0.25) (pow y 0.25)))))
(if (< z 7.636950090573675e+176)
(* 2.0 (sqrt (+ (* (+ x y) z) (* x y))))
(* (* t_0 t_0) 2.0))))
double code(double x, double y, double z) {
double t_0 = (0.25 * ((pow(y, -0.75) * (pow(z, -0.75) * x)) * (y + z))) + (pow(z, 0.25) * pow(y, 0.25));
double tmp;
if (z < 7.636950090573675e+176) {
tmp = 2.0 * sqrt((((x + y) * z) + (x * y)));
} else {
tmp = (t_0 * t_0) * 2.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (0.25d0 * (((y ** (-0.75d0)) * ((z ** (-0.75d0)) * x)) * (y + z))) + ((z ** 0.25d0) * (y ** 0.25d0))
if (z < 7.636950090573675d+176) then
tmp = 2.0d0 * sqrt((((x + y) * z) + (x * y)))
else
tmp = (t_0 * t_0) * 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (0.25 * ((Math.pow(y, -0.75) * (Math.pow(z, -0.75) * x)) * (y + z))) + (Math.pow(z, 0.25) * Math.pow(y, 0.25));
double tmp;
if (z < 7.636950090573675e+176) {
tmp = 2.0 * Math.sqrt((((x + y) * z) + (x * y)));
} else {
tmp = (t_0 * t_0) * 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (0.25 * ((math.pow(y, -0.75) * (math.pow(z, -0.75) * x)) * (y + z))) + (math.pow(z, 0.25) * math.pow(y, 0.25)) tmp = 0 if z < 7.636950090573675e+176: tmp = 2.0 * math.sqrt((((x + y) * z) + (x * y))) else: tmp = (t_0 * t_0) * 2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(0.25 * Float64(Float64((y ^ -0.75) * Float64((z ^ -0.75) * x)) * Float64(y + z))) + Float64((z ^ 0.25) * (y ^ 0.25))) tmp = 0.0 if (z < 7.636950090573675e+176) tmp = Float64(2.0 * sqrt(Float64(Float64(Float64(x + y) * z) + Float64(x * y)))); else tmp = Float64(Float64(t_0 * t_0) * 2.0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (0.25 * (((y ^ -0.75) * ((z ^ -0.75) * x)) * (y + z))) + ((z ^ 0.25) * (y ^ 0.25)); tmp = 0.0; if (z < 7.636950090573675e+176) tmp = 2.0 * sqrt((((x + y) * z) + (x * y))); else tmp = (t_0 * t_0) * 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(0.25 * N[(N[(N[Power[y, -0.75], $MachinePrecision] * N[(N[Power[z, -0.75], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[z, 0.25], $MachinePrecision] * N[Power[y, 0.25], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, 7.636950090573675e+176], N[(2.0 * N[Sqrt[N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \left(\left({y}^{-0.75} \cdot \left({z}^{-0.75} \cdot x\right)\right) \cdot \left(y + z\right)\right) + {z}^{0.25} \cdot {y}^{0.25}\\
\mathbf{if}\;z < 7.636950090573675 \cdot 10^{+176}:\\
\;\;\;\;2 \cdot \sqrt{\left(x + y\right) \cdot z + x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot t\_0\right) \cdot 2\\
\end{array}
\end{array}
herbie shell --seed 2024132
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:descartes from diagrams-contrib-1.3.0.5"
:precision binary64
:alt
(! :herbie-platform default (if (< z 763695009057367500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* 2 (sqrt (+ (* (+ x y) z) (* x y)))) (* (* (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4))) (+ (* 1/4 (* (* (pow y -3/4) (* (pow z -3/4) x)) (+ y z))) (* (pow z 1/4) (pow y 1/4)))) 2)))
(* 2.0 (sqrt (+ (+ (* x y) (* x z)) (* y z)))))