
(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 9 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 (or (<= z -1.2) (not (<= z 0.000125))) (* (+ y -1.0) (* x z)) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.2) || !(z <= 0.000125)) {
tmp = (y + -1.0) * (x * z);
} 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 <= (-1.2d0)) .or. (.not. (z <= 0.000125d0))) then
tmp = (y + (-1.0d0)) * (x * z)
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 <= -1.2) || !(z <= 0.000125)) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.2) or not (z <= 0.000125): tmp = (y + -1.0) * (x * z) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.2) || !(z <= 0.000125)) tmp = Float64(Float64(y + -1.0) * Float64(x * z)); 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 <= -1.2) || ~((z <= 0.000125))) tmp = (y + -1.0) * (x * z); else tmp = x + (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.2], N[Not[LessEqual[z, 0.000125]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.2 \lor \neg \left(z \leq 0.000125\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.19999999999999996 or 1.25e-4 < z Initial program 93.3%
Taylor expanded in z around inf 99.2%
*-commutative99.2%
associate-*l*99.1%
sub-neg99.1%
metadata-eval99.1%
*-commutative99.1%
Simplified99.1%
if -1.19999999999999996 < z < 1.25e-4Initial program 99.9%
sub-neg99.9%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
distribute-rgt-neg-in100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 99.3%
*-commutative99.3%
Simplified99.3%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (fma (+ y -1.0) (* x z) x))
double code(double x, double y, double z) {
return fma((y + -1.0), (x * z), x);
}
function code(x, y, z) return fma(Float64(y + -1.0), Float64(x * z), x) end
code[x_, y_, z_] := N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y + -1, x \cdot z, x\right)
\end{array}
Initial program 96.7%
distribute-rgt-out--96.7%
*-lft-identity96.7%
cancel-sign-sub-inv96.7%
+-commutative96.7%
distribute-lft-neg-in96.7%
associate-*l*98.4%
fma-def98.4%
neg-sub098.4%
associate--r-98.4%
metadata-eval98.4%
+-commutative98.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.2e-66) (not (<= z 0.000125))) (* (+ y -1.0) (* x z)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e-66) || !(z <= 0.000125)) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x - (x * 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 <= (-8.2d-66)) .or. (.not. (z <= 0.000125d0))) then
tmp = (y + (-1.0d0)) * (x * z)
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.2e-66) || !(z <= 0.000125)) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.2e-66) or not (z <= 0.000125): tmp = (y + -1.0) * (x * z) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.2e-66) || !(z <= 0.000125)) tmp = Float64(Float64(y + -1.0) * Float64(x * z)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.2e-66) || ~((z <= 0.000125))) tmp = (y + -1.0) * (x * z); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.2e-66], N[Not[LessEqual[z, 0.000125]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{-66} \lor \neg \left(z \leq 0.000125\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if z < -8.19999999999999996e-66 or 1.25e-4 < z Initial program 93.6%
Taylor expanded in z around inf 97.8%
*-commutative97.8%
associate-*l*97.8%
sub-neg97.8%
metadata-eval97.8%
*-commutative97.8%
Simplified97.8%
if -8.19999999999999996e-66 < z < 1.25e-4Initial program 99.9%
Taylor expanded in y around 0 81.7%
*-commutative81.7%
distribute-rgt-out--81.7%
*-lft-identity81.7%
Simplified81.7%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= z -1.1e-65) (- x (* z (* x (- 1.0 y)))) (- x (* x (* z (- 1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e-65) {
tmp = x - (z * (x * (1.0 - y)));
} else {
tmp = x - (x * (z * (1.0 - 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.1d-65)) then
tmp = x - (z * (x * (1.0d0 - y)))
else
tmp = x - (x * (z * (1.0d0 - y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e-65) {
tmp = x - (z * (x * (1.0 - y)));
} else {
tmp = x - (x * (z * (1.0 - y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e-65: tmp = x - (z * (x * (1.0 - y))) else: tmp = x - (x * (z * (1.0 - y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e-65) tmp = Float64(x - Float64(z * Float64(x * Float64(1.0 - y)))); else tmp = Float64(x - Float64(x * Float64(z * Float64(1.0 - y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e-65) tmp = x - (z * (x * (1.0 - y))); else tmp = x - (x * (z * (1.0 - y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e-65], N[(x - N[(z * N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{-65}:\\
\;\;\;\;x - z \cdot \left(x \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot \left(z \cdot \left(1 - y\right)\right)\\
\end{array}
\end{array}
if z < -1.10000000000000011e-65Initial program 92.4%
distribute-rgt-out--92.4%
*-lft-identity92.4%
cancel-sign-sub-inv92.4%
+-commutative92.4%
distribute-lft-neg-in92.4%
associate-*l*99.9%
fma-def99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
*-commutative99.9%
Simplified99.9%
fma-udef99.9%
associate-*r*99.9%
Applied egg-rr99.9%
if -1.10000000000000011e-65 < z Initial program 98.4%
sub-neg98.4%
distribute-rgt-in98.4%
*-un-lft-identity98.4%
distribute-rgt-neg-in98.4%
Applied egg-rr98.4%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z -5e+113) (* (+ y -1.0) (* x z)) (* x (+ 1.0 (* (+ y -1.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e+113) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x * (1.0 + ((y + -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 <= (-5d+113)) then
tmp = (y + (-1.0d0)) * (x * z)
else
tmp = x * (1.0d0 + ((y + (-1.0d0)) * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5e+113) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x * (1.0 + ((y + -1.0) * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e+113: tmp = (y + -1.0) * (x * z) else: tmp = x * (1.0 + ((y + -1.0) * z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e+113) tmp = Float64(Float64(y + -1.0) * Float64(x * z)); else tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e+113) tmp = (y + -1.0) * (x * z); else tmp = x * (1.0 + ((y + -1.0) * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e+113], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $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}\;z \leq -5 \cdot 10^{+113}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\end{array}
\end{array}
if z < -5e113Initial program 89.8%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
associate-*l*99.9%
sub-neg99.9%
metadata-eval99.9%
*-commutative99.9%
Simplified99.9%
if -5e113 < z Initial program 98.5%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= z -9.2e-66) (- x (* z (* x (- 1.0 y)))) (* x (+ 1.0 (* (+ y -1.0) z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.2e-66) {
tmp = x - (z * (x * (1.0 - y)));
} else {
tmp = x * (1.0 + ((y + -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 <= (-9.2d-66)) then
tmp = x - (z * (x * (1.0d0 - y)))
else
tmp = x * (1.0d0 + ((y + (-1.0d0)) * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.2e-66) {
tmp = x - (z * (x * (1.0 - y)));
} else {
tmp = x * (1.0 + ((y + -1.0) * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.2e-66: tmp = x - (z * (x * (1.0 - y))) else: tmp = x * (1.0 + ((y + -1.0) * z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.2e-66) tmp = Float64(x - Float64(z * Float64(x * Float64(1.0 - y)))); else tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.2e-66) tmp = x - (z * (x * (1.0 - y))); else tmp = x * (1.0 + ((y + -1.0) * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.2e-66], N[(x - N[(z * N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $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}\;z \leq -9.2 \cdot 10^{-66}:\\
\;\;\;\;x - z \cdot \left(x \cdot \left(1 - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\end{array}
\end{array}
if z < -9.19999999999999967e-66Initial program 92.4%
distribute-rgt-out--92.4%
*-lft-identity92.4%
cancel-sign-sub-inv92.4%
+-commutative92.4%
distribute-lft-neg-in92.4%
associate-*l*99.9%
fma-def99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
*-commutative99.9%
Simplified99.9%
fma-udef99.9%
associate-*r*99.9%
Applied egg-rr99.9%
if -9.19999999999999967e-66 < z Initial program 98.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05e-65) (not (<= z 9.2e-13))) (* y (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05e-65) || !(z <= 9.2e-13)) {
tmp = y * (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.05d-65)) .or. (.not. (z <= 9.2d-13))) then
tmp = y * (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.05e-65) || !(z <= 9.2e-13)) {
tmp = y * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05e-65) or not (z <= 9.2e-13): tmp = y * (x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05e-65) || !(z <= 9.2e-13)) tmp = Float64(y * Float64(x * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05e-65) || ~((z <= 9.2e-13))) tmp = y * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05e-65], N[Not[LessEqual[z, 9.2e-13]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \cdot 10^{-65} \lor \neg \left(z \leq 9.2 \cdot 10^{-13}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.05000000000000001e-65 or 9.19999999999999917e-13 < z Initial program 93.7%
Taylor expanded in y around inf 64.7%
if -1.05000000000000001e-65 < z < 9.19999999999999917e-13Initial program 99.9%
Taylor expanded in z around 0 82.0%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.8e+106) (* y (* x z)) (if (<= y 4.8e+28) (- x (* x z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+106) {
tmp = y * (x * z);
} else if (y <= 4.8e+28) {
tmp = x - (x * z);
} else {
tmp = 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 (y <= (-5.8d+106)) then
tmp = y * (x * z)
else if (y <= 4.8d+28) then
tmp = x - (x * z)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+106) {
tmp = y * (x * z);
} else if (y <= 4.8e+28) {
tmp = x - (x * z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+106: tmp = y * (x * z) elif y <= 4.8e+28: tmp = x - (x * z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+106) tmp = Float64(y * Float64(x * z)); elseif (y <= 4.8e+28) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.8e+106) tmp = y * (x * z); elseif (y <= 4.8e+28) tmp = x - (x * z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+106], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+28], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+106}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+28}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -5.8000000000000004e106Initial program 89.3%
Taylor expanded in y around inf 80.6%
if -5.8000000000000004e106 < y < 4.79999999999999962e28Initial program 99.3%
Taylor expanded in y around 0 95.6%
*-commutative95.6%
distribute-rgt-out--95.6%
*-lft-identity95.6%
Simplified95.6%
if 4.79999999999999962e28 < y Initial program 96.9%
distribute-rgt-out--96.9%
*-lft-identity96.9%
cancel-sign-sub-inv96.9%
+-commutative96.9%
distribute-lft-neg-in96.9%
associate-*l*96.2%
fma-def96.2%
neg-sub096.2%
associate--r-96.2%
metadata-eval96.2%
+-commutative96.2%
*-commutative96.2%
Simplified96.2%
fma-udef96.2%
flip-+32.0%
associate-*r*28.9%
associate-*r*28.8%
associate-*r*28.8%
Applied egg-rr28.8%
Simplified96.9%
Taylor expanded in y around inf 70.9%
associate-/r/70.8%
/-rgt-identity70.8%
*-commutative70.8%
Applied egg-rr70.8%
Final simplification86.5%
(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 96.7%
Taylor expanded in z around 0 41.2%
Final simplification41.2%
(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 2023242
(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))))