
(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 (- 1.0 y))))
(if (or (<= t_0 -4e+71) (not (<= t_0 2e+243)))
(* z (* x (+ y -1.0)))
(+ x (* x (* z (+ y -1.0)))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if ((t_0 <= -4e+71) || !(t_0 <= 2e+243)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (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) :: t_0
real(8) :: tmp
t_0 = z * (1.0d0 - y)
if ((t_0 <= (-4d+71)) .or. (.not. (t_0 <= 2d+243))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x + (x * (z * (y + (-1.0d0))))
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 <= -4e+71) || !(t_0 <= 2e+243)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if (t_0 <= -4e+71) or not (t_0 <= 2e+243): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (z * (y + -1.0))) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if ((t_0 <= -4e+71) || !(t_0 <= 2e+243)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if ((t_0 <= -4e+71) || ~((t_0 <= 2e+243))) tmp = z * (x * (y + -1.0)); else tmp = x + (x * (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+71], N[Not[LessEqual[t$95$0, 2e+243]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+71} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+243}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.0000000000000002e71 or 2.0000000000000001e243 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 89.3%
Taylor expanded in z around inf 89.3%
*-commutative89.3%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -4.0000000000000002e71 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 2.0000000000000001e243Initial program 99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* z y))))
(if (<= z -3.55e+168)
t_0
(if (<= z -1.8e-110)
t_1
(if (<= z 2.5e-34)
x
(if (or (<= z 1.24e+61) (not (<= z 5.1e+135))) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (z * y);
double tmp;
if (z <= -3.55e+168) {
tmp = t_0;
} else if (z <= -1.8e-110) {
tmp = t_1;
} else if (z <= 2.5e-34) {
tmp = x;
} else if ((z <= 1.24e+61) || !(z <= 5.1e+135)) {
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 * (z * y)
if (z <= (-3.55d+168)) then
tmp = t_0
else if (z <= (-1.8d-110)) then
tmp = t_1
else if (z <= 2.5d-34) then
tmp = x
else if ((z <= 1.24d+61) .or. (.not. (z <= 5.1d+135))) 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 * (z * y);
double tmp;
if (z <= -3.55e+168) {
tmp = t_0;
} else if (z <= -1.8e-110) {
tmp = t_1;
} else if (z <= 2.5e-34) {
tmp = x;
} else if ((z <= 1.24e+61) || !(z <= 5.1e+135)) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (z * y) tmp = 0 if z <= -3.55e+168: tmp = t_0 elif z <= -1.8e-110: tmp = t_1 elif z <= 2.5e-34: tmp = x elif (z <= 1.24e+61) or not (z <= 5.1e+135): 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(z * y)) tmp = 0.0 if (z <= -3.55e+168) tmp = t_0; elseif (z <= -1.8e-110) tmp = t_1; elseif (z <= 2.5e-34) tmp = x; elseif ((z <= 1.24e+61) || !(z <= 5.1e+135)) 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 * (z * y); tmp = 0.0; if (z <= -3.55e+168) tmp = t_0; elseif (z <= -1.8e-110) tmp = t_1; elseif (z <= 2.5e-34) tmp = x; elseif ((z <= 1.24e+61) || ~((z <= 5.1e+135))) 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[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.55e+168], t$95$0, If[LessEqual[z, -1.8e-110], t$95$1, If[LessEqual[z, 2.5e-34], x, If[Or[LessEqual[z, 1.24e+61], N[Not[LessEqual[z, 5.1e+135]], $MachinePrecision]], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -3.55 \cdot 10^{+168}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-110}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-34}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.24 \cdot 10^{+61} \lor \neg \left(z \leq 5.1 \cdot 10^{+135}\right):\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.55000000000000006e168 or 1.24e61 < z < 5.09999999999999982e135Initial program 94.2%
Taylor expanded in z around inf 94.2%
*-commutative94.2%
associate-*r*100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 75.9%
neg-mul-175.9%
Simplified75.9%
if -3.55000000000000006e168 < z < -1.79999999999999997e-110 or 2.5000000000000001e-34 < z < 1.24e61 or 5.09999999999999982e135 < z Initial program 93.0%
Taylor expanded in y around inf 59.2%
*-commutative59.2%
Simplified59.2%
if -1.79999999999999997e-110 < z < 2.5000000000000001e-34Initial program 100.0%
Taylor expanded in z around 0 85.8%
Final simplification72.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* x (+ y -1.0)))))
(if (<= z -220000000000.0)
t_0
(if (<= z -1e-52)
(- x (* x z))
(if (<= z -9e-111) (* x (* z y)) (if (<= z 3.25e-34) x t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (x * (y + -1.0));
double tmp;
if (z <= -220000000000.0) {
tmp = t_0;
} else if (z <= -1e-52) {
tmp = x - (x * z);
} else if (z <= -9e-111) {
tmp = x * (z * y);
} else if (z <= 3.25e-34) {
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 * (x * (y + (-1.0d0)))
if (z <= (-220000000000.0d0)) then
tmp = t_0
else if (z <= (-1d-52)) then
tmp = x - (x * z)
else if (z <= (-9d-111)) then
tmp = x * (z * y)
else if (z <= 3.25d-34) 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 * (x * (y + -1.0));
double tmp;
if (z <= -220000000000.0) {
tmp = t_0;
} else if (z <= -1e-52) {
tmp = x - (x * z);
} else if (z <= -9e-111) {
tmp = x * (z * y);
} else if (z <= 3.25e-34) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (x * (y + -1.0)) tmp = 0 if z <= -220000000000.0: tmp = t_0 elif z <= -1e-52: tmp = x - (x * z) elif z <= -9e-111: tmp = x * (z * y) elif z <= 3.25e-34: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(x * Float64(y + -1.0))) tmp = 0.0 if (z <= -220000000000.0) tmp = t_0; elseif (z <= -1e-52) tmp = Float64(x - Float64(x * z)); elseif (z <= -9e-111) tmp = Float64(x * Float64(z * y)); elseif (z <= 3.25e-34) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (x * (y + -1.0)); tmp = 0.0; if (z <= -220000000000.0) tmp = t_0; elseif (z <= -1e-52) tmp = x - (x * z); elseif (z <= -9e-111) tmp = x * (z * y); elseif (z <= 3.25e-34) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -220000000000.0], t$95$0, If[LessEqual[z, -1e-52], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -9e-111], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.25e-34], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;z \leq -220000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-52}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{elif}\;z \leq -9 \cdot 10^{-111}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq 3.25 \cdot 10^{-34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.2e11 or 3.24999999999999993e-34 < z Initial program 92.4%
Taylor expanded in z around inf 91.8%
*-commutative91.8%
associate-*r*99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
if -2.2e11 < z < -1e-52Initial program 99.7%
Taylor expanded in z around 0 99.8%
+-commutative99.8%
add-cube-cbrt99.2%
fma-define99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 76.0%
mul-1-neg76.0%
sub-neg76.0%
Simplified76.0%
if -1e-52 < z < -8.99999999999999987e-111Initial program 99.7%
Taylor expanded in y around inf 73.7%
*-commutative73.7%
Simplified73.7%
if -8.99999999999999987e-111 < z < 3.24999999999999993e-34Initial program 100.0%
Taylor expanded in z around 0 85.8%
Final simplification92.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- 1.0 y))))
(if (or (<= t_0 -4e+71) (not (<= t_0 2e+243)))
(* z (* x (+ y -1.0)))
(* x (+ 1.0 (* z (+ y -1.0)))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if ((t_0 <= -4e+71) || !(t_0 <= 2e+243)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (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) :: t_0
real(8) :: tmp
t_0 = z * (1.0d0 - y)
if ((t_0 <= (-4d+71)) .or. (.not. (t_0 <= 2d+243))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
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 <= -4e+71) || !(t_0 <= 2e+243)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if (t_0 <= -4e+71) or not (t_0 <= 2e+243): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if ((t_0 <= -4e+71) || !(t_0 <= 2e+243)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if ((t_0 <= -4e+71) || ~((t_0 <= 2e+243))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -4e+71], N[Not[LessEqual[t$95$0, 2e+243]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{+71} \lor \neg \left(t\_0 \leq 2 \cdot 10^{+243}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.0000000000000002e71 or 2.0000000000000001e243 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 89.3%
Taylor expanded in z around inf 89.3%
*-commutative89.3%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -4.0000000000000002e71 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 2.0000000000000001e243Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.95) (not (<= z 2.45e-31))) (* z (* x (+ y -1.0))) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 2.45e-31)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * y));
}
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 <= 2.45d-31))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x + (x * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 2.45e-31)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.95) or not (z <= 2.45e-31): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.95) || !(z <= 2.45e-31)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x + Float64(x * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.95) || ~((z <= 2.45e-31))) tmp = z * (x * (y + -1.0)); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.95], N[Not[LessEqual[z, 2.45e-31]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 2.45 \cdot 10^{-31}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -0.94999999999999996 or 2.45000000000000012e-31 < z Initial program 92.5%
Taylor expanded in z around inf 91.5%
*-commutative91.5%
associate-*r*98.8%
*-commutative98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
if -0.94999999999999996 < z < 2.45000000000000012e-31Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 99.4%
*-commutative99.4%
Simplified99.4%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= x 1.02e-94) (+ x (/ z (/ 1.0 (* x (+ y -1.0))))) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.02e-94) {
tmp = x + (z / (1.0 / (x * (y + -1.0))));
} else {
tmp = x * (1.0 + (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 (x <= 1.02d-94) then
tmp = x + (z / (1.0d0 / (x * (y + (-1.0d0)))))
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.02e-94) {
tmp = x + (z / (1.0 / (x * (y + -1.0))));
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.02e-94: tmp = x + (z / (1.0 / (x * (y + -1.0)))) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.02e-94) tmp = Float64(x + Float64(z / Float64(1.0 / Float64(x * Float64(y + -1.0))))); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.02e-94) tmp = x + (z / (1.0 / (x * (y + -1.0)))); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.02e-94], N[(x + N[(z / N[(1.0 / N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.02 \cdot 10^{-94}:\\
\;\;\;\;x + \frac{z}{\frac{1}{x \cdot \left(y + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if x < 1.02e-94Initial program 94.1%
Taylor expanded in z around 0 94.2%
+-commutative94.2%
add-cube-cbrt93.4%
fma-define93.4%
Applied egg-rr96.7%
fma-undefine96.7%
unpow296.7%
add-cube-cbrt97.5%
Applied egg-rr97.5%
associate-*r*96.3%
metadata-eval96.3%
sub-neg96.3%
flip--82.4%
metadata-eval82.4%
fma-neg82.4%
metadata-eval82.4%
associate-*l/81.4%
clear-num81.4%
associate-*l/81.3%
*-un-lft-identity81.3%
clear-num81.3%
associate-*l/82.4%
metadata-eval82.4%
fma-neg82.4%
metadata-eval82.4%
flip--96.2%
sub-neg96.2%
metadata-eval96.2%
Applied egg-rr96.2%
if 1.02e-94 < x Initial program 99.9%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e+58) (not (<= y 360000000000.0))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e+58) || !(y <= 360000000000.0)) {
tmp = x * (z * y);
} 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 <= (-3.1d+58)) .or. (.not. (y <= 360000000000.0d0))) then
tmp = x * (z * y)
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 <= -3.1e+58) || !(y <= 360000000000.0)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e+58) or not (y <= 360000000000.0): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e+58) || !(y <= 360000000000.0)) tmp = Float64(x * Float64(z * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.1e+58) || ~((y <= 360000000000.0))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e+58], N[Not[LessEqual[y, 360000000000.0]], $MachinePrecision]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+58} \lor \neg \left(y \leq 360000000000\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.0999999999999999e58 or 3.6e11 < y Initial program 91.1%
Taylor expanded in y around inf 70.4%
*-commutative70.4%
Simplified70.4%
if -3.0999999999999999e58 < y < 3.6e11Initial program 100.0%
Taylor expanded in y around 0 96.2%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e+58) (not (<= y 280000000000.0))) (* z (* x y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e+58) || !(y <= 280000000000.0)) {
tmp = z * (x * y);
} 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 <= (-3.1d+58)) .or. (.not. (y <= 280000000000.0d0))) then
tmp = z * (x * y)
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 <= -3.1e+58) || !(y <= 280000000000.0)) {
tmp = z * (x * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e+58) or not (y <= 280000000000.0): tmp = z * (x * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e+58) || !(y <= 280000000000.0)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.1e+58) || ~((y <= 280000000000.0))) tmp = z * (x * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e+58], N[Not[LessEqual[y, 280000000000.0]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+58} \lor \neg \left(y \leq 280000000000\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.0999999999999999e58 or 2.8e11 < y Initial program 91.1%
Taylor expanded in z around inf 70.4%
*-commutative70.4%
associate-*r*76.1%
*-commutative76.1%
sub-neg76.1%
metadata-eval76.1%
Simplified76.1%
Taylor expanded in y around inf 76.1%
if -3.0999999999999999e58 < y < 2.8e11Initial program 100.0%
Taylor expanded in y around 0 96.2%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+58) (* y (* x z)) (if (<= y 210000000000.0) (* x (- 1.0 z)) (* z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+58) {
tmp = y * (x * z);
} else if (y <= 210000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * y);
}
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.4d+58)) then
tmp = y * (x * z)
else if (y <= 210000000000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = z * (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+58) {
tmp = y * (x * z);
} else if (y <= 210000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+58: tmp = y * (x * z) elif y <= 210000000000.0: tmp = x * (1.0 - z) else: tmp = z * (x * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+58) tmp = Float64(y * Float64(x * z)); elseif (y <= 210000000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+58) tmp = y * (x * z); elseif (y <= 210000000000.0) tmp = x * (1.0 - z); else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+58], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 210000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+58}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq 210000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -3.4000000000000001e58Initial program 89.4%
Taylor expanded in y around inf 71.7%
*-commutative71.7%
Simplified71.7%
add-sqr-sqrt39.3%
pow239.3%
associate-*r*43.0%
*-commutative43.0%
Applied egg-rr43.0%
unpow243.0%
add-sqr-sqrt80.3%
*-commutative80.3%
Applied egg-rr80.3%
if -3.4000000000000001e58 < y < 2.1e11Initial program 100.0%
Taylor expanded in y around 0 96.2%
if 2.1e11 < y Initial program 92.4%
Taylor expanded in z around inf 69.3%
*-commutative69.3%
associate-*r*75.3%
*-commutative75.3%
sub-neg75.3%
metadata-eval75.3%
Simplified75.3%
Taylor expanded in y around inf 75.3%
Final simplification87.7%
(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 92.3%
Taylor expanded in z around inf 91.2%
*-commutative91.2%
associate-*r*98.8%
*-commutative98.8%
sub-neg98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in y around 0 51.8%
neg-mul-151.8%
Simplified51.8%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 76.4%
Final simplification63.3%
(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 95.9%
Taylor expanded in z around 0 95.9%
+-commutative95.9%
add-cube-cbrt95.2%
fma-define95.2%
Applied egg-rr97.5%
fma-undefine97.5%
unpow297.5%
add-cube-cbrt98.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 95.9%
Taylor expanded in z around 0 37.5%
Final simplification37.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 2024077
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(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))))