
(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 11 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 (* (+ y -1.0) z)))))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 2e+296)))
(* z (* (+ y -1.0) x))
(* x (+ 1.0 (- (* y z) z))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 + ((y + -1.0) * z));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 2e+296)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x * (1.0 + ((y * z) - z));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + ((y + -1.0) * z));
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 2e+296)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x * (1.0 + ((y * z) - z));
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 + ((y + -1.0) * z)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 2e+296): tmp = z * ((y + -1.0) * x) else: tmp = x * (1.0 + ((y * z) - z)) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 2e+296)) tmp = Float64(z * Float64(Float64(y + -1.0) * x)); else tmp = Float64(x * Float64(1.0 + Float64(Float64(y * z) - z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 + ((y + -1.0) * z)); tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 2e+296))) tmp = z * ((y + -1.0) * x); else tmp = x * (1.0 + ((y * z) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 2e+296]], $MachinePrecision]], N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 2 \cdot 10^{+296}\right):\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(y \cdot z - z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -inf.0 or 1.99999999999999996e296 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 77.9%
Taylor expanded in z around inf 77.9%
*-commutative77.9%
associate-*l*99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -inf.0 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 1.99999999999999996e296Initial program 99.8%
Taylor expanded in y around 0 99.8%
mul-1-neg99.8%
unsub-neg99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- 1.0 y))))
(if (<= t_0 -5e+249)
(* (+ y -1.0) (* x z))
(if (<= t_0 1e+257)
(* x (+ 1.0 (* (+ y -1.0) z)))
(* z (* (+ y -1.0) x))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -5e+249) {
tmp = (y + -1.0) * (x * z);
} else if (t_0 <= 1e+257) {
tmp = x * (1.0 + ((y + -1.0) * z));
} else {
tmp = z * ((y + -1.0) * 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) :: t_0
real(8) :: tmp
t_0 = z * (1.0d0 - y)
if (t_0 <= (-5d+249)) then
tmp = (y + (-1.0d0)) * (x * z)
else if (t_0 <= 1d+257) then
tmp = x * (1.0d0 + ((y + (-1.0d0)) * z))
else
tmp = z * ((y + (-1.0d0)) * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -5e+249) {
tmp = (y + -1.0) * (x * z);
} else if (t_0 <= 1e+257) {
tmp = x * (1.0 + ((y + -1.0) * z));
} else {
tmp = z * ((y + -1.0) * x);
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if t_0 <= -5e+249: tmp = (y + -1.0) * (x * z) elif t_0 <= 1e+257: tmp = x * (1.0 + ((y + -1.0) * z)) else: tmp = z * ((y + -1.0) * x) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if (t_0 <= -5e+249) tmp = Float64(Float64(y + -1.0) * Float64(x * z)); elseif (t_0 <= 1e+257) tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); else tmp = Float64(z * Float64(Float64(y + -1.0) * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if (t_0 <= -5e+249) tmp = (y + -1.0) * (x * z); elseif (t_0 <= 1e+257) tmp = x * (1.0 + ((y + -1.0) * z)); else tmp = z * ((y + -1.0) * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+249], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+257], N[(x * N[(1.0 + N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+249}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;t_0 \leq 10^{+257}:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -4.9999999999999996e249Initial program 82.5%
Taylor expanded in z around inf 82.5%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
if -4.9999999999999996e249 < (*.f64 (-.f64 1 y) z) < 1.00000000000000003e257Initial program 99.8%
if 1.00000000000000003e257 < (*.f64 (-.f64 1 y) z) Initial program 65.1%
Taylor expanded in z around inf 65.1%
*-commutative65.1%
associate-*l*100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -2.65e+218)
t_0
(if (<= z -1.4e+84)
t_1
(if (<= z -1.0)
t_0
(if (<= z 1.7e-132)
x
(if (or (<= z 1.7e+21) (and (not (<= z 2.9e+239)) (<= z 1.26e+266)))
t_1
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 <= -2.65e+218) {
tmp = t_0;
} else if (z <= -1.4e+84) {
tmp = t_1;
} else if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.7e-132) {
tmp = x;
} else if ((z <= 1.7e+21) || (!(z <= 2.9e+239) && (z <= 1.26e+266))) {
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 = x * -z
t_1 = x * (y * z)
if (z <= (-2.65d+218)) then
tmp = t_0
else if (z <= (-1.4d+84)) then
tmp = t_1
else if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 1.7d-132) then
tmp = x
else if ((z <= 1.7d+21) .or. (.not. (z <= 2.9d+239)) .and. (z <= 1.26d+266)) 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 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -2.65e+218) {
tmp = t_0;
} else if (z <= -1.4e+84) {
tmp = t_1;
} else if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.7e-132) {
tmp = x;
} else if ((z <= 1.7e+21) || (!(z <= 2.9e+239) && (z <= 1.26e+266))) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (y * z) tmp = 0 if z <= -2.65e+218: tmp = t_0 elif z <= -1.4e+84: tmp = t_1 elif z <= -1.0: tmp = t_0 elif z <= 1.7e-132: tmp = x elif (z <= 1.7e+21) or (not (z <= 2.9e+239) and (z <= 1.26e+266)): tmp = t_1 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 <= -2.65e+218) tmp = t_0; elseif (z <= -1.4e+84) tmp = t_1; elseif (z <= -1.0) tmp = t_0; elseif (z <= 1.7e-132) tmp = x; elseif ((z <= 1.7e+21) || (!(z <= 2.9e+239) && (z <= 1.26e+266))) tmp = t_1; 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 <= -2.65e+218) tmp = t_0; elseif (z <= -1.4e+84) tmp = t_1; elseif (z <= -1.0) tmp = t_0; elseif (z <= 1.7e-132) tmp = x; elseif ((z <= 1.7e+21) || (~((z <= 2.9e+239)) && (z <= 1.26e+266))) tmp = t_1; 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, -2.65e+218], t$95$0, If[LessEqual[z, -1.4e+84], t$95$1, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 1.7e-132], x, If[Or[LessEqual[z, 1.7e+21], And[N[Not[LessEqual[z, 2.9e+239]], $MachinePrecision], LessEqual[z, 1.26e+266]]], t$95$1, 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 -2.65 \cdot 10^{+218}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{+84}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-132}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{+21} \lor \neg \left(z \leq 2.9 \cdot 10^{+239}\right) \land z \leq 1.26 \cdot 10^{+266}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.6500000000000001e218 or -1.39999999999999991e84 < z < -1 or 1.7e21 < z < 2.9000000000000002e239 or 1.26e266 < z Initial program 87.6%
Taylor expanded in y around 0 62.5%
sub-neg62.5%
distribute-rgt-in62.5%
*-lft-identity62.5%
distribute-lft-neg-out62.5%
*-commutative62.5%
unsub-neg62.5%
Simplified62.5%
Taylor expanded in z around inf 61.6%
mul-1-neg61.6%
distribute-rgt-neg-in61.6%
Simplified61.6%
if -2.6500000000000001e218 < z < -1.39999999999999991e84 or 1.69999999999999991e-132 < z < 1.7e21 or 2.9000000000000002e239 < z < 1.26e266Initial program 93.7%
Taylor expanded in y around inf 59.1%
*-commutative59.1%
Simplified59.1%
if -1 < z < 1.69999999999999991e-132Initial program 99.8%
Taylor expanded in z around 0 79.0%
Final simplification68.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* (+ y -1.0) x))))
(if (<= z -2.9e-44)
t_0
(if (<= z 1.7e-132)
x
(if (<= z 4.6e-70) (* x (* y z)) (if (<= z 1.6e-55) x t_0))))))
double code(double x, double y, double z) {
double t_0 = z * ((y + -1.0) * x);
double tmp;
if (z <= -2.9e-44) {
tmp = t_0;
} else if (z <= 1.7e-132) {
tmp = x;
} else if (z <= 4.6e-70) {
tmp = x * (y * z);
} else if (z <= 1.6e-55) {
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) :: tmp
t_0 = z * ((y + (-1.0d0)) * x)
if (z <= (-2.9d-44)) then
tmp = t_0
else if (z <= 1.7d-132) then
tmp = x
else if (z <= 4.6d-70) then
tmp = x * (y * z)
else if (z <= 1.6d-55) 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 = z * ((y + -1.0) * x);
double tmp;
if (z <= -2.9e-44) {
tmp = t_0;
} else if (z <= 1.7e-132) {
tmp = x;
} else if (z <= 4.6e-70) {
tmp = x * (y * z);
} else if (z <= 1.6e-55) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * ((y + -1.0) * x) tmp = 0 if z <= -2.9e-44: tmp = t_0 elif z <= 1.7e-132: tmp = x elif z <= 4.6e-70: tmp = x * (y * z) elif z <= 1.6e-55: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(Float64(y + -1.0) * x)) tmp = 0.0 if (z <= -2.9e-44) tmp = t_0; elseif (z <= 1.7e-132) tmp = x; elseif (z <= 4.6e-70) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.6e-55) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * ((y + -1.0) * x); tmp = 0.0; if (z <= -2.9e-44) tmp = t_0; elseif (z <= 1.7e-132) tmp = x; elseif (z <= 4.6e-70) tmp = x * (y * z); elseif (z <= 1.6e-55) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.9e-44], t$95$0, If[LessEqual[z, 1.7e-132], x, If[LessEqual[z, 4.6e-70], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e-55], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\mathbf{if}\;z \leq -2.9 \cdot 10^{-44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-132}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-70}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.9000000000000001e-44 or 1.6000000000000001e-55 < z Initial program 89.7%
Taylor expanded in z around inf 85.1%
*-commutative85.1%
associate-*l*95.3%
sub-neg95.3%
metadata-eval95.3%
Simplified95.3%
if -2.9000000000000001e-44 < z < 1.69999999999999991e-132 or 4.60000000000000001e-70 < z < 1.6000000000000001e-55Initial program 99.8%
Taylor expanded in z around 0 82.0%
if 1.69999999999999991e-132 < z < 4.60000000000000001e-70Initial program 99.7%
Taylor expanded in y around inf 79.3%
*-commutative79.3%
Simplified79.3%
Final simplification89.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* y z))))
(if (<= y -6.9e+47)
t_0
(if (<= y 130000000000.0)
(* x (- 1.0 z))
(if (or (<= y 1e+118) (not (<= y 1.7e+166))) t_0 x)))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -6.9e+47) {
tmp = t_0;
} else if (y <= 130000000000.0) {
tmp = x * (1.0 - z);
} else if ((y <= 1e+118) || !(y <= 1.7e+166)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (y * z)
if (y <= (-6.9d+47)) then
tmp = t_0
else if (y <= 130000000000.0d0) then
tmp = x * (1.0d0 - z)
else if ((y <= 1d+118) .or. (.not. (y <= 1.7d+166))) then
tmp = t_0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -6.9e+47) {
tmp = t_0;
} else if (y <= 130000000000.0) {
tmp = x * (1.0 - z);
} else if ((y <= 1e+118) || !(y <= 1.7e+166)) {
tmp = t_0;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if y <= -6.9e+47: tmp = t_0 elif y <= 130000000000.0: tmp = x * (1.0 - z) elif (y <= 1e+118) or not (y <= 1.7e+166): tmp = t_0 else: tmp = x return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (y <= -6.9e+47) tmp = t_0; elseif (y <= 130000000000.0) tmp = Float64(x * Float64(1.0 - z)); elseif ((y <= 1e+118) || !(y <= 1.7e+166)) tmp = t_0; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * z); tmp = 0.0; if (y <= -6.9e+47) tmp = t_0; elseif (y <= 130000000000.0) tmp = x * (1.0 - z); elseif ((y <= 1e+118) || ~((y <= 1.7e+166))) tmp = t_0; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.9e+47], t$95$0, If[LessEqual[y, 130000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1e+118], N[Not[LessEqual[y, 1.7e+166]], $MachinePrecision]], t$95$0, x]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \leq -6.9 \cdot 10^{+47}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 130000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq 10^{+118} \lor \neg \left(y \leq 1.7 \cdot 10^{+166}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -6.9000000000000004e47 or 1.3e11 < y < 9.99999999999999967e117 or 1.7e166 < y Initial program 86.5%
Taylor expanded in y around inf 72.5%
*-commutative72.5%
Simplified72.5%
if -6.9000000000000004e47 < y < 1.3e11Initial program 99.3%
Taylor expanded in y around 0 94.3%
if 9.99999999999999967e117 < y < 1.7e166Initial program 99.8%
Taylor expanded in z around 0 80.2%
Final simplification84.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -3e-44) (not (<= z 1.7e-132))) (* x (- (* y z) z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3e-44) || !(z <= 1.7e-132)) {
tmp = x * ((y * z) - 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 <= (-3d-44)) .or. (.not. (z <= 1.7d-132))) then
tmp = x * ((y * z) - z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3e-44) || !(z <= 1.7e-132)) {
tmp = x * ((y * z) - z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3e-44) or not (z <= 1.7e-132): tmp = x * ((y * z) - z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3e-44) || !(z <= 1.7e-132)) tmp = Float64(x * Float64(Float64(y * z) - z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3e-44) || ~((z <= 1.7e-132))) tmp = x * ((y * z) - z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3e-44], N[Not[LessEqual[z, 1.7e-132]], $MachinePrecision]], N[(x * N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-44} \lor \neg \left(z \leq 1.7 \cdot 10^{-132}\right):\\
\;\;\;\;x \cdot \left(y \cdot z - z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.0000000000000002e-44 or 1.69999999999999991e-132 < z Initial program 90.5%
Taylor expanded in y around 0 90.5%
mul-1-neg90.5%
unsub-neg90.5%
*-commutative90.5%
Simplified90.5%
Taylor expanded in z around inf 83.2%
sub-neg83.2%
metadata-eval83.2%
distribute-rgt-in83.3%
neg-mul-183.3%
fma-def83.2%
fma-neg83.3%
Simplified83.3%
if -3.0000000000000002e-44 < z < 1.69999999999999991e-132Initial program 99.8%
Taylor expanded in z around 0 81.5%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.94) (not (<= z 1.0))) (* z (* (+ y -1.0) x)) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.94) || !(z <= 1.0)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x + (x * (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.94d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * ((y + (-1.0d0)) * x)
else
tmp = x + (x * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.94) || !(z <= 1.0)) {
tmp = z * ((y + -1.0) * x);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.94) or not (z <= 1.0): tmp = z * ((y + -1.0) * x) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.94) || !(z <= 1.0)) tmp = Float64(z * Float64(Float64(y + -1.0) * x)); else tmp = Float64(x + Float64(x * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.94) || ~((z <= 1.0))) tmp = z * ((y + -1.0) * x); else tmp = x + (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.94], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.94 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.93999999999999995 or 1 < z Initial program 88.8%
Taylor expanded in z around inf 87.2%
*-commutative87.2%
associate-*l*98.3%
sub-neg98.3%
metadata-eval98.3%
Simplified98.3%
if -0.93999999999999995 < z < 1Initial program 99.8%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around inf 99.2%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (<= z -3e-44) (* z (* (+ y -1.0) x)) (if (<= z 1.7e-132) x (* (+ y -1.0) (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3e-44) {
tmp = z * ((y + -1.0) * x);
} else if (z <= 1.7e-132) {
tmp = x;
} else {
tmp = (y + -1.0) * (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 <= (-3d-44)) then
tmp = z * ((y + (-1.0d0)) * x)
else if (z <= 1.7d-132) then
tmp = x
else
tmp = (y + (-1.0d0)) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3e-44) {
tmp = z * ((y + -1.0) * x);
} else if (z <= 1.7e-132) {
tmp = x;
} else {
tmp = (y + -1.0) * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3e-44: tmp = z * ((y + -1.0) * x) elif z <= 1.7e-132: tmp = x else: tmp = (y + -1.0) * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3e-44) tmp = Float64(z * Float64(Float64(y + -1.0) * x)); elseif (z <= 1.7e-132) tmp = x; else tmp = Float64(Float64(y + -1.0) * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3e-44) tmp = z * ((y + -1.0) * x); elseif (z <= 1.7e-132) tmp = x; else tmp = (y + -1.0) * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3e-44], N[(z * N[(N[(y + -1.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.7e-132], x, N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-44}:\\
\;\;\;\;z \cdot \left(\left(y + -1\right) \cdot x\right)\\
\mathbf{elif}\;z \leq 1.7 \cdot 10^{-132}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -3.0000000000000002e-44Initial program 91.1%
Taylor expanded in z around inf 86.4%
*-commutative86.4%
associate-*l*95.2%
sub-neg95.2%
metadata-eval95.2%
Simplified95.2%
if -3.0000000000000002e-44 < z < 1.69999999999999991e-132Initial program 99.8%
Taylor expanded in z around 0 81.5%
if 1.69999999999999991e-132 < z Initial program 89.9%
Taylor expanded in z around inf 80.4%
associate-*r*89.2%
*-commutative89.2%
sub-neg89.2%
metadata-eval89.2%
Simplified89.2%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (+ x (* (+ y -1.0) (* x z))))
double code(double x, double y, double z) {
return x + ((y + -1.0) * (x * 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 + ((y + (-1.0d0)) * (x * z))
end function
public static double code(double x, double y, double z) {
return x + ((y + -1.0) * (x * z));
}
def code(x, y, z): return x + ((y + -1.0) * (x * z))
function code(x, y, z) return Float64(x + Float64(Float64(y + -1.0) * Float64(x * z))) end
function tmp = code(x, y, z) tmp = x + ((y + -1.0) * (x * z)); end
code[x_, y_, z_] := N[(x + N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y + -1\right) \cdot \left(x \cdot z\right)
\end{array}
Initial program 94.0%
Taylor expanded in z around 0 94.0%
+-commutative94.0%
associate-*r*97.6%
*-commutative97.6%
fma-def97.6%
sub-neg97.6%
metadata-eval97.6%
Applied egg-rr97.6%
fma-udef97.6%
Applied egg-rr97.6%
Final simplification97.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(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 <= (-1.0d0)) .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 <= -1.0) || !(z <= 1.0)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(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 <= -1.0) || ~((z <= 1.0))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 88.8%
Taylor expanded in y around 0 54.4%
sub-neg54.4%
distribute-rgt-in54.3%
*-lft-identity54.3%
distribute-lft-neg-out54.3%
*-commutative54.3%
unsub-neg54.3%
Simplified54.3%
Taylor expanded in z around inf 52.8%
mul-1-neg52.8%
distribute-rgt-neg-in52.8%
Simplified52.8%
if -1 < z < 1Initial program 99.8%
Taylor expanded in z around 0 72.5%
Final simplification62.1%
(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 94.0%
Taylor expanded in z around 0 36.1%
Final simplification36.1%
(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 2023290
(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))))