
(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 (if (<= z 2e+16) (+ x (* x (* z (+ y -1.0)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2e+16) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2d+16) then
tmp = x + (x * (z * (y + (-1.0d0))))
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2e+16) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2e+16: tmp = x + (x * (z * (y + -1.0))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2e+16) tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2e+16) tmp = x + (x * (z * (y + -1.0))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2e+16], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{+16}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 2e16Initial program 98.9%
Taylor expanded in z around 0 98.9%
if 2e16 < z Initial program 86.4%
Taylor expanded in z around inf 86.4%
*-commutative86.4%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
(if (<= z -7e+35)
t_0
(if (<= z -6e-6)
t_1
(if (<= z 1.0)
x
(if (or (<= z 2.3e+144) (not (<= z 6.2e+189))) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (z <= -7e+35) {
tmp = t_0;
} else if (z <= -6e-6) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 2.3e+144) || !(z <= 6.2e+189)) {
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 = z * -x
t_1 = x * (z * y)
if (z <= (-7d+35)) then
tmp = t_0
else if (z <= (-6d-6)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x
else if ((z <= 2.3d+144) .or. (.not. (z <= 6.2d+189))) 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 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (z <= -7e+35) {
tmp = t_0;
} else if (z <= -6e-6) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 2.3e+144) || !(z <= 6.2e+189)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (z * y) tmp = 0 if z <= -7e+35: tmp = t_0 elif z <= -6e-6: tmp = t_1 elif z <= 1.0: tmp = x elif (z <= 2.3e+144) or not (z <= 6.2e+189): tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(z * y)) tmp = 0.0 if (z <= -7e+35) tmp = t_0; elseif (z <= -6e-6) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 2.3e+144) || !(z <= 6.2e+189)) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (z * y); tmp = 0.0; if (z <= -7e+35) tmp = t_0; elseif (z <= -6e-6) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 2.3e+144) || ~((z <= 6.2e+189))) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7e+35], t$95$0, If[LessEqual[z, -6e-6], t$95$1, If[LessEqual[z, 1.0], x, If[Or[LessEqual[z, 2.3e+144], N[Not[LessEqual[z, 6.2e+189]], $MachinePrecision]], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -7 \cdot 10^{+35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{+144} \lor \neg \left(z \leq 6.2 \cdot 10^{+189}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -7.0000000000000001e35 or 1 < z < 2.3000000000000001e144 or 6.1999999999999999e189 < z Initial program 93.6%
Taylor expanded in z around 0 93.6%
Taylor expanded in y around inf 73.3%
+-commutative73.3%
mul-1-neg73.3%
unsub-neg73.3%
*-commutative73.3%
*-commutative73.3%
associate-/l*74.9%
distribute-lft-out--85.3%
Simplified85.3%
Taylor expanded in y around 0 67.5%
mul-1-neg67.5%
sub-neg67.5%
Simplified67.5%
Taylor expanded in z around inf 66.5%
associate-*r*66.5%
neg-mul-166.5%
*-commutative66.5%
Simplified66.5%
if -7.0000000000000001e35 < z < -6.0000000000000002e-6 or 2.3000000000000001e144 < z < 6.1999999999999999e189Initial program 81.7%
Taylor expanded in y around inf 63.9%
*-commutative63.9%
Simplified63.9%
if -6.0000000000000002e-6 < z < 1Initial program 99.9%
Taylor expanded in z around 0 79.5%
Final simplification72.4%
(FPCore (x y z)
:precision binary64
(if (or (<= y -9.5e+148)
(and (not (<= y -1.85e+53))
(or (<= y -7.2e+29) (not (<= y 1.5e+18)))))
(* y (* z x))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.5e+148) || (!(y <= -1.85e+53) && ((y <= -7.2e+29) || !(y <= 1.5e+18)))) {
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 <= (-9.5d+148)) .or. (.not. (y <= (-1.85d+53))) .and. (y <= (-7.2d+29)) .or. (.not. (y <= 1.5d+18))) 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 <= -9.5e+148) || (!(y <= -1.85e+53) && ((y <= -7.2e+29) || !(y <= 1.5e+18)))) {
tmp = y * (z * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.5e+148) or (not (y <= -1.85e+53) and ((y <= -7.2e+29) or not (y <= 1.5e+18))): tmp = y * (z * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.5e+148) || (!(y <= -1.85e+53) && ((y <= -7.2e+29) || !(y <= 1.5e+18)))) 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 <= -9.5e+148) || (~((y <= -1.85e+53)) && ((y <= -7.2e+29) || ~((y <= 1.5e+18))))) tmp = y * (z * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.5e+148], And[N[Not[LessEqual[y, -1.85e+53]], $MachinePrecision], Or[LessEqual[y, -7.2e+29], N[Not[LessEqual[y, 1.5e+18]], $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 -9.5 \cdot 10^{+148} \lor \neg \left(y \leq -1.85 \cdot 10^{+53}\right) \land \left(y \leq -7.2 \cdot 10^{+29} \lor \neg \left(y \leq 1.5 \cdot 10^{+18}\right)\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -9.5000000000000002e148 or -1.85e53 < y < -7.19999999999999952e29 or 1.5e18 < y Initial program 88.3%
Taylor expanded in z around 0 88.3%
Taylor expanded in y around inf 88.3%
*-commutative88.3%
Simplified88.3%
*-commutative88.3%
distribute-rgt1-in88.3%
Applied egg-rr88.3%
Taylor expanded in z around inf 68.1%
associate-*r*76.7%
*-commutative76.7%
associate-*r*75.9%
Simplified75.9%
if -9.5000000000000002e148 < y < -1.85e53 or -7.19999999999999952e29 < y < 1.5e18Initial program 99.5%
Taylor expanded in y around 0 96.5%
Final simplification89.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* z x))))
(if (<= y -9.5e+148)
t_0
(if (<= y -1.05e+57)
(* x (- 1.0 z))
(if (or (<= y -3.35e+28) (not (<= y 2.5e+18))) t_0 (- x (* z x)))))))
double code(double x, double y, double z) {
double t_0 = y * (z * x);
double tmp;
if (y <= -9.5e+148) {
tmp = t_0;
} else if (y <= -1.05e+57) {
tmp = x * (1.0 - z);
} else if ((y <= -3.35e+28) || !(y <= 2.5e+18)) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y * (z * x)
if (y <= (-9.5d+148)) then
tmp = t_0
else if (y <= (-1.05d+57)) then
tmp = x * (1.0d0 - z)
else if ((y <= (-3.35d+28)) .or. (.not. (y <= 2.5d+18))) then
tmp = t_0
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (z * x);
double tmp;
if (y <= -9.5e+148) {
tmp = t_0;
} else if (y <= -1.05e+57) {
tmp = x * (1.0 - z);
} else if ((y <= -3.35e+28) || !(y <= 2.5e+18)) {
tmp = t_0;
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): t_0 = y * (z * x) tmp = 0 if y <= -9.5e+148: tmp = t_0 elif y <= -1.05e+57: tmp = x * (1.0 - z) elif (y <= -3.35e+28) or not (y <= 2.5e+18): tmp = t_0 else: tmp = x - (z * x) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z * x)) tmp = 0.0 if (y <= -9.5e+148) tmp = t_0; elseif (y <= -1.05e+57) tmp = Float64(x * Float64(1.0 - z)); elseif ((y <= -3.35e+28) || !(y <= 2.5e+18)) tmp = t_0; else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z * x); tmp = 0.0; if (y <= -9.5e+148) tmp = t_0; elseif (y <= -1.05e+57) tmp = x * (1.0 - z); elseif ((y <= -3.35e+28) || ~((y <= 2.5e+18))) tmp = t_0; else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+148], t$95$0, If[LessEqual[y, -1.05e+57], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -3.35e+28], N[Not[LessEqual[y, 2.5e+18]], $MachinePrecision]], t$95$0, N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+148}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{+57}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{elif}\;y \leq -3.35 \cdot 10^{+28} \lor \neg \left(y \leq 2.5 \cdot 10^{+18}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -9.5000000000000002e148 or -1.04999999999999995e57 < y < -3.35e28 or 2.5e18 < y Initial program 88.3%
Taylor expanded in z around 0 88.3%
Taylor expanded in y around inf 88.3%
*-commutative88.3%
Simplified88.3%
*-commutative88.3%
distribute-rgt1-in88.3%
Applied egg-rr88.3%
Taylor expanded in z around inf 68.1%
associate-*r*76.7%
*-commutative76.7%
associate-*r*75.9%
Simplified75.9%
if -9.5000000000000002e148 < y < -1.04999999999999995e57Initial program 94.5%
Taylor expanded in y around 0 75.1%
if -3.35e28 < y < 2.5e18Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around inf 77.1%
+-commutative77.1%
mul-1-neg77.1%
unsub-neg77.1%
*-commutative77.1%
*-commutative77.1%
associate-/l*72.4%
distribute-lft-out--78.4%
Simplified78.4%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
sub-neg98.7%
Simplified98.7%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e-5) (not (<= z 8200.0))) (* z (* x (+ y -1.0))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e-5) || !(z <= 8200.0)) {
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 <= (-2d-5)) .or. (.not. (z <= 8200.0d0))) 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 <= -2e-5) || !(z <= 8200.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e-5) or not (z <= 8200.0): tmp = z * (x * (y + -1.0)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e-5) || !(z <= 8200.0)) 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 <= -2e-5) || ~((z <= 8200.0))) tmp = z * (x * (y + -1.0)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e-5], N[Not[LessEqual[z, 8200.0]], $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 \cdot 10^{-5} \lor \neg \left(z \leq 8200\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -2.00000000000000016e-5 or 8200 < z Initial program 91.7%
Taylor expanded in z around inf 90.7%
*-commutative90.7%
associate-*r*99.0%
*-commutative99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
if -2.00000000000000016e-5 < z < 8200Initial program 99.9%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around inf 87.7%
+-commutative87.7%
mul-1-neg87.7%
unsub-neg87.7%
*-commutative87.7%
*-commutative87.7%
associate-/l*81.9%
distribute-lft-out--81.9%
Simplified81.9%
Taylor expanded in y around 0 81.6%
mul-1-neg81.6%
sub-neg81.6%
Simplified81.6%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.5e+24) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e+24) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (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 <= (-1.5d+24)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x * (1.0d0 + (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e+24) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.5e+24) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.5e+24) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 + Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.5e+24) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.5e+24], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+24} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -1.49999999999999997e24 or 1 < z Initial program 91.4%
Taylor expanded in z around inf 90.5%
*-commutative90.5%
associate-*r*99.0%
*-commutative99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
if -1.49999999999999997e24 < z < 1Initial program 99.9%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around inf 97.6%
*-commutative97.6%
Simplified97.6%
*-commutative97.6%
distribute-rgt1-in97.6%
Applied egg-rr97.6%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.5e+24) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e+24) || !(z <= 1.0)) {
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 <= (-1.5d+24)) .or. (.not. (z <= 1.0d0))) 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 <= -1.5e+24) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.5e+24) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.5e+24) || !(z <= 1.0)) 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 <= -1.5e+24) || ~((z <= 1.0))) 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, -1.5e+24], N[Not[LessEqual[z, 1.0]], $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 -1.5 \cdot 10^{+24} \lor \neg \left(z \leq 1\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 < -1.49999999999999997e24 or 1 < z Initial program 91.4%
Taylor expanded in z around inf 90.5%
*-commutative90.5%
associate-*r*99.0%
*-commutative99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
if -1.49999999999999997e24 < z < 1Initial program 99.9%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around inf 97.6%
*-commutative97.6%
Simplified97.6%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.05e+120) (not (<= y 1.6e+18))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.05e+120) || !(y <= 1.6e+18)) {
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 <= (-2.05d+120)) .or. (.not. (y <= 1.6d+18))) 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 <= -2.05e+120) || !(y <= 1.6e+18)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.05e+120) or not (y <= 1.6e+18): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.05e+120) || !(y <= 1.6e+18)) 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 <= -2.05e+120) || ~((y <= 1.6e+18))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.05e+120], N[Not[LessEqual[y, 1.6e+18]], $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 -2.05 \cdot 10^{+120} \lor \neg \left(y \leq 1.6 \cdot 10^{+18}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.05e120 or 1.6e18 < y Initial program 88.8%
Taylor expanded in y around inf 67.7%
*-commutative67.7%
Simplified67.7%
if -2.05e120 < y < 1.6e18Initial program 98.9%
Taylor expanded in y around 0 94.4%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.5e+24) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.5e+24) || !(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.5d+24)) .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.5e+24) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.5e+24) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.5e+24) || !(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.5e+24) || ~((z <= 1.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.5e+24], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.5 \cdot 10^{+24} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.49999999999999997e24 or 1 < z Initial program 91.4%
Taylor expanded in z around 0 91.4%
Taylor expanded in y around inf 76.4%
+-commutative76.4%
mul-1-neg76.4%
unsub-neg76.4%
*-commutative76.4%
*-commutative76.4%
associate-/l*77.8%
distribute-lft-out--86.9%
Simplified86.9%
Taylor expanded in y around 0 63.0%
mul-1-neg63.0%
sub-neg63.0%
Simplified63.0%
Taylor expanded in z around inf 62.1%
associate-*r*62.1%
neg-mul-162.1%
*-commutative62.1%
Simplified62.1%
if -1.49999999999999997e24 < z < 1Initial program 99.9%
Taylor expanded in z around 0 76.0%
Final simplification68.9%
(FPCore (x y z) :precision binary64 (if (<= z 2e+16) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2e+16) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2d+16) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2e+16) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2e+16: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2e+16) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2e+16) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2e+16], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{+16}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 2e16Initial program 98.9%
if 2e16 < z Initial program 86.4%
Taylor expanded in z around inf 86.4%
*-commutative86.4%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.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.5%
Taylor expanded in z around 0 38.7%
Final simplification38.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t\_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024054
(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))))