
(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 13 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 (if (<= z 3.7e+15) (* x (- (+ 1.0 (* y z)) z)) (* (+ y -1.0) (* x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.7e+15) {
tmp = x * ((1.0 + (y * z)) - z);
} 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 <= 3.7d+15) then
tmp = x * ((1.0d0 + (y * z)) - z)
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 <= 3.7e+15) {
tmp = x * ((1.0 + (y * z)) - z);
} else {
tmp = (y + -1.0) * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 3.7e+15: tmp = x * ((1.0 + (y * z)) - z) else: tmp = (y + -1.0) * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 3.7e+15) tmp = Float64(x * Float64(Float64(1.0 + Float64(y * z)) - z)); 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 <= 3.7e+15) tmp = x * ((1.0 + (y * z)) - z); else tmp = (y + -1.0) * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 3.7e+15], N[(x * N[(N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.7 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \left(\left(1 + y \cdot z\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < 3.7e15Initial program 98.9%
Taylor expanded in y around 0 98.9%
if 3.7e15 < z Initial program 91.9%
Taylor expanded in y around 0 91.9%
Taylor expanded in z around inf 91.9%
sub-neg91.9%
metadata-eval91.9%
associate-*r*99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
(if (<= z -1.7e+276)
t_0
(if (<= z -1.45e-27)
t_1
(if (<= z 4.2e-43) x (if (<= z 1.25e+28) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -1.7e+276) {
tmp = t_0;
} else if (z <= -1.45e-27) {
tmp = t_1;
} else if (z <= 4.2e-43) {
tmp = x;
} else if (z <= 1.25e+28) {
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 = z * -x
t_1 = x * (y * z)
if (z <= (-1.7d+276)) then
tmp = t_0
else if (z <= (-1.45d-27)) then
tmp = t_1
else if (z <= 4.2d-43) then
tmp = x
else if (z <= 1.25d+28) 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 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -1.7e+276) {
tmp = t_0;
} else if (z <= -1.45e-27) {
tmp = t_1;
} else if (z <= 4.2e-43) {
tmp = x;
} else if (z <= 1.25e+28) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (y * z) tmp = 0 if z <= -1.7e+276: tmp = t_0 elif z <= -1.45e-27: tmp = t_1 elif z <= 4.2e-43: tmp = x elif z <= 1.25e+28: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -1.7e+276) tmp = t_0; elseif (z <= -1.45e-27) tmp = t_1; elseif (z <= 4.2e-43) tmp = x; elseif (z <= 1.25e+28) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (y * z); tmp = 0.0; if (z <= -1.7e+276) tmp = t_0; elseif (z <= -1.45e-27) tmp = t_1; elseif (z <= 4.2e-43) tmp = x; elseif (z <= 1.25e+28) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.7e+276], t$95$0, If[LessEqual[z, -1.45e-27], t$95$1, If[LessEqual[z, 4.2e-43], x, If[LessEqual[z, 1.25e+28], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.7 \cdot 10^{+276}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{-27}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{+28}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.69999999999999992e276 or 1.24999999999999989e28 < z Initial program 92.4%
Taylor expanded in y around 0 66.4%
Taylor expanded in z around inf 66.4%
mul-1-neg66.4%
distribute-rgt-neg-out66.4%
Simplified66.4%
if -1.69999999999999992e276 < z < -1.45000000000000002e-27 or 4.2000000000000001e-43 < z < 1.24999999999999989e28Initial program 97.3%
Taylor expanded in y around inf 62.6%
*-commutative62.6%
Simplified62.6%
if -1.45000000000000002e-27 < z < 4.2000000000000001e-43Initial program 99.9%
Taylor expanded in z around 0 80.2%
Final simplification71.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.3e+25) (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 <= -4.3e+25) || !(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 <= (-4.3d+25)) .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 <= -4.3e+25) || !(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 <= -4.3e+25) 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 <= -4.3e+25) || !(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 <= -4.3e+25) || ~((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, -4.3e+25], 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 -4.3 \cdot 10^{+25} \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 < -4.29999999999999998e25 or 1 < z Initial program 94.5%
Taylor expanded in y around 0 94.6%
Taylor expanded in z around inf 94.4%
sub-neg94.4%
metadata-eval94.4%
associate-*r*99.8%
Simplified99.8%
if -4.29999999999999998e25 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.5%
*-commutative98.5%
*-commutative98.5%
distribute-rgt1-in98.5%
Applied egg-rr98.5%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.2e-35) (not (<= z 2.5e-43))) (* (* x z) (+ y -1.0)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.2e-35) || !(z <= 2.5e-43)) {
tmp = (x * z) * (y + -1.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) :: tmp
if ((z <= (-4.2d-35)) .or. (.not. (z <= 2.5d-43))) then
tmp = (x * z) * (y + (-1.0d0))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.2e-35) || !(z <= 2.5e-43)) {
tmp = (x * z) * (y + -1.0);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.2e-35) or not (z <= 2.5e-43): tmp = (x * z) * (y + -1.0) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.2e-35) || !(z <= 2.5e-43)) tmp = Float64(Float64(x * z) * Float64(y + -1.0)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.2e-35) || ~((z <= 2.5e-43))) tmp = (x * z) * (y + -1.0); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.2e-35], N[Not[LessEqual[z, 2.5e-43]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-35} \lor \neg \left(z \leq 2.5 \cdot 10^{-43}\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.2e-35 or 2.50000000000000009e-43 < z Initial program 95.1%
Taylor expanded in y around 0 95.2%
Taylor expanded in z around inf 91.7%
sub-neg91.7%
metadata-eval91.7%
associate-*r*96.4%
Simplified96.4%
if -4.2e-35 < z < 2.50000000000000009e-43Initial program 99.9%
Taylor expanded in z around 0 80.6%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-35) (not (<= z 4.3e-42))) (* x (* z (+ y -1.0))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-35) || !(z <= 4.3e-42)) {
tmp = x * (z * (y + -1.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) :: tmp
if ((z <= (-1d-35)) .or. (.not. (z <= 4.3d-42))) then
tmp = x * (z * (y + (-1.0d0)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-35) || !(z <= 4.3e-42)) {
tmp = x * (z * (y + -1.0));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-35) or not (z <= 4.3e-42): tmp = x * (z * (y + -1.0)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-35) || !(z <= 4.3e-42)) tmp = Float64(x * Float64(z * Float64(y + -1.0))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-35) || ~((z <= 4.3e-42))) tmp = x * (z * (y + -1.0)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-35], N[Not[LessEqual[z, 4.3e-42]], $MachinePrecision]], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-35} \lor \neg \left(z \leq 4.3 \cdot 10^{-42}\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.00000000000000001e-35 or 4.3000000000000001e-42 < z Initial program 95.1%
Taylor expanded in z around inf 91.7%
if -1.00000000000000001e-35 < z < 4.3000000000000001e-42Initial program 99.9%
Taylor expanded in z around 0 80.6%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (<= z -3.1e-35) (* x (- (* y z) z)) (if (<= z 5.5e-41) x (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e-35) {
tmp = x * ((y * z) - z);
} else if (z <= 5.5e-41) {
tmp = x;
} else {
tmp = x * (z * (y + -1.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) :: tmp
if (z <= (-3.1d-35)) then
tmp = x * ((y * z) - z)
else if (z <= 5.5d-41) then
tmp = x
else
tmp = x * (z * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.1e-35) {
tmp = x * ((y * z) - z);
} else if (z <= 5.5e-41) {
tmp = x;
} else {
tmp = x * (z * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.1e-35: tmp = x * ((y * z) - z) elif z <= 5.5e-41: tmp = x else: tmp = x * (z * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.1e-35) tmp = Float64(x * Float64(Float64(y * z) - z)); elseif (z <= 5.5e-41) tmp = x; else tmp = Float64(x * Float64(z * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.1e-35) tmp = x * ((y * z) - z); elseif (z <= 5.5e-41) tmp = x; else tmp = x * (z * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.1e-35], N[(x * N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.5e-41], x, N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \left(y \cdot z - z\right)\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -3.10000000000000012e-35Initial program 97.1%
Taylor expanded in z around inf 94.5%
distribute-rgt-out--94.5%
*-un-lft-identity94.5%
Applied egg-rr94.5%
if -3.10000000000000012e-35 < z < 5.50000000000000022e-41Initial program 99.9%
Taylor expanded in z around 0 80.6%
if 5.50000000000000022e-41 < z Initial program 93.2%
Taylor expanded in z around inf 88.9%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e+68) (not (<= y 9e+60))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+68) || !(y <= 9e+60)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - 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 <= (-1.25d+68)) .or. (.not. (y <= 9d+60))) then
tmp = x * (y * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e+68) || !(y <= 9e+60)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e+68) or not (y <= 9e+60): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e+68) || !(y <= 9e+60)) tmp = Float64(x * Float64(y * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.25e+68) || ~((y <= 9e+60))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e+68], N[Not[LessEqual[y, 9e+60]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+68} \lor \neg \left(y \leq 9 \cdot 10^{+60}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.2500000000000001e68 or 9.00000000000000026e60 < y Initial program 93.9%
Taylor expanded in y around inf 72.1%
*-commutative72.1%
Simplified72.1%
if -1.2500000000000001e68 < y < 9.00000000000000026e60Initial program 99.9%
Taylor expanded in y around 0 96.8%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.3e+68) (* z (* y x)) (if (<= y 1e+61) (- x (* x z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e+68) {
tmp = z * (y * x);
} else if (y <= 1e+61) {
tmp = x - (x * z);
} else {
tmp = 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 (y <= (-1.3d+68)) then
tmp = z * (y * x)
else if (y <= 1d+61) then
tmp = x - (x * z)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e+68) {
tmp = z * (y * x);
} else if (y <= 1e+61) {
tmp = x - (x * z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.3e+68: tmp = z * (y * x) elif y <= 1e+61: tmp = x - (x * z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.3e+68) tmp = Float64(z * Float64(y * x)); elseif (y <= 1e+61) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.3e+68) tmp = z * (y * x); elseif (y <= 1e+61) tmp = x - (x * z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.3e+68], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+61], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{+68}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 10^{+61}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -1.2999999999999999e68Initial program 95.4%
Taylor expanded in y around inf 75.6%
associate-*r*77.7%
Simplified77.7%
if -1.2999999999999999e68 < y < 9.99999999999999949e60Initial program 99.9%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
associate-+l+100.0%
sub-neg100.0%
*-un-lft-identity100.0%
distribute-rgt-out--99.9%
+-commutative99.9%
distribute-rgt-out100.0%
*-un-lft-identity100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.8%
neg-mul-196.8%
distribute-lft-neg-in96.8%
Simplified96.8%
+-commutative96.8%
distribute-lft-neg-out96.8%
unsub-neg96.8%
*-commutative96.8%
Applied egg-rr96.8%
if 9.99999999999999949e60 < y Initial program 93.1%
Taylor expanded in y around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -8e+67) (* z (* y x)) (if (<= y 9e+60) (* x (- 1.0 z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8e+67) {
tmp = z * (y * x);
} else if (y <= 9e+60) {
tmp = x * (1.0 - z);
} else {
tmp = 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 (y <= (-8d+67)) then
tmp = z * (y * x)
else if (y <= 9d+60) then
tmp = x * (1.0d0 - z)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8e+67) {
tmp = z * (y * x);
} else if (y <= 9e+60) {
tmp = x * (1.0 - z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8e+67: tmp = z * (y * x) elif y <= 9e+60: tmp = x * (1.0 - z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8e+67) tmp = Float64(z * Float64(y * x)); elseif (y <= 9e+60) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8e+67) tmp = z * (y * x); elseif (y <= 9e+60) tmp = x * (1.0 - z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8e+67], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e+60], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+67}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+60}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -7.99999999999999986e67Initial program 95.4%
Taylor expanded in y around inf 75.6%
associate-*r*77.7%
Simplified77.7%
if -7.99999999999999986e67 < y < 9.00000000000000026e60Initial program 99.9%
Taylor expanded in y around 0 96.8%
if 9.00000000000000026e60 < y Initial program 93.1%
Taylor expanded in y around inf 70.0%
*-commutative70.0%
Simplified70.0%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.3e+25) (not (<= z 1.05))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.3e+25) || !(z <= 1.05)) {
tmp = z * -x;
} 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 <= (-4.3d+25)) .or. (.not. (z <= 1.05d0))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.3e+25) || !(z <= 1.05)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.3e+25) or not (z <= 1.05): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.3e+25) || !(z <= 1.05)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.3e+25) || ~((z <= 1.05))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.3e+25], N[Not[LessEqual[z, 1.05]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+25} \lor \neg \left(z \leq 1.05\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.29999999999999998e25 or 1.05000000000000004 < z Initial program 94.5%
Taylor expanded in y around 0 57.4%
Taylor expanded in z around inf 57.4%
mul-1-neg57.4%
distribute-rgt-neg-out57.4%
Simplified57.4%
if -4.29999999999999998e25 < z < 1.05000000000000004Initial program 99.9%
Taylor expanded in z around 0 73.5%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (if (<= z 4e+15) (* x (+ 1.0 (* z (+ y -1.0)))) (* (* x z) (+ y -1.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= 4e+15) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (x * z) * (y + -1.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) :: tmp
if (z <= 4d+15) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = (x * z) * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 4e+15) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (x * z) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 4e+15: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = (x * z) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 4e+15) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(x * z) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 4e+15) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = (x * z) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 4e+15], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if z < 4e15Initial program 98.9%
if 4e15 < z Initial program 91.9%
Taylor expanded in y around 0 91.9%
Taylor expanded in z around inf 91.9%
sub-neg91.9%
metadata-eval91.9%
associate-*r*99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (+ x (* (* x z) (+ y -1.0))))
double code(double x, double y, double z) {
return x + ((x * z) * (y + -1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((x * z) * (y + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return x + ((x * z) * (y + -1.0));
}
def code(x, y, z): return x + ((x * z) * (y + -1.0))
function code(x, y, z) return Float64(x + Float64(Float64(x * z) * Float64(y + -1.0))) end
function tmp = code(x, y, z) tmp = x + ((x * z) * (y + -1.0)); end
code[x_, y_, z_] := N[(x + N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot z\right) \cdot \left(y + -1\right)
\end{array}
Initial program 97.3%
Taylor expanded in y around 0 97.3%
sub-neg97.3%
associate-+l+97.3%
sub-neg97.3%
*-un-lft-identity97.3%
distribute-rgt-out--97.3%
+-commutative97.3%
distribute-rgt-out97.3%
*-un-lft-identity97.3%
*-commutative97.3%
associate-*r*98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Applied egg-rr98.2%
Final simplification98.2%
(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 39.7%
(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 2024135
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(! :herbie-platform default (if (< (* x (- 1 (* (- 1 y) z))) -161819597360704900000000000000000000000000000000000) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 389223764966390300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x))))))
(* x (- 1.0 (* (- 1.0 y) z))))