
(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 12 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 (* z (+ y -1.0))))
(if (<= (+ 1.0 t_0) -5e+277)
(pow (/ 1.0 (* z (* x (+ y -1.0)))) -1.0)
(+ x (* x t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (y + -1.0);
double tmp;
if ((1.0 + t_0) <= -5e+277) {
tmp = pow((1.0 / (z * (x * (y + -1.0)))), -1.0);
} else {
tmp = x + (x * 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))
if ((1.0d0 + t_0) <= (-5d+277)) then
tmp = (1.0d0 / (z * (x * (y + (-1.0d0))))) ** (-1.0d0)
else
tmp = x + (x * 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);
double tmp;
if ((1.0 + t_0) <= -5e+277) {
tmp = Math.pow((1.0 / (z * (x * (y + -1.0)))), -1.0);
} else {
tmp = x + (x * t_0);
}
return tmp;
}
def code(x, y, z): t_0 = z * (y + -1.0) tmp = 0 if (1.0 + t_0) <= -5e+277: tmp = math.pow((1.0 / (z * (x * (y + -1.0)))), -1.0) else: tmp = x + (x * t_0) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y + -1.0)) tmp = 0.0 if (Float64(1.0 + t_0) <= -5e+277) tmp = Float64(1.0 / Float64(z * Float64(x * Float64(y + -1.0)))) ^ -1.0; else tmp = Float64(x + Float64(x * t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y + -1.0); tmp = 0.0; if ((1.0 + t_0) <= -5e+277) tmp = (1.0 / (z * (x * (y + -1.0)))) ^ -1.0; else tmp = x + (x * t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], -5e+277], N[Power[N[(1.0 / N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[(x + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y + -1\right)\\
\mathbf{if}\;1 + t\_0 \leq -5 \cdot 10^{+277}:\\
\;\;\;\;{\left(\frac{1}{z \cdot \left(x \cdot \left(y + -1\right)\right)}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -4.99999999999999982e277Initial program 74.0%
Taylor expanded in z around inf 74.0%
associate-*r*99.8%
flip--83.8%
associate-*r/83.9%
metadata-eval83.9%
fma-neg83.9%
metadata-eval83.9%
Applied egg-rr83.9%
clear-num83.9%
inv-pow83.9%
clear-num83.8%
associate-/l*83.8%
*-commutative83.8%
metadata-eval83.8%
fma-neg83.8%
metadata-eval83.8%
flip--99.8%
associate-*l*99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if -4.99999999999999982e277 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 98.7%
Taylor expanded in z around 0 98.7%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (+ y -1.0)))) (if (<= (+ 1.0 t_0) (- INFINITY)) (* z (* y x)) (+ x (* x t_0)))))
double code(double x, double y, double z) {
double t_0 = z * (y + -1.0);
double tmp;
if ((1.0 + t_0) <= -((double) INFINITY)) {
tmp = z * (y * x);
} else {
tmp = x + (x * t_0);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = z * (y + -1.0);
double tmp;
if ((1.0 + t_0) <= -Double.POSITIVE_INFINITY) {
tmp = z * (y * x);
} else {
tmp = x + (x * t_0);
}
return tmp;
}
def code(x, y, z): t_0 = z * (y + -1.0) tmp = 0 if (1.0 + t_0) <= -math.inf: tmp = z * (y * x) else: tmp = x + (x * t_0) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y + -1.0)) tmp = 0.0 if (Float64(1.0 + t_0) <= Float64(-Inf)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x + Float64(x * t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y + -1.0); tmp = 0.0; if ((1.0 + t_0) <= -Inf) tmp = z * (y * x); else tmp = x + (x * t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 + t$95$0), $MachinePrecision], (-Infinity)], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y + -1\right)\\
\mathbf{if}\;1 + t\_0 \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot t\_0\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -inf.0Initial program 64.3%
Taylor expanded in y around inf 64.3%
*-commutative64.3%
*-commutative64.3%
associate-*l*100.0%
Simplified100.0%
if -inf.0 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 98.7%
Taylor expanded in z around 0 98.7%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ 1.0 (* z (+ y -1.0))))) (if (<= t_0 (- INFINITY)) (* z (* y x)) (* t_0 x))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (y + -1.0));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = z * (y * x);
} else {
tmp = t_0 * x;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (y + -1.0));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = z * (y * x);
} else {
tmp = t_0 * x;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (y + -1.0)) tmp = 0 if t_0 <= -math.inf: tmp = z * (y * x) else: tmp = t_0 * x return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(y + -1.0))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(t_0 * x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (y + -1.0)); tmp = 0.0; if (t_0 <= -Inf) tmp = z * (y * x); else tmp = t_0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \left(y + -1\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot x\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < -inf.0Initial program 64.3%
Taylor expanded in y around inf 64.3%
*-commutative64.3%
*-commutative64.3%
associate-*l*100.0%
Simplified100.0%
if -inf.0 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 98.7%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.95) (not (<= z 6.8e-6))) (* (+ y -1.0) (* z x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 6.8e-6)) {
tmp = (y + -1.0) * (z * x);
} 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.95d0)) .or. (.not. (z <= 6.8d-6))) then
tmp = (y + (-1.0d0)) * (z * x)
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.95) || !(z <= 6.8e-6)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.95) or not (z <= 6.8e-6): tmp = (y + -1.0) * (z * x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.95) || !(z <= 6.8e-6)) tmp = Float64(Float64(y + -1.0) * Float64(z * x)); 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.95) || ~((z <= 6.8e-6))) tmp = (y + -1.0) * (z * x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.95], N[Not[LessEqual[z, 6.8e-6]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 6.8 \cdot 10^{-6}\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.94999999999999996 or 6.80000000000000012e-6 < z Initial program 92.2%
Taylor expanded in z around inf 90.2%
associate-*r*98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
Simplified98.0%
if -0.94999999999999996 < z < 6.80000000000000012e-6Initial program 99.9%
Taylor expanded in y around inf 98.9%
neg-mul-198.9%
Simplified98.9%
cancel-sign-sub98.9%
+-commutative98.9%
*-commutative98.9%
Applied egg-rr98.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -2e+25) (not (<= y 3.4e-7))) (* x (+ 1.0 (* y z))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+25) || !(y <= 3.4e-7)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x - (z * 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 ((y <= (-2d+25)) .or. (.not. (y <= 3.4d-7))) then
tmp = x * (1.0d0 + (y * z))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+25) || !(y <= 3.4e-7)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2e+25) or not (y <= 3.4e-7): tmp = x * (1.0 + (y * z)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2e+25) || !(y <= 3.4e-7)) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2e+25) || ~((y <= 3.4e-7))) tmp = x * (1.0 + (y * z)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2e+25], N[Not[LessEqual[y, 3.4e-7]], $MachinePrecision]], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+25} \lor \neg \left(y \leq 3.4 \cdot 10^{-7}\right):\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -2.00000000000000018e25 or 3.39999999999999974e-7 < y Initial program 91.6%
Taylor expanded in y around inf 90.3%
neg-mul-190.3%
Simplified90.3%
cancel-sign-sub90.3%
+-commutative90.3%
*-commutative90.3%
Applied egg-rr90.3%
if -2.00000000000000018e25 < y < 3.39999999999999974e-7Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 99.2%
mul-1-neg99.2%
*-commutative99.2%
distribute-rgt-neg-in99.2%
Simplified99.2%
distribute-rgt-neg-out99.2%
*-commutative99.2%
unsub-neg99.2%
Applied egg-rr99.2%
Final simplification94.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.1e+73) (not (<= y 1.16e+29))) (* y (* z x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.1e+73) || !(y <= 1.16e+29)) {
tmp = y * (z * x);
} 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 <= (-4.1d+73)) .or. (.not. (y <= 1.16d+29))) then
tmp = y * (z * x)
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 <= -4.1e+73) || !(y <= 1.16e+29)) {
tmp = y * (z * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.1e+73) or not (y <= 1.16e+29): tmp = y * (z * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.1e+73) || !(y <= 1.16e+29)) tmp = Float64(y * Float64(z * x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4.1e+73) || ~((y <= 1.16e+29))) tmp = y * (z * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.1e+73], N[Not[LessEqual[y, 1.16e+29]], $MachinePrecision]], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+73} \lor \neg \left(y \leq 1.16 \cdot 10^{+29}\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -4.0999999999999998e73 or 1.16e29 < y Initial program 90.6%
Taylor expanded in z around inf 65.9%
associate-*r*70.9%
flip--51.9%
associate-*r/49.5%
metadata-eval49.5%
fma-neg49.5%
metadata-eval49.5%
Applied egg-rr49.5%
associate-/l*51.9%
metadata-eval51.9%
fma-neg51.9%
metadata-eval51.9%
flip--70.9%
*-commutative70.9%
sub-neg70.9%
metadata-eval70.9%
*-commutative70.9%
Applied egg-rr70.9%
Taylor expanded in y around inf 70.9%
if -4.0999999999999998e73 < y < 1.16e29Initial program 99.9%
Taylor expanded in y around 0 95.9%
Final simplification85.1%
(FPCore (x y z) :precision binary64 (if (<= y -1.28e+79) (* z (* y x)) (if (<= y 4.5e+28) (- x (* z x)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.28e+79) {
tmp = z * (y * x);
} else if (y <= 4.5e+28) {
tmp = x - (z * x);
} else {
tmp = y * (z * 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 (y <= (-1.28d+79)) then
tmp = z * (y * x)
else if (y <= 4.5d+28) then
tmp = x - (z * x)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.28e+79) {
tmp = z * (y * x);
} else if (y <= 4.5e+28) {
tmp = x - (z * x);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.28e+79: tmp = z * (y * x) elif y <= 4.5e+28: tmp = x - (z * x) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.28e+79) tmp = Float64(z * Float64(y * x)); elseif (y <= 4.5e+28) tmp = Float64(x - Float64(z * x)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.28e+79) tmp = z * (y * x); elseif (y <= 4.5e+28) tmp = x - (z * x); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.28e+79], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e+28], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.28 \cdot 10^{+79}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+28}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -1.27999999999999998e79Initial program 88.7%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
*-commutative72.8%
associate-*l*79.7%
Simplified79.7%
if -1.27999999999999998e79 < y < 4.4999999999999997e28Initial program 99.9%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 96.0%
mul-1-neg96.0%
*-commutative96.0%
distribute-rgt-neg-in96.0%
Simplified96.0%
distribute-rgt-neg-out96.0%
*-commutative96.0%
unsub-neg96.0%
Applied egg-rr96.0%
if 4.4999999999999997e28 < y Initial program 91.7%
Taylor expanded in z around inf 61.7%
associate-*r*67.0%
flip--52.3%
associate-*r/49.7%
metadata-eval49.7%
fma-neg49.7%
metadata-eval49.7%
Applied egg-rr49.7%
associate-/l*52.3%
metadata-eval52.3%
fma-neg52.3%
metadata-eval52.3%
flip--67.0%
*-commutative67.0%
sub-neg67.0%
metadata-eval67.0%
*-commutative67.0%
Applied egg-rr67.0%
Taylor expanded in y around inf 67.0%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.8e+73) (* z (* y x)) (if (<= y 1.3e+28) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.8e+73) {
tmp = z * (y * x);
} else if (y <= 1.3e+28) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * 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 (y <= (-3.8d+73)) then
tmp = z * (y * x)
else if (y <= 1.3d+28) then
tmp = x * (1.0d0 - z)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.8e+73) {
tmp = z * (y * x);
} else if (y <= 1.3e+28) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.8e+73: tmp = z * (y * x) elif y <= 1.3e+28: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.8e+73) tmp = Float64(z * Float64(y * x)); elseif (y <= 1.3e+28) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.8e+73) tmp = z * (y * x); elseif (y <= 1.3e+28) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.8e+73], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+28], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+73}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+28}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -3.80000000000000022e73Initial program 88.7%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
*-commutative72.8%
associate-*l*79.7%
Simplified79.7%
if -3.80000000000000022e73 < y < 1.3000000000000001e28Initial program 99.9%
Taylor expanded in y around 0 95.9%
if 1.3000000000000001e28 < y Initial program 91.7%
Taylor expanded in z around inf 61.7%
associate-*r*67.0%
flip--52.3%
associate-*r/49.7%
metadata-eval49.7%
fma-neg49.7%
metadata-eval49.7%
Applied egg-rr49.7%
associate-/l*52.3%
metadata-eval52.3%
fma-neg52.3%
metadata-eval52.3%
flip--67.0%
*-commutative67.0%
sub-neg67.0%
metadata-eval67.0%
*-commutative67.0%
Applied egg-rr67.0%
Taylor expanded in y around inf 67.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) 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 <= -1.0) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(-x)); 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 = z * -x; 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[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 92.0%
Taylor expanded in z around inf 90.0%
Taylor expanded in y around 0 60.7%
mul-1-neg62.3%
*-commutative62.3%
distribute-rgt-neg-in62.3%
Simplified60.7%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 74.9%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (<= y 2.3e+212) (* x (- 1.0 z)) (* z x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.3e+212) {
tmp = x * (1.0 - z);
} else {
tmp = z * 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 (y <= 2.3d+212) then
tmp = x * (1.0d0 - z)
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.3e+212) {
tmp = x * (1.0 - z);
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.3e+212: tmp = x * (1.0 - z) else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.3e+212) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.3e+212) tmp = x * (1.0 - z); else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.3e+212], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{+212}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if y < 2.2999999999999998e212Initial program 96.0%
Taylor expanded in y around 0 73.7%
if 2.2999999999999998e212 < y Initial program 94.9%
Taylor expanded in z around inf 85.3%
Taylor expanded in y around 0 1.9%
mul-1-neg10.9%
*-commutative10.9%
distribute-rgt-neg-in10.9%
Simplified1.9%
add-sqr-sqrt1.5%
sqrt-unprod29.3%
sqr-neg29.3%
sqrt-unprod27.5%
add-sqr-sqrt35.0%
pow135.0%
Applied egg-rr35.0%
unpow135.0%
*-commutative35.0%
Simplified35.0%
Final simplification70.8%
(FPCore (x y z) :precision binary64 (if (<= z -4.3e+91) (* z x) x))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.3e+91) {
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+91)) 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+91) {
tmp = z * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.3e+91: tmp = z * x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.3e+91) tmp = Float64(z * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.3e+91) tmp = z * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.3e+91], N[(z * x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{+91}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.3000000000000001e91Initial program 86.8%
Taylor expanded in z around inf 86.8%
Taylor expanded in y around 0 56.9%
mul-1-neg56.9%
*-commutative56.9%
distribute-rgt-neg-in56.9%
Simplified56.9%
add-sqr-sqrt32.4%
sqrt-unprod33.2%
sqr-neg33.2%
sqrt-unprod6.5%
add-sqr-sqrt13.4%
pow113.4%
Applied egg-rr13.4%
unpow113.4%
*-commutative13.4%
Simplified13.4%
if -4.3000000000000001e91 < z Initial program 98.1%
Taylor expanded in z around 0 47.0%
Final simplification40.4%
(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 95.9%
Taylor expanded in z around 0 38.5%
(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 2024145
(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))))