
(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 10 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 -0.0021) (* z (* x (+ y -1.0))) (if (<= z 1.0) (+ x (* x (* y z))) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0021) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x + (x * (y * z));
} else {
tmp = z * ((y * x) - 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 <= (-0.0021d0)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 1.0d0) then
tmp = x + (x * (y * z))
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.0021) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x + (x * (y * z));
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0021: tmp = z * (x * (y + -1.0)) elif z <= 1.0: tmp = x + (x * (y * z)) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0021) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 1.0) tmp = Float64(x + Float64(x * Float64(y * z))); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.0021) tmp = z * (x * (y + -1.0)); elseif (z <= 1.0) tmp = x + (x * (y * z)); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0021], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0021:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -0.00209999999999999987Initial program 90.6%
Taylor expanded in z around inf 89.0%
*-commutative89.0%
associate-*l*98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
if -0.00209999999999999987 < z < 1Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around inf 99.7%
*-commutative99.7%
Simplified99.7%
if 1 < z Initial program 92.0%
Taylor expanded in z around inf 91.3%
*-commutative91.3%
associate-*l*99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 99.3%
neg-mul-199.3%
+-commutative99.3%
fma-def99.3%
fma-neg99.3%
Simplified99.3%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
(if (<= z -1.35e+219)
t_0
(if (<= z -3.6e+186)
t_1
(if (<= z -1.0)
t_0
(if (<= z 1.2e-62) x (if (<= z 1.35e+41) 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.35e+219) {
tmp = t_0;
} else if (z <= -3.6e+186) {
tmp = t_1;
} else if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.2e-62) {
tmp = x;
} else if (z <= 1.35e+41) {
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.35d+219)) then
tmp = t_0
else if (z <= (-3.6d+186)) then
tmp = t_1
else if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 1.2d-62) then
tmp = x
else if (z <= 1.35d+41) 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.35e+219) {
tmp = t_0;
} else if (z <= -3.6e+186) {
tmp = t_1;
} else if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.2e-62) {
tmp = x;
} else if (z <= 1.35e+41) {
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.35e+219: tmp = t_0 elif z <= -3.6e+186: tmp = t_1 elif z <= -1.0: tmp = t_0 elif z <= 1.2e-62: tmp = x elif z <= 1.35e+41: 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.35e+219) tmp = t_0; elseif (z <= -3.6e+186) tmp = t_1; elseif (z <= -1.0) tmp = t_0; elseif (z <= 1.2e-62) tmp = x; elseif (z <= 1.35e+41) 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.35e+219) tmp = t_0; elseif (z <= -3.6e+186) tmp = t_1; elseif (z <= -1.0) tmp = t_0; elseif (z <= 1.2e-62) tmp = x; elseif (z <= 1.35e+41) 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.35e+219], t$95$0, If[LessEqual[z, -3.6e+186], t$95$1, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 1.2e-62], x, If[LessEqual[z, 1.35e+41], 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.35 \cdot 10^{+219}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{+186}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-62}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+41}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.3499999999999999e219 or -3.6000000000000002e186 < z < -1 or 1.35e41 < z Initial program 92.1%
Taylor expanded in y around 0 65.0%
sub-neg65.0%
distribute-rgt-in65.0%
*-lft-identity65.0%
distribute-lft-neg-out65.0%
*-commutative65.0%
unsub-neg65.0%
Simplified65.0%
Taylor expanded in z around inf 64.7%
mul-1-neg64.7%
*-commutative64.7%
distribute-rgt-neg-in64.7%
Simplified64.7%
if -1.3499999999999999e219 < z < -3.6000000000000002e186 or 1.19999999999999992e-62 < z < 1.35e41Initial program 90.0%
Taylor expanded in y around inf 64.9%
*-commutative64.9%
Simplified64.9%
if -1 < z < 1.19999999999999992e-62Initial program 99.9%
Taylor expanded in z around 0 78.4%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) (- INFINITY)) (* z (* y x)) (* x (- (- (* y z) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -((double) INFINITY)) {
tmp = z * (y * x);
} else {
tmp = x * (((y * z) - z) - -1.0);
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -Double.POSITIVE_INFINITY) {
tmp = z * (y * x);
} else {
tmp = x * (((y * z) - z) - -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -math.inf: tmp = z * (y * x) else: tmp = x * (((y * z) - z) - -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= Float64(-Inf)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(Float64(Float64(y * z) - z) - -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -Inf) tmp = z * (y * x); else tmp = x * (((y * z) - z) - -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], (-Infinity)], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(y \cdot z - z\right) - -1\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -inf.0Initial program 50.6%
Taylor expanded in y around 0 50.6%
mul-1-neg50.6%
unsub-neg50.6%
*-commutative50.6%
Simplified50.6%
Taylor expanded in y around inf 50.6%
*-commutative50.6%
associate-*r*99.8%
*-commutative99.8%
associate-*r*99.9%
Simplified99.9%
if -inf.0 < (*.f64 (-.f64 1 y) z) Initial program 98.4%
Taylor expanded in y around 0 98.4%
mul-1-neg98.4%
unsub-neg98.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) (- INFINITY)) (* z (* y x)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -((double) INFINITY)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -Double.POSITIVE_INFINITY) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -math.inf: tmp = z * (y * x) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= Float64(-Inf)) tmp = Float64(z * Float64(y * x)); 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 (((1.0 - y) * z) <= -Inf) tmp = z * (y * x); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], (-Infinity)], N[(z * N[(y * x), $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}\;\left(1 - y\right) \cdot z \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -inf.0Initial program 50.6%
Taylor expanded in y around 0 50.6%
mul-1-neg50.6%
unsub-neg50.6%
*-commutative50.6%
Simplified50.6%
Taylor expanded in y around inf 50.6%
*-commutative50.6%
associate-*r*99.8%
*-commutative99.8%
associate-*r*99.9%
Simplified99.9%
if -inf.0 < (*.f64 (-.f64 1 y) z) Initial program 98.4%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* z x))) (t_1 (* z (- x))))
(if (<= z -9.4e+185)
t_0
(if (<= z -1.0)
t_1
(if (<= z 1.36e-62) x (if (<= z 1.75e+99) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = y * (z * x);
double t_1 = z * -x;
double tmp;
if (z <= -9.4e+185) {
tmp = t_0;
} else if (z <= -1.0) {
tmp = t_1;
} else if (z <= 1.36e-62) {
tmp = x;
} else if (z <= 1.75e+99) {
tmp = t_0;
} 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 = y * (z * x)
t_1 = z * -x
if (z <= (-9.4d+185)) then
tmp = t_0
else if (z <= (-1.0d0)) then
tmp = t_1
else if (z <= 1.36d-62) then
tmp = x
else if (z <= 1.75d+99) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (z * x);
double t_1 = z * -x;
double tmp;
if (z <= -9.4e+185) {
tmp = t_0;
} else if (z <= -1.0) {
tmp = t_1;
} else if (z <= 1.36e-62) {
tmp = x;
} else if (z <= 1.75e+99) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z * x) t_1 = z * -x tmp = 0 if z <= -9.4e+185: tmp = t_0 elif z <= -1.0: tmp = t_1 elif z <= 1.36e-62: tmp = x elif z <= 1.75e+99: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z * x)) t_1 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -9.4e+185) tmp = t_0; elseif (z <= -1.0) tmp = t_1; elseif (z <= 1.36e-62) tmp = x; elseif (z <= 1.75e+99) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z * x); t_1 = z * -x; tmp = 0.0; if (z <= -9.4e+185) tmp = t_0; elseif (z <= -1.0) tmp = t_1; elseif (z <= 1.36e-62) tmp = x; elseif (z <= 1.75e+99) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -9.4e+185], t$95$0, If[LessEqual[z, -1.0], t$95$1, If[LessEqual[z, 1.36e-62], x, If[LessEqual[z, 1.75e+99], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot x\right)\\
t_1 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -9.4 \cdot 10^{+185}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.36 \cdot 10^{-62}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+99}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -9.39999999999999945e185 or 1.35999999999999999e-62 < z < 1.7499999999999999e99Initial program 86.9%
Taylor expanded in y around inf 58.0%
mul-1-neg58.0%
distribute-lft-neg-out58.0%
*-commutative58.0%
Simplified58.0%
*-commutative58.0%
cancel-sign-sub58.0%
*-commutative58.0%
+-commutative58.0%
add-cube-cbrt57.5%
associate-*l*57.5%
fma-def57.5%
pow257.5%
Applied egg-rr57.5%
Taylor expanded in y around inf 52.2%
pow-base-152.2%
*-commutative52.2%
*-lft-identity52.2%
associate-*r*68.4%
*-commutative68.4%
Simplified68.4%
if -9.39999999999999945e185 < z < -1 or 1.7499999999999999e99 < z Initial program 94.7%
Taylor expanded in y around 0 67.7%
sub-neg67.7%
distribute-rgt-in67.7%
*-lft-identity67.7%
distribute-lft-neg-out67.7%
*-commutative67.7%
unsub-neg67.7%
Simplified67.7%
Taylor expanded in z around inf 67.3%
mul-1-neg67.3%
*-commutative67.3%
distribute-rgt-neg-in67.3%
Simplified67.3%
if -1 < z < 1.35999999999999999e-62Initial program 99.9%
Taylor expanded in z around 0 78.4%
Final simplification72.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.7e-23) (not (<= z 1.36e-62))) (* z (* x (+ y -1.0))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.7e-23) || !(z <= 1.36e-62)) {
tmp = z * (x * (y + -1.0));
} 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 ((z <= (-2.7d-23)) .or. (.not. (z <= 1.36d-62))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.7e-23) || !(z <= 1.36e-62)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.7e-23) or not (z <= 1.36e-62): tmp = z * (x * (y + -1.0)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.7e-23) || !(z <= 1.36e-62)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.7e-23) || ~((z <= 1.36e-62))) tmp = z * (x * (y + -1.0)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.7e-23], N[Not[LessEqual[z, 1.36e-62]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{-23} \lor \neg \left(z \leq 1.36 \cdot 10^{-62}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -2.69999999999999985e-23 or 1.35999999999999999e-62 < z Initial program 92.1%
Taylor expanded in z around inf 87.7%
*-commutative87.7%
associate-*l*95.5%
sub-neg95.5%
metadata-eval95.5%
Simplified95.5%
if -2.69999999999999985e-23 < z < 1.35999999999999999e-62Initial program 100.0%
Taylor expanded in y around 0 81.9%
sub-neg81.9%
distribute-rgt-in81.9%
*-lft-identity81.9%
distribute-lft-neg-out81.9%
*-commutative81.9%
unsub-neg81.9%
Simplified81.9%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (<= z -9.7e-23) (* z (* x (+ y -1.0))) (if (<= z 3.1e-63) (- x (* z x)) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.7e-23) {
tmp = z * (x * (y + -1.0));
} else if (z <= 3.1e-63) {
tmp = x - (z * x);
} else {
tmp = z * ((y * x) - 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 <= (-9.7d-23)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 3.1d-63) then
tmp = x - (z * x)
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.7e-23) {
tmp = z * (x * (y + -1.0));
} else if (z <= 3.1e-63) {
tmp = x - (z * x);
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.7e-23: tmp = z * (x * (y + -1.0)) elif z <= 3.1e-63: tmp = x - (z * x) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.7e-23) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 3.1e-63) tmp = Float64(x - Float64(z * x)); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.7e-23) tmp = z * (x * (y + -1.0)); elseif (z <= 3.1e-63) tmp = x - (z * x); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.7e-23], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.1e-63], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.7 \cdot 10^{-23}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 3.1 \cdot 10^{-63}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -9.7000000000000003e-23Initial program 91.3%
Taylor expanded in z around inf 87.3%
*-commutative87.3%
associate-*l*95.9%
sub-neg95.9%
metadata-eval95.9%
Simplified95.9%
if -9.7000000000000003e-23 < z < 3.09999999999999984e-63Initial program 100.0%
Taylor expanded in y around 0 81.9%
sub-neg81.9%
distribute-rgt-in81.9%
*-lft-identity81.9%
distribute-lft-neg-out81.9%
*-commutative81.9%
unsub-neg81.9%
Simplified81.9%
if 3.09999999999999984e-63 < z Initial program 92.8%
Taylor expanded in z around inf 88.0%
*-commutative88.0%
associate-*l*95.2%
sub-neg95.2%
metadata-eval95.2%
Simplified95.2%
Taylor expanded in y around 0 95.2%
neg-mul-195.2%
+-commutative95.2%
fma-def95.2%
fma-neg95.2%
Simplified95.2%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.6e+52) (not (<= y 2.1e+59))) (* y (* z x)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.6e+52) || !(y <= 2.1e+59)) {
tmp = y * (z * x);
} 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 <= (-2.6d+52)) .or. (.not. (y <= 2.1d+59))) then
tmp = y * (z * x)
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 <= -2.6e+52) || !(y <= 2.1e+59)) {
tmp = y * (z * x);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.6e+52) or not (y <= 2.1e+59): tmp = y * (z * x) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.6e+52) || !(y <= 2.1e+59)) tmp = Float64(y * Float64(z * x)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.6e+52) || ~((y <= 2.1e+59))) tmp = y * (z * x); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.6e+52], N[Not[LessEqual[y, 2.1e+59]], $MachinePrecision]], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+52} \lor \neg \left(y \leq 2.1 \cdot 10^{+59}\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -2.6e52 or 2.09999999999999984e59 < y Initial program 87.1%
Taylor expanded in y around inf 87.1%
mul-1-neg87.1%
distribute-lft-neg-out87.1%
*-commutative87.1%
Simplified87.1%
*-commutative87.1%
cancel-sign-sub87.1%
*-commutative87.1%
+-commutative87.1%
add-cube-cbrt86.2%
associate-*l*86.3%
fma-def86.3%
pow286.3%
Applied egg-rr86.3%
Taylor expanded in y around inf 70.7%
pow-base-170.7%
*-commutative70.7%
*-lft-identity70.7%
associate-*r*81.9%
*-commutative81.9%
Simplified81.9%
if -2.6e52 < y < 2.09999999999999984e59Initial program 100.0%
Taylor expanded in y around 0 94.0%
sub-neg94.0%
distribute-rgt-in94.0%
*-lft-identity94.0%
distribute-lft-neg-out94.0%
*-commutative94.0%
unsub-neg94.0%
Simplified94.0%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 4.9))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 4.9)) {
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 <= 4.9d0))) 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 <= 4.9)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 4.9): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 4.9)) 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 <= 4.9))) 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, 4.9]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4.9\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 4.9000000000000004 < z Initial program 91.1%
Taylor expanded in y around 0 59.1%
sub-neg59.1%
distribute-rgt-in59.1%
*-lft-identity59.1%
distribute-lft-neg-out59.1%
*-commutative59.1%
unsub-neg59.1%
Simplified59.1%
Taylor expanded in z around inf 58.5%
mul-1-neg58.5%
*-commutative58.5%
distribute-rgt-neg-in58.5%
Simplified58.5%
if -1 < z < 4.9000000000000004Initial program 99.9%
Taylor expanded in z around 0 75.2%
Final simplification66.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.2%
Taylor expanded in z around 0 36.5%
Final simplification36.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 2023287
(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))))