
(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 (<= (* (- 1.0 y) z) 1e+149) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 1e+149) {
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 (((1.0d0 - y) * z) <= 1d+149) 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 (((1.0 - y) * z) <= 1e+149) {
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 ((1.0 - y) * z) <= 1e+149: 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 (Float64(Float64(1.0 - y) * z) <= 1e+149) 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 (((1.0 - y) * z) <= 1e+149) 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[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], 1e+149], 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}\;\left(1 - y\right) \cdot z \leq 10^{+149}:\\
\;\;\;\;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 (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 1.00000000000000005e149Initial program 98.5%
if 1.00000000000000005e149 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 82.7%
Taylor expanded in z around inf 82.7%
*-commutative82.7%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(if (or (<= y -6.4e+144)
(not
(or (<= y -8e+59)
(and (not (<= y -4800000000000.0)) (<= y 5.5e+55)))))
(* x (* y z))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e+144) || !((y <= -8e+59) || (!(y <= -4800000000000.0) && (y <= 5.5e+55)))) {
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 <= (-6.4d+144)) .or. (.not. (y <= (-8d+59)) .or. (.not. (y <= (-4800000000000.0d0))) .and. (y <= 5.5d+55))) 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 <= -6.4e+144) || !((y <= -8e+59) || (!(y <= -4800000000000.0) && (y <= 5.5e+55)))) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.4e+144) or not ((y <= -8e+59) or (not (y <= -4800000000000.0) and (y <= 5.5e+55))): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.4e+144) || !((y <= -8e+59) || (!(y <= -4800000000000.0) && (y <= 5.5e+55)))) 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 <= -6.4e+144) || ~(((y <= -8e+59) || (~((y <= -4800000000000.0)) && (y <= 5.5e+55))))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.4e+144], N[Not[Or[LessEqual[y, -8e+59], And[N[Not[LessEqual[y, -4800000000000.0]], $MachinePrecision], LessEqual[y, 5.5e+55]]]], $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 -6.4 \cdot 10^{+144} \lor \neg \left(y \leq -8 \cdot 10^{+59} \lor \neg \left(y \leq -4800000000000\right) \land y \leq 5.5 \cdot 10^{+55}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -6.4000000000000002e144 or -7.99999999999999977e59 < y < -4.8e12 or 5.5000000000000004e55 < y Initial program 88.7%
Taylor expanded in y around inf 72.5%
*-commutative72.5%
Simplified72.5%
if -6.4000000000000002e144 < y < -7.99999999999999977e59 or -4.8e12 < y < 5.5000000000000004e55Initial program 98.8%
Taylor expanded in y around 0 93.4%
Final simplification85.8%
(FPCore (x y z)
:precision binary64
(if (or (<= y -3e+106)
(and (not (<= y -3.75e+86))
(or (<= y -19000000000000.0) (not (<= y 2.2e+55)))))
(* y (* z x))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+106) || (!(y <= -3.75e+86) && ((y <= -19000000000000.0) || !(y <= 2.2e+55)))) {
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 <= (-3d+106)) .or. (.not. (y <= (-3.75d+86))) .and. (y <= (-19000000000000.0d0)) .or. (.not. (y <= 2.2d+55))) 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 <= -3e+106) || (!(y <= -3.75e+86) && ((y <= -19000000000000.0) || !(y <= 2.2e+55)))) {
tmp = y * (z * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+106) or (not (y <= -3.75e+86) and ((y <= -19000000000000.0) or not (y <= 2.2e+55))): tmp = y * (z * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e+106) || (!(y <= -3.75e+86) && ((y <= -19000000000000.0) || !(y <= 2.2e+55)))) 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 <= -3e+106) || (~((y <= -3.75e+86)) && ((y <= -19000000000000.0) || ~((y <= 2.2e+55))))) tmp = y * (z * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e+106], And[N[Not[LessEqual[y, -3.75e+86]], $MachinePrecision], Or[LessEqual[y, -19000000000000.0], N[Not[LessEqual[y, 2.2e+55]], $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 -3 \cdot 10^{+106} \lor \neg \left(y \leq -3.75 \cdot 10^{+86}\right) \land \left(y \leq -19000000000000 \lor \neg \left(y \leq 2.2 \cdot 10^{+55}\right)\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.0000000000000001e106 or -3.7499999999999998e86 < y < -1.9e13 or 2.2000000000000001e55 < y Initial program 88.2%
Taylor expanded in y around inf 87.8%
Taylor expanded in y around inf 78.2%
if -3.0000000000000001e106 < y < -3.7499999999999998e86 or -1.9e13 < y < 2.2000000000000001e55Initial program 100.0%
Taylor expanded in y around 0 96.7%
Final simplification89.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -1.6e+37)
t_0
(if (<= z -1.35e-21)
t_1
(if (<= z 5.8e-6) x (if (<= z 3.7e+146) 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 <= -1.6e+37) {
tmp = t_0;
} else if (z <= -1.35e-21) {
tmp = t_1;
} else if (z <= 5.8e-6) {
tmp = x;
} else if (z <= 3.7e+146) {
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 <= (-1.6d+37)) then
tmp = t_0
else if (z <= (-1.35d-21)) then
tmp = t_1
else if (z <= 5.8d-6) then
tmp = x
else if (z <= 3.7d+146) 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 <= -1.6e+37) {
tmp = t_0;
} else if (z <= -1.35e-21) {
tmp = t_1;
} else if (z <= 5.8e-6) {
tmp = x;
} else if (z <= 3.7e+146) {
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 <= -1.6e+37: tmp = t_0 elif z <= -1.35e-21: tmp = t_1 elif z <= 5.8e-6: tmp = x elif z <= 3.7e+146: 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 <= -1.6e+37) tmp = t_0; elseif (z <= -1.35e-21) tmp = t_1; elseif (z <= 5.8e-6) tmp = x; elseif (z <= 3.7e+146) 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 <= -1.6e+37) tmp = t_0; elseif (z <= -1.35e-21) tmp = t_1; elseif (z <= 5.8e-6) tmp = x; elseif (z <= 3.7e+146) 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, -1.6e+37], t$95$0, If[LessEqual[z, -1.35e-21], t$95$1, If[LessEqual[z, 5.8e-6], x, If[LessEqual[z, 3.7e+146], 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 -1.6 \cdot 10^{+37}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-6}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+146}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.60000000000000007e37 or 3.70000000000000004e146 < z Initial program 88.7%
Taylor expanded in z around inf 88.7%
*-commutative88.7%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 67.2%
neg-mul-167.2%
Simplified67.2%
if -1.60000000000000007e37 < z < -1.3500000000000001e-21 or 5.8000000000000004e-6 < z < 3.70000000000000004e146Initial program 95.7%
Taylor expanded in y around inf 68.2%
*-commutative68.2%
Simplified68.2%
if -1.3500000000000001e-21 < z < 5.8000000000000004e-6Initial program 100.0%
Taylor expanded in z around 0 80.3%
Final simplification73.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* z x))) (t_1 (* x (- 1.0 z))))
(if (<= y -3e+106)
t_0
(if (<= y -4.2e+88)
t_1
(if (<= y -3.8e+14) (* z (* y x)) (if (<= y 2.05e+55) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (z * x);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -3e+106) {
tmp = t_0;
} else if (y <= -4.2e+88) {
tmp = t_1;
} else if (y <= -3.8e+14) {
tmp = z * (y * x);
} else if (y <= 2.05e+55) {
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 = y * (z * x)
t_1 = x * (1.0d0 - z)
if (y <= (-3d+106)) then
tmp = t_0
else if (y <= (-4.2d+88)) then
tmp = t_1
else if (y <= (-3.8d+14)) then
tmp = z * (y * x)
else if (y <= 2.05d+55) 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 = y * (z * x);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -3e+106) {
tmp = t_0;
} else if (y <= -4.2e+88) {
tmp = t_1;
} else if (y <= -3.8e+14) {
tmp = z * (y * x);
} else if (y <= 2.05e+55) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z * x) t_1 = x * (1.0 - z) tmp = 0 if y <= -3e+106: tmp = t_0 elif y <= -4.2e+88: tmp = t_1 elif y <= -3.8e+14: tmp = z * (y * x) elif y <= 2.05e+55: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z * x)) t_1 = Float64(x * Float64(1.0 - z)) tmp = 0.0 if (y <= -3e+106) tmp = t_0; elseif (y <= -4.2e+88) tmp = t_1; elseif (y <= -3.8e+14) tmp = Float64(z * Float64(y * x)); elseif (y <= 2.05e+55) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z * x); t_1 = x * (1.0 - z); tmp = 0.0; if (y <= -3e+106) tmp = t_0; elseif (y <= -4.2e+88) tmp = t_1; elseif (y <= -3.8e+14) tmp = z * (y * x); elseif (y <= 2.05e+55) tmp = t_1; else tmp = t_0; 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[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3e+106], t$95$0, If[LessEqual[y, -4.2e+88], t$95$1, If[LessEqual[y, -3.8e+14], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e+55], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot x\right)\\
t_1 := x \cdot \left(1 - z\right)\\
\mathbf{if}\;y \leq -3 \cdot 10^{+106}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{+88}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -3.8 \cdot 10^{+14}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{+55}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.0000000000000001e106 or 2.04999999999999991e55 < y Initial program 87.1%
Taylor expanded in y around inf 85.7%
Taylor expanded in y around inf 78.7%
if -3.0000000000000001e106 < y < -4.2e88 or -3.8e14 < y < 2.04999999999999991e55Initial program 100.0%
Taylor expanded in y around 0 96.7%
if -4.2e88 < y < -3.8e14Initial program 94.0%
Taylor expanded in z around inf 70.2%
*-commutative70.2%
associate-*r*76.1%
*-commutative76.1%
sub-neg76.1%
metadata-eval76.1%
Simplified76.1%
Taylor expanded in y around inf 75.7%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.4e-23) (not (<= z 9.8e-6))) (* z (* x (+ y -1.0))) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.4e-23) || !(z <= 9.8e-6)) {
tmp = z * (x * (y + -1.0));
} 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 ((z <= (-1.4d-23)) .or. (.not. (z <= 9.8d-6))) then
tmp = z * (x * (y + (-1.0d0)))
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 ((z <= -1.4e-23) || !(z <= 9.8e-6)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.4e-23) or not (z <= 9.8e-6): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.4e-23) || !(z <= 9.8e-6)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.4e-23) || ~((z <= 9.8e-6))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.4e-23], N[Not[LessEqual[z, 9.8e-6]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-23} \lor \neg \left(z \leq 9.8 \cdot 10^{-6}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if z < -1.3999999999999999e-23 or 9.79999999999999934e-6 < z Initial program 91.0%
Taylor expanded in z around inf 88.7%
*-commutative88.7%
associate-*r*97.5%
*-commutative97.5%
sub-neg97.5%
metadata-eval97.5%
Simplified97.5%
if -1.3999999999999999e-23 < z < 9.79999999999999934e-6Initial program 100.0%
Taylor expanded in y around 0 81.1%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5) (not (<= z 0.00115))) (* z (* x (+ y -1.0))) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5) || !(z <= 0.00115)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (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 <= (-5.5d0)) .or. (.not. (z <= 0.00115d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x + (x * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5) || !(z <= 0.00115)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5) or not (z <= 0.00115): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5) || !(z <= 0.00115)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x + Float64(x * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.5) || ~((z <= 0.00115))) tmp = z * (x * (y + -1.0)); else tmp = x + (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5], N[Not[LessEqual[z, 0.00115]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \lor \neg \left(z \leq 0.00115\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -5.5 or 0.00115 < z Initial program 90.7%
Taylor expanded in z around inf 89.0%
*-commutative89.0%
associate-*r*98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
if -5.5 < z < 0.00115Initial program 99.9%
Taylor expanded in y around inf 98.7%
mul-1-neg98.7%
distribute-lft-neg-out98.7%
*-commutative98.7%
Simplified98.7%
sub-neg98.7%
distribute-rgt-neg-out98.7%
remove-double-neg98.7%
distribute-lft-in98.7%
*-commutative98.7%
*-un-lft-identity98.7%
Applied egg-rr98.7%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5) (not (<= z 0.00115))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5) || !(z <= 0.00115)) {
tmp = z * (x * (y + -1.0));
} 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 <= (-5.5d0)) .or. (.not. (z <= 0.00115d0))) then
tmp = z * (x * (y + (-1.0d0)))
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 <= -5.5) || !(z <= 0.00115)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5) or not (z <= 0.00115): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5) || !(z <= 0.00115)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); 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 <= -5.5) || ~((z <= 0.00115))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5], N[Not[LessEqual[z, 0.00115]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \lor \neg \left(z \leq 0.00115\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -5.5 or 0.00115 < z Initial program 90.7%
Taylor expanded in z around inf 89.0%
*-commutative89.0%
associate-*r*98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
if -5.5 < z < 0.00115Initial program 99.9%
Taylor expanded in y around inf 98.7%
mul-1-neg98.7%
distribute-lft-neg-out98.7%
*-commutative98.7%
Simplified98.7%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.1e-20) (not (<= z 0.00115))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.1e-20) || !(z <= 0.00115)) {
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 <= (-4.1d-20)) .or. (.not. (z <= 0.00115d0))) 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 <= -4.1e-20) || !(z <= 0.00115)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.1e-20) or not (z <= 0.00115): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.1e-20) || !(z <= 0.00115)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.1e-20) || ~((z <= 0.00115))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.1e-20], N[Not[LessEqual[z, 0.00115]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.1 \cdot 10^{-20} \lor \neg \left(z \leq 0.00115\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.1000000000000001e-20 or 0.00115 < z Initial program 90.9%
Taylor expanded in z around inf 89.2%
*-commutative89.2%
associate-*r*98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Taylor expanded in y around 0 53.8%
neg-mul-153.8%
Simplified53.8%
if -4.1000000000000001e-20 < z < 0.00115Initial program 99.9%
Taylor expanded in z around 0 79.3%
Final simplification65.7%
(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.1%
Taylor expanded in z around 0 38.9%
Final simplification38.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 2024076
(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))))