
(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 (* z (- 1.0 y))))
(if (<= t_0 (- INFINITY))
(* z (* x y))
(if (<= t_0 5e+87) (+ x (* x (* (+ y -1.0) z))) (* z (- (* x y) x))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = z * (x * y);
} else if (t_0 <= 5e+87) {
tmp = x + (x * ((y + -1.0) * z));
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = z * (x * y);
} else if (t_0 <= 5e+87) {
tmp = x + (x * ((y + -1.0) * z));
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if t_0 <= -math.inf: tmp = z * (x * y) elif t_0 <= 5e+87: tmp = x + (x * ((y + -1.0) * z)) else: tmp = z * ((x * y) - x) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(z * Float64(x * y)); elseif (t_0 <= 5e+87) tmp = Float64(x + Float64(x * Float64(Float64(y + -1.0) * z))); else tmp = Float64(z * Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if (t_0 <= -Inf) tmp = z * (x * y); elseif (t_0 <= 5e+87) tmp = x + (x * ((y + -1.0) * z)); else tmp = z * ((x * y) - 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, (-Infinity)], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+87], N[(x + N[(x * N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+87}:\\
\;\;\;\;x + x \cdot \left(\left(y + -1\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -inf.0Initial program 44.8%
Taylor expanded in y around inf 44.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
if -inf.0 < (*.f64 (-.f64 1 y) z) < 4.9999999999999998e87Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
*-commutative99.9%
+-commutative99.9%
distribute-lft-neg-in99.9%
*-commutative99.9%
sub-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
*-un-lft-identity99.9%
distribute-lft-neg-in99.9%
distribute-lft-neg-in99.9%
metadata-eval99.9%
metadata-eval99.9%
*-un-lft-identity99.9%
metadata-eval99.9%
Applied egg-rr99.9%
if 4.9999999999999998e87 < (*.f64 (-.f64 1 y) z) Initial program 88.5%
sub-neg88.5%
distribute-rgt-in88.5%
*-un-lft-identity88.5%
*-commutative88.5%
+-commutative88.5%
distribute-lft-neg-in88.5%
*-commutative88.5%
sub-neg88.5%
distribute-neg-in88.5%
+-commutative88.5%
*-un-lft-identity88.5%
distribute-lft-neg-in88.5%
distribute-lft-neg-in88.5%
metadata-eval88.5%
metadata-eval88.5%
*-un-lft-identity88.5%
metadata-eval88.5%
Applied egg-rr88.5%
associate-*r*99.7%
flip-+84.1%
associate-*r/81.4%
metadata-eval81.4%
fma-neg81.4%
metadata-eval81.4%
sub-neg81.4%
metadata-eval81.4%
Applied egg-rr81.4%
Taylor expanded in y around inf 81.0%
Taylor expanded in z around inf 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 2.1e-27) (+ x (pow (cbrt (* (* x (+ y -1.0)) z)) 3.0)) (* x (+ 1.0 (* (+ y -1.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2.1e-27) {
tmp = x + pow(cbrt(((x * (y + -1.0)) * z)), 3.0);
} else {
tmp = x * (1.0 + ((y + -1.0) * z));
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2.1e-27) {
tmp = x + Math.pow(Math.cbrt(((x * (y + -1.0)) * z)), 3.0);
} else {
tmp = x * (1.0 + ((y + -1.0) * z));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 2.1e-27) tmp = Float64(x + (cbrt(Float64(Float64(x * Float64(y + -1.0)) * z)) ^ 3.0)); else tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 2.1e-27], N[(x + N[Power[N[Power[N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.1 \cdot 10^{-27}:\\
\;\;\;\;x + {\left(\sqrt[3]{\left(x \cdot \left(y + -1\right)\right) \cdot z}\right)}^{3}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\end{array}
\end{array}
if x < 2.10000000000000015e-27Initial program 91.2%
sub-neg91.2%
distribute-rgt-in91.2%
*-un-lft-identity91.2%
*-commutative91.2%
+-commutative91.2%
distribute-lft-neg-in91.2%
*-commutative91.2%
sub-neg91.2%
distribute-neg-in91.2%
+-commutative91.2%
*-un-lft-identity91.2%
distribute-lft-neg-in91.2%
distribute-lft-neg-in91.2%
metadata-eval91.2%
metadata-eval91.2%
*-un-lft-identity91.2%
metadata-eval91.2%
Applied egg-rr91.2%
add-cube-cbrt90.4%
pow390.4%
*-commutative90.4%
associate-*r*96.5%
Applied egg-rr96.5%
if 2.10000000000000015e-27 < x Initial program 99.9%
Final simplification97.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- 1.0 y))))
(if (<= t_0 (- INFINITY))
(* z (* x y))
(if (<= t_0 5e+87) (* x (+ 1.0 (* (+ y -1.0) z))) (* z (- (* x y) x))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = z * (x * y);
} else if (t_0 <= 5e+87) {
tmp = x * (1.0 + ((y + -1.0) * z));
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = z * (x * y);
} else if (t_0 <= 5e+87) {
tmp = x * (1.0 + ((y + -1.0) * z));
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if t_0 <= -math.inf: tmp = z * (x * y) elif t_0 <= 5e+87: tmp = x * (1.0 + ((y + -1.0) * z)) else: tmp = z * ((x * y) - x) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(z * Float64(x * y)); elseif (t_0 <= 5e+87) tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); else tmp = Float64(z * Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if (t_0 <= -Inf) tmp = z * (x * y); elseif (t_0 <= 5e+87) tmp = x * (1.0 + ((y + -1.0) * z)); else tmp = z * ((x * y) - 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, (-Infinity)], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+87], N[(x * N[(1.0 + N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+87}:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -inf.0Initial program 44.8%
Taylor expanded in y around inf 44.8%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
if -inf.0 < (*.f64 (-.f64 1 y) z) < 4.9999999999999998e87Initial program 99.9%
if 4.9999999999999998e87 < (*.f64 (-.f64 1 y) z) Initial program 88.5%
sub-neg88.5%
distribute-rgt-in88.5%
*-un-lft-identity88.5%
*-commutative88.5%
+-commutative88.5%
distribute-lft-neg-in88.5%
*-commutative88.5%
sub-neg88.5%
distribute-neg-in88.5%
+-commutative88.5%
*-un-lft-identity88.5%
distribute-lft-neg-in88.5%
distribute-lft-neg-in88.5%
metadata-eval88.5%
metadata-eval88.5%
*-un-lft-identity88.5%
metadata-eval88.5%
Applied egg-rr88.5%
associate-*r*99.7%
flip-+84.1%
associate-*r/81.4%
metadata-eval81.4%
fma-neg81.4%
metadata-eval81.4%
sub-neg81.4%
metadata-eval81.4%
Applied egg-rr81.4%
Taylor expanded in y around inf 81.0%
Taylor expanded in z around inf 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -8800.0)
t_0
(if (<= z -2.8e-88)
t_1
(if (<= z 6.6e-64) x (if (<= z 4.1e+49) 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 <= -8800.0) {
tmp = t_0;
} else if (z <= -2.8e-88) {
tmp = t_1;
} else if (z <= 6.6e-64) {
tmp = x;
} else if (z <= 4.1e+49) {
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 <= (-8800.0d0)) then
tmp = t_0
else if (z <= (-2.8d-88)) then
tmp = t_1
else if (z <= 6.6d-64) then
tmp = x
else if (z <= 4.1d+49) 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 <= -8800.0) {
tmp = t_0;
} else if (z <= -2.8e-88) {
tmp = t_1;
} else if (z <= 6.6e-64) {
tmp = x;
} else if (z <= 4.1e+49) {
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 <= -8800.0: tmp = t_0 elif z <= -2.8e-88: tmp = t_1 elif z <= 6.6e-64: tmp = x elif z <= 4.1e+49: 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 <= -8800.0) tmp = t_0; elseif (z <= -2.8e-88) tmp = t_1; elseif (z <= 6.6e-64) tmp = x; elseif (z <= 4.1e+49) 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 <= -8800.0) tmp = t_0; elseif (z <= -2.8e-88) tmp = t_1; elseif (z <= 6.6e-64) tmp = x; elseif (z <= 4.1e+49) 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, -8800.0], t$95$0, If[LessEqual[z, -2.8e-88], t$95$1, If[LessEqual[z, 6.6e-64], x, If[LessEqual[z, 4.1e+49], 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 -8800:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-88}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-64}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -8800 or 4.1e49 < z Initial program 86.2%
Taylor expanded in z around inf 85.7%
Taylor expanded in y around 0 60.5%
mul-1-neg60.5%
Simplified60.5%
if -8800 < z < -2.79999999999999976e-88 or 6.5999999999999999e-64 < z < 4.1e49Initial program 97.8%
Taylor expanded in y around inf 62.2%
*-commutative62.2%
Simplified62.2%
if -2.79999999999999976e-88 < z < 6.5999999999999999e-64Initial program 99.9%
Taylor expanded in z around 0 82.0%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -30000000000.0) (not (<= y 3.6e-18))) (+ x (* z (* x y))) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -30000000000.0) || !(y <= 3.6e-18)) {
tmp = x + (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 <= (-30000000000.0d0)) .or. (.not. (y <= 3.6d-18))) then
tmp = x + (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 <= -30000000000.0) || !(y <= 3.6e-18)) {
tmp = x + (z * (x * y));
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -30000000000.0) or not (y <= 3.6e-18): tmp = x + (z * (x * y)) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -30000000000.0) || !(y <= 3.6e-18)) tmp = Float64(x + 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 <= -30000000000.0) || ~((y <= 3.6e-18))) tmp = x + (z * (x * y)); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -30000000000.0], N[Not[LessEqual[y, 3.6e-18]], $MachinePrecision]], N[(x + N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -30000000000 \lor \neg \left(y \leq 3.6 \cdot 10^{-18}\right):\\
\;\;\;\;x + z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3e10 or 3.6000000000000001e-18 < y Initial program 85.9%
sub-neg85.9%
distribute-rgt-in85.9%
*-un-lft-identity85.9%
*-commutative85.9%
+-commutative85.9%
distribute-lft-neg-in85.9%
*-commutative85.9%
sub-neg85.9%
distribute-neg-in85.9%
+-commutative85.9%
*-un-lft-identity85.9%
distribute-lft-neg-in85.9%
distribute-lft-neg-in85.9%
metadata-eval85.9%
metadata-eval85.9%
*-un-lft-identity85.9%
metadata-eval85.9%
Applied egg-rr85.9%
Taylor expanded in y around inf 85.9%
associate-*r*92.8%
*-commutative92.8%
Simplified92.8%
if -3e10 < y < 3.6000000000000001e-18Initial program 100.0%
Taylor expanded in y around 0 99.8%
Final simplification96.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.1) (not (<= z 0.019))) (* z (- (* x y) x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.1) || !(z <= 0.019)) {
tmp = z * ((x * y) - 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 <= (-1.1d0)) .or. (.not. (z <= 0.019d0))) then
tmp = z * ((x * y) - 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 <= -1.1) || !(z <= 0.019)) {
tmp = z * ((x * y) - x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.1) or not (z <= 0.019): tmp = z * ((x * y) - x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.1) || !(z <= 0.019)) tmp = Float64(z * Float64(Float64(x * y) - 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 <= -1.1) || ~((z <= 0.019))) tmp = z * ((x * y) - x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1], N[Not[LessEqual[z, 0.019]], $MachinePrecision]], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \lor \neg \left(z \leq 0.019\right):\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.1000000000000001 or 0.0189999999999999995 < z Initial program 86.7%
sub-neg86.7%
distribute-rgt-in86.6%
*-un-lft-identity86.6%
*-commutative86.6%
+-commutative86.6%
distribute-lft-neg-in86.6%
*-commutative86.6%
sub-neg86.6%
distribute-neg-in86.6%
+-commutative86.6%
*-un-lft-identity86.6%
distribute-lft-neg-in86.6%
distribute-lft-neg-in86.6%
metadata-eval86.6%
metadata-eval86.6%
*-un-lft-identity86.6%
metadata-eval86.6%
Applied egg-rr86.6%
associate-*r*99.8%
flip-+91.0%
associate-*r/87.4%
metadata-eval87.4%
fma-neg87.4%
metadata-eval87.4%
sub-neg87.4%
metadata-eval87.4%
Applied egg-rr87.4%
Taylor expanded in y around inf 78.8%
Taylor expanded in z around inf 98.2%
if -1.1000000000000001 < z < 0.0189999999999999995Initial program 99.9%
Taylor expanded in y around inf 98.7%
mul-1-neg98.7%
*-commutative98.7%
distribute-rgt-neg-in98.7%
Simplified98.7%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.7e+39) (not (<= y 1.24e+14))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.7e+39) || !(y <= 1.24e+14)) {
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 <= (-8.7d+39)) .or. (.not. (y <= 1.24d+14))) 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 <= -8.7e+39) || !(y <= 1.24e+14)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.7e+39) or not (y <= 1.24e+14): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.7e+39) || !(y <= 1.24e+14)) 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 <= -8.7e+39) || ~((y <= 1.24e+14))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.7e+39], N[Not[LessEqual[y, 1.24e+14]], $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 -8.7 \cdot 10^{+39} \lor \neg \left(y \leq 1.24 \cdot 10^{+14}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -8.70000000000000028e39 or 1.24e14 < y Initial program 86.0%
Taylor expanded in y around inf 67.3%
*-commutative67.3%
Simplified67.3%
if -8.70000000000000028e39 < y < 1.24e14Initial program 99.3%
Taylor expanded in y around 0 99.1%
Final simplification84.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.4e+24) (not (<= y 2.15e+15))) (* z (* x y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.4e+24) || !(y <= 2.15e+15)) {
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 <= (-7.4d+24)) .or. (.not. (y <= 2.15d+15))) 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 <= -7.4e+24) || !(y <= 2.15e+15)) {
tmp = z * (x * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.4e+24) or not (y <= 2.15e+15): tmp = z * (x * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.4e+24) || !(y <= 2.15e+15)) 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 <= -7.4e+24) || ~((y <= 2.15e+15))) tmp = z * (x * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.4e+24], N[Not[LessEqual[y, 2.15e+15]], $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 -7.4 \cdot 10^{+24} \lor \neg \left(y \leq 2.15 \cdot 10^{+15}\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -7.39999999999999998e24 or 2.15e15 < y Initial program 85.4%
Taylor expanded in y around inf 67.1%
associate-*r*76.7%
*-commutative76.7%
Simplified76.7%
if -7.39999999999999998e24 < y < 2.15e15Initial program 100.0%
Taylor expanded in y around 0 99.8%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -7e+15) (not (<= y 1.2e+17))) (* y (* x z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7e+15) || !(y <= 1.2e+17)) {
tmp = y * (x * 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 <= (-7d+15)) .or. (.not. (y <= 1.2d+17))) then
tmp = y * (x * 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 <= -7e+15) || !(y <= 1.2e+17)) {
tmp = y * (x * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7e+15) or not (y <= 1.2e+17): tmp = y * (x * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7e+15) || !(y <= 1.2e+17)) tmp = Float64(y * Float64(x * 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 <= -7e+15) || ~((y <= 1.2e+17))) tmp = y * (x * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e+15], N[Not[LessEqual[y, 1.2e+17]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+15} \lor \neg \left(y \leq 1.2 \cdot 10^{+17}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -7e15 or 1.2e17 < y Initial program 85.4%
flip--56.1%
associate-*r/51.5%
associate-/l*56.2%
*-un-lft-identity56.2%
associate-/l*56.2%
flip--85.4%
cancel-sign-sub-inv85.4%
*-commutative85.4%
sub-neg85.4%
distribute-neg-in85.4%
+-commutative85.4%
*-un-lft-identity85.4%
distribute-lft-neg-in85.4%
distribute-lft-neg-in85.4%
metadata-eval85.4%
metadata-eval85.4%
*-un-lft-identity85.4%
metadata-eval85.4%
Applied egg-rr85.4%
Taylor expanded in y around inf 67.0%
*-commutative67.0%
associate-/r*68.7%
Simplified68.7%
associate-/r/80.5%
div-inv80.5%
clear-num80.5%
/-rgt-identity80.5%
Applied egg-rr80.5%
if -7e15 < y < 1.2e17Initial program 100.0%
Taylor expanded in y around 0 99.8%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.019))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.019)) {
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 <= 0.019d0))) 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 <= 0.019)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.019): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.019)) 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 <= 0.019))) 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, 0.019]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.019\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 0.0189999999999999995 < z Initial program 86.7%
Taylor expanded in z around inf 85.0%
Taylor expanded in y around 0 58.2%
mul-1-neg58.2%
Simplified58.2%
if -1 < z < 0.0189999999999999995Initial program 99.9%
Taylor expanded in z around 0 68.4%
Final simplification63.3%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.3%
Taylor expanded in z around 0 35.9%
Final simplification35.9%
(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 2023336
(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))))