
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - 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 = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - 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 = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))) (if (<= t_0 -5e+163) (fma (+ y -1.0) (* x z) x) t_0)))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (t_0 <= -5e+163) {
tmp = fma((y + -1.0), (x * z), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) tmp = 0.0 if (t_0 <= -5e+163) tmp = fma(Float64(y + -1.0), Float64(x * z), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+163], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+163}:\\
\;\;\;\;\mathsf{fma}\left(y + -1, x \cdot z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -5e163Initial program 89.6%
distribute-rgt-out--89.6%
*-lft-identity89.6%
cancel-sign-sub-inv89.6%
+-commutative89.6%
distribute-lft-neg-in89.6%
associate-*l*100.0%
fma-def100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
*-commutative100.0%
Simplified100.0%
if -5e163 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* x z))) (t_1 (* x (- z))))
(if (<= z -2.9e+165)
t_1
(if (<= z -3.6e+103)
(* x (* y z))
(if (<= z -3.6e+86)
t_1
(if (<= z -1.36e-29)
t_0
(if (<= z 1.0)
x
(if (or (<= z 6.2e+119) (not (<= z 3.95e+267))) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = y * (x * z);
double t_1 = x * -z;
double tmp;
if (z <= -2.9e+165) {
tmp = t_1;
} else if (z <= -3.6e+103) {
tmp = x * (y * z);
} else if (z <= -3.6e+86) {
tmp = t_1;
} else if (z <= -1.36e-29) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 6.2e+119) || !(z <= 3.95e+267)) {
tmp = t_1;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = y * (x * z)
t_1 = x * -z
if (z <= (-2.9d+165)) then
tmp = t_1
else if (z <= (-3.6d+103)) then
tmp = x * (y * z)
else if (z <= (-3.6d+86)) then
tmp = t_1
else if (z <= (-1.36d-29)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x
else if ((z <= 6.2d+119) .or. (.not. (z <= 3.95d+267))) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x * z);
double t_1 = x * -z;
double tmp;
if (z <= -2.9e+165) {
tmp = t_1;
} else if (z <= -3.6e+103) {
tmp = x * (y * z);
} else if (z <= -3.6e+86) {
tmp = t_1;
} else if (z <= -1.36e-29) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 6.2e+119) || !(z <= 3.95e+267)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x * z) t_1 = x * -z tmp = 0 if z <= -2.9e+165: tmp = t_1 elif z <= -3.6e+103: tmp = x * (y * z) elif z <= -3.6e+86: tmp = t_1 elif z <= -1.36e-29: tmp = t_0 elif z <= 1.0: tmp = x elif (z <= 6.2e+119) or not (z <= 3.95e+267): tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x * z)) t_1 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -2.9e+165) tmp = t_1; elseif (z <= -3.6e+103) tmp = Float64(x * Float64(y * z)); elseif (z <= -3.6e+86) tmp = t_1; elseif (z <= -1.36e-29) tmp = t_0; elseif (z <= 1.0) tmp = x; elseif ((z <= 6.2e+119) || !(z <= 3.95e+267)) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x * z); t_1 = x * -z; tmp = 0.0; if (z <= -2.9e+165) tmp = t_1; elseif (z <= -3.6e+103) tmp = x * (y * z); elseif (z <= -3.6e+86) tmp = t_1; elseif (z <= -1.36e-29) tmp = t_0; elseif (z <= 1.0) tmp = x; elseif ((z <= 6.2e+119) || ~((z <= 3.95e+267))) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -2.9e+165], t$95$1, If[LessEqual[z, -3.6e+103], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.6e+86], t$95$1, If[LessEqual[z, -1.36e-29], t$95$0, If[LessEqual[z, 1.0], x, If[Or[LessEqual[z, 6.2e+119], N[Not[LessEqual[z, 3.95e+267]], $MachinePrecision]], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot z\right)\\
t_1 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{+165}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{+86}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.36 \cdot 10^{-29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+119} \lor \neg \left(z \leq 3.95 \cdot 10^{+267}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.90000000000000006e165 or -3.60000000000000017e103 < z < -3.60000000000000005e86 or 1 < z < 6.1999999999999999e119 or 3.95000000000000008e267 < z Initial program 97.2%
Taylor expanded in z around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in y around 0 72.8%
mul-1-neg72.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
if -2.90000000000000006e165 < z < -3.60000000000000017e103Initial program 99.9%
distribute-rgt-out--99.9%
*-lft-identity99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
distribute-lft-neg-in99.9%
associate-*l*99.9%
fma-def99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
*-commutative99.9%
Simplified99.9%
fma-udef99.9%
associate-*r*100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 76.8%
Taylor expanded in x around 0 76.8%
Taylor expanded in y around inf 76.6%
associate-*r*76.6%
*-commutative76.6%
Simplified76.6%
if -3.60000000000000005e86 < z < -1.3600000000000001e-29 or 6.1999999999999999e119 < z < 3.95000000000000008e267Initial program 88.8%
Taylor expanded in y around inf 72.9%
if -1.3600000000000001e-29 < z < 1Initial program 99.9%
Taylor expanded in z around 0 79.4%
Final simplification76.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* z (* x y))))
(if (<= z -6.6e+162)
t_0
(if (<= z -2.9e+104)
t_1
(if (<= z -4.8e+86)
t_0
(if (<= z -3.5e-30)
t_1
(if (<= z 1.0)
x
(if (or (<= z 1.85e+120) (not (<= z 5.5e+271)))
t_0
(* y (* x z))))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = z * (x * y);
double tmp;
if (z <= -6.6e+162) {
tmp = t_0;
} else if (z <= -2.9e+104) {
tmp = t_1;
} else if (z <= -4.8e+86) {
tmp = t_0;
} else if (z <= -3.5e-30) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 1.85e+120) || !(z <= 5.5e+271)) {
tmp = t_0;
} else {
tmp = y * (x * z);
}
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) :: t_1
real(8) :: tmp
t_0 = x * -z
t_1 = z * (x * y)
if (z <= (-6.6d+162)) then
tmp = t_0
else if (z <= (-2.9d+104)) then
tmp = t_1
else if (z <= (-4.8d+86)) then
tmp = t_0
else if (z <= (-3.5d-30)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x
else if ((z <= 1.85d+120) .or. (.not. (z <= 5.5d+271))) then
tmp = t_0
else
tmp = y * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = z * (x * y);
double tmp;
if (z <= -6.6e+162) {
tmp = t_0;
} else if (z <= -2.9e+104) {
tmp = t_1;
} else if (z <= -4.8e+86) {
tmp = t_0;
} else if (z <= -3.5e-30) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 1.85e+120) || !(z <= 5.5e+271)) {
tmp = t_0;
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = z * (x * y) tmp = 0 if z <= -6.6e+162: tmp = t_0 elif z <= -2.9e+104: tmp = t_1 elif z <= -4.8e+86: tmp = t_0 elif z <= -3.5e-30: tmp = t_1 elif z <= 1.0: tmp = x elif (z <= 1.85e+120) or not (z <= 5.5e+271): tmp = t_0 else: tmp = y * (x * z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(z * Float64(x * y)) tmp = 0.0 if (z <= -6.6e+162) tmp = t_0; elseif (z <= -2.9e+104) tmp = t_1; elseif (z <= -4.8e+86) tmp = t_0; elseif (z <= -3.5e-30) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 1.85e+120) || !(z <= 5.5e+271)) tmp = t_0; else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = z * (x * y); tmp = 0.0; if (z <= -6.6e+162) tmp = t_0; elseif (z <= -2.9e+104) tmp = t_1; elseif (z <= -4.8e+86) tmp = t_0; elseif (z <= -3.5e-30) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 1.85e+120) || ~((z <= 5.5e+271))) tmp = t_0; else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.6e+162], t$95$0, If[LessEqual[z, -2.9e+104], t$95$1, If[LessEqual[z, -4.8e+86], t$95$0, If[LessEqual[z, -3.5e-30], t$95$1, If[LessEqual[z, 1.0], x, If[Or[LessEqual[z, 1.85e+120], N[Not[LessEqual[z, 5.5e+271]], $MachinePrecision]], t$95$0, N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := z \cdot \left(x \cdot y\right)\\
\mathbf{if}\;z \leq -6.6 \cdot 10^{+162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.9 \cdot 10^{+104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{-30}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{+120} \lor \neg \left(z \leq 5.5 \cdot 10^{+271}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -6.59999999999999975e162 or -2.8999999999999998e104 < z < -4.8000000000000001e86 or 1 < z < 1.85000000000000012e120 or 5.50000000000000021e271 < z Initial program 97.2%
Taylor expanded in z around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in y around 0 72.8%
mul-1-neg72.8%
distribute-rgt-neg-in72.8%
Simplified72.8%
if -6.59999999999999975e162 < z < -2.8999999999999998e104 or -4.8000000000000001e86 < z < -3.5000000000000003e-30Initial program 97.2%
Taylor expanded in y around inf 69.7%
associate-*r*67.0%
*-commutative67.0%
associate-*l*69.7%
Simplified69.7%
if -3.5000000000000003e-30 < z < 1Initial program 99.9%
Taylor expanded in z around 0 79.4%
if 1.85000000000000012e120 < z < 5.50000000000000021e271Initial program 80.9%
Taylor expanded in y around inf 80.8%
Final simplification76.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))) (if (<= t_0 (- INFINITY)) (* (* x z) (+ y -1.0)) t_0)))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) tmp = 0 if t_0 <= -math.inf: tmp = (x * z) * (y + -1.0) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(x * z) * Float64(y + -1.0)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); tmp = 0.0; if (t_0 <= -Inf) tmp = (x * z) * (y + -1.0); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -inf.0Initial program 83.0%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
associate-*l*100.0%
sub-neg100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
if -inf.0 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -3.55e+162)
t_0
(if (<= z -1.15e+106)
t_1
(if (<= z -5.5e+86)
t_0
(if (<= z -3.5e-33) t_1 (if (<= z 1.0) x t_0)))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -3.55e+162) {
tmp = t_0;
} else if (z <= -1.15e+106) {
tmp = t_1;
} else if (z <= -5.5e+86) {
tmp = t_0;
} else if (z <= -3.5e-33) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = t_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) :: t_1
real(8) :: tmp
t_0 = x * -z
t_1 = x * (y * z)
if (z <= (-3.55d+162)) then
tmp = t_0
else if (z <= (-1.15d+106)) then
tmp = t_1
else if (z <= (-5.5d+86)) then
tmp = t_0
else if (z <= (-3.5d-33)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -3.55e+162) {
tmp = t_0;
} else if (z <= -1.15e+106) {
tmp = t_1;
} else if (z <= -5.5e+86) {
tmp = t_0;
} else if (z <= -3.5e-33) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (y * z) tmp = 0 if z <= -3.55e+162: tmp = t_0 elif z <= -1.15e+106: tmp = t_1 elif z <= -5.5e+86: tmp = t_0 elif z <= -3.5e-33: tmp = t_1 elif z <= 1.0: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -3.55e+162) tmp = t_0; elseif (z <= -1.15e+106) tmp = t_1; elseif (z <= -5.5e+86) tmp = t_0; elseif (z <= -3.5e-33) tmp = t_1; elseif (z <= 1.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = x * (y * z); tmp = 0.0; if (z <= -3.55e+162) tmp = t_0; elseif (z <= -1.15e+106) tmp = t_1; elseif (z <= -5.5e+86) tmp = t_0; elseif (z <= -3.5e-33) tmp = t_1; elseif (z <= 1.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.55e+162], t$95$0, If[LessEqual[z, -1.15e+106], t$95$1, If[LessEqual[z, -5.5e+86], t$95$0, If[LessEqual[z, -3.5e-33], t$95$1, If[LessEqual[z, 1.0], x, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -3.55 \cdot 10^{+162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{+106}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{+86}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.5 \cdot 10^{-33}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3.5499999999999999e162 or -1.1500000000000001e106 < z < -5.5000000000000002e86 or 1 < z Initial program 93.5%
Taylor expanded in z around inf 99.5%
*-commutative99.5%
associate-*l*99.5%
sub-neg99.5%
metadata-eval99.5%
*-commutative99.5%
Simplified99.5%
Taylor expanded in y around 0 66.8%
mul-1-neg66.8%
distribute-rgt-neg-in66.8%
Simplified66.8%
if -3.5499999999999999e162 < z < -1.1500000000000001e106 or -5.5000000000000002e86 < z < -3.4999999999999999e-33Initial program 97.2%
distribute-rgt-out--97.2%
*-lft-identity97.2%
cancel-sign-sub-inv97.2%
+-commutative97.2%
distribute-lft-neg-in97.2%
associate-*l*99.8%
fma-def99.8%
neg-sub099.8%
associate--r-99.8%
metadata-eval99.8%
+-commutative99.8%
*-commutative99.8%
Simplified99.8%
fma-udef99.8%
associate-*r*99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 73.4%
Taylor expanded in x around 0 70.8%
Taylor expanded in y around inf 69.7%
associate-*r*67.0%
*-commutative67.0%
Simplified67.0%
if -3.4999999999999999e-33 < z < 1Initial program 99.9%
Taylor expanded in z around 0 79.4%
Final simplification73.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.55e-29) (not (<= z 950000000.0))) (* (* x z) (+ y -1.0)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-29) || !(z <= 950000000.0)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = x - (x * z);
}
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) :: tmp
if ((z <= (-1.55d-29)) .or. (.not. (z <= 950000000.0d0))) then
tmp = (x * z) * (y + (-1.0d0))
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.55e-29) || !(z <= 950000000.0)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.55e-29) or not (z <= 950000000.0): tmp = (x * z) * (y + -1.0) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.55e-29) || !(z <= 950000000.0)) tmp = Float64(Float64(x * z) * Float64(y + -1.0)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.55e-29) || ~((z <= 950000000.0))) tmp = (x * z) * (y + -1.0); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.55e-29], N[Not[LessEqual[z, 950000000.0]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.55 \cdot 10^{-29} \lor \neg \left(z \leq 950000000\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if z < -1.55000000000000013e-29 or 9.5e8 < z Initial program 94.5%
Taylor expanded in z around inf 98.2%
*-commutative98.2%
associate-*l*98.2%
sub-neg98.2%
metadata-eval98.2%
*-commutative98.2%
Simplified98.2%
if -1.55000000000000013e-29 < z < 9.5e8Initial program 99.9%
Taylor expanded in y around 0 80.1%
*-commutative80.1%
distribute-rgt-out--80.1%
*-lft-identity80.1%
Simplified80.1%
Final simplification88.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.92) (not (<= z 1.0))) (* (* x z) (+ y -1.0)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.92) || !(z <= 1.0)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = x * (1.0 + (y * z));
}
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) :: tmp
if ((z <= (-0.92d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x * z) * (y + (-1.0d0))
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.92) || !(z <= 1.0)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.92) or not (z <= 1.0): tmp = (x * z) * (y + -1.0) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.92) || !(z <= 1.0)) tmp = Float64(Float64(x * z) * Float64(y + -1.0)); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.92) || ~((z <= 1.0))) tmp = (x * z) * (y + -1.0); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.92], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.92 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.92000000000000004 or 1 < z Initial program 94.2%
Taylor expanded in z around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
Simplified99.4%
if -0.92000000000000004 < z < 1Initial program 99.9%
distribute-rgt-out--99.9%
*-lft-identity99.9%
cancel-sign-sub-inv99.9%
+-commutative99.9%
distribute-lft-neg-in99.9%
associate-*l*95.7%
fma-def95.7%
neg-sub095.7%
associate--r-95.7%
metadata-eval95.7%
+-commutative95.7%
*-commutative95.7%
Simplified95.7%
fma-udef95.7%
associate-*r*96.0%
Applied egg-rr96.0%
Taylor expanded in y around inf 94.6%
Taylor expanded in x around 0 98.8%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e+26) (not (<= y 3.2e+71))) (* z (* x y)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+26) || !(y <= 3.2e+71)) {
tmp = z * (x * y);
} else {
tmp = x - (x * z);
}
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) :: tmp
if ((y <= (-6.5d+26)) .or. (.not. (y <= 3.2d+71))) then
tmp = z * (x * y)
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+26) || !(y <= 3.2e+71)) {
tmp = z * (x * y);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e+26) or not (y <= 3.2e+71): tmp = z * (x * y) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.5e+26) || !(y <= 3.2e+71)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.5e+26) || ~((y <= 3.2e+71))) tmp = z * (x * y); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.5e+26], N[Not[LessEqual[y, 3.2e+71]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+26} \lor \neg \left(y \leq 3.2 \cdot 10^{+71}\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -6.50000000000000022e26 or 3.20000000000000023e71 < y Initial program 93.0%
Taylor expanded in y around inf 76.3%
associate-*r*75.8%
*-commutative75.8%
associate-*l*78.3%
Simplified78.3%
if -6.50000000000000022e26 < y < 3.20000000000000023e71Initial program 100.0%
Taylor expanded in y around 0 93.9%
*-commutative93.9%
distribute-rgt-out--93.9%
*-lft-identity93.9%
Simplified93.9%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.41) (not (<= z 1.0))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.41) || !(z <= 1.0)) {
tmp = x * -z;
} else {
tmp = x;
}
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) :: tmp
if ((z <= (-0.41d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.41) || !(z <= 1.0)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.41) or not (z <= 1.0): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.41) || !(z <= 1.0)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.41) || ~((z <= 1.0))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.41], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.41 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.409999999999999976 or 1 < z Initial program 94.2%
Taylor expanded in z around inf 99.4%
*-commutative99.4%
associate-*l*99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
Simplified99.4%
Taylor expanded in y around 0 58.6%
mul-1-neg58.6%
distribute-rgt-neg-in58.6%
Simplified58.6%
if -0.409999999999999976 < z < 1Initial program 99.9%
Taylor expanded in z around 0 76.3%
Final simplification68.3%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 97.3%
Taylor expanded in z around 0 43.3%
Final simplification43.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023185
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))