
(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 12 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) -5e+199) (* (* z x) (+ y -1.0)) (* x (+ 1.0 (- (* y z) z)))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -5e+199) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + ((y * z) - 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 (((1.0d0 - y) * z) <= (-5d+199)) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x * (1.0d0 + ((y * z) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -5e+199) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + ((y * z) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -5e+199: tmp = (z * x) * (y + -1.0) else: tmp = x * (1.0 + ((y * z) - z)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -5e+199) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x * Float64(1.0 + Float64(Float64(y * z) - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -5e+199) tmp = (z * x) * (y + -1.0); else tmp = x * (1.0 + ((y * z) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -5e+199], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(N[(y * z), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -5 \cdot 10^{+199}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + \left(y \cdot z - z\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.9999999999999998e199Initial program 78.1%
*-commutative78.1%
sub-neg78.1%
distribute-rgt-in78.1%
*-un-lft-identity78.1%
Applied egg-rr78.1%
Taylor expanded in z around inf 78.1%
mul-1-neg78.1%
*-commutative78.1%
mul-1-neg78.1%
sub-neg78.1%
*-commutative78.1%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
sub-neg99.9%
mul-1-neg99.9%
distribute-neg-in99.9%
metadata-eval99.9%
mul-1-neg99.9%
remove-double-neg99.9%
Simplified99.9%
if -4.9999999999999998e199 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 98.5%
*-commutative98.5%
sub-neg98.5%
distribute-rgt-in98.5%
*-un-lft-identity98.5%
Applied egg-rr98.5%
Taylor expanded in x around 0 98.5%
mul-1-neg98.5%
*-commutative98.5%
sub-neg98.5%
Simplified98.5%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -5e+199) (* (* z x) (+ y -1.0)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -5e+199) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + (z * (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) <= (-5d+199)) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x * (1.0d0 + (z * (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) <= -5e+199) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -5e+199: tmp = (z * x) * (y + -1.0) 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) <= -5e+199) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); 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) <= -5e+199) tmp = (z * x) * (y + -1.0); 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], -5e+199], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $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 -5 \cdot 10^{+199}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.9999999999999998e199Initial program 78.1%
*-commutative78.1%
sub-neg78.1%
distribute-rgt-in78.1%
*-un-lft-identity78.1%
Applied egg-rr78.1%
Taylor expanded in z around inf 78.1%
mul-1-neg78.1%
*-commutative78.1%
mul-1-neg78.1%
sub-neg78.1%
*-commutative78.1%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
sub-neg99.9%
mul-1-neg99.9%
distribute-neg-in99.9%
metadata-eval99.9%
mul-1-neg99.9%
remove-double-neg99.9%
Simplified99.9%
if -4.9999999999999998e199 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 98.5%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.4e-34) (not (<= z 5.5e-85))) (* z (* x (+ y -1.0))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.4e-34) || !(z <= 5.5e-85)) {
tmp = z * (x * (y + -1.0));
} 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 <= (-2.4d-34)) .or. (.not. (z <= 5.5d-85))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.4e-34) || !(z <= 5.5e-85)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.4e-34) or not (z <= 5.5e-85): tmp = z * (x * (y + -1.0)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.4e-34) || !(z <= 5.5e-85)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.4e-34) || ~((z <= 5.5e-85))) tmp = z * (x * (y + -1.0)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.4e-34], N[Not[LessEqual[z, 5.5e-85]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-34} \lor \neg \left(z \leq 5.5 \cdot 10^{-85}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.39999999999999991e-34 or 5.4999999999999997e-85 < z Initial program 91.7%
Taylor expanded in z around inf 84.2%
*-commutative84.2%
associate-*r*91.7%
*-commutative91.7%
sub-neg91.7%
metadata-eval91.7%
Simplified91.7%
if -2.39999999999999991e-34 < z < 5.4999999999999997e-85Initial program 100.0%
Taylor expanded in z around 0 84.4%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (<= z -6500.0) (* z (* x (+ y -1.0))) (if (<= z 1.0) (+ x (* x (* y z))) (* (* z x) (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6500.0) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x + (x * (y * z));
} 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 <= (-6500.0d0)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 1.0d0) then
tmp = x + (x * (y * z))
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 <= -6500.0) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x + (x * (y * z));
} else {
tmp = (z * x) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6500.0: tmp = z * (x * (y + -1.0)) elif z <= 1.0: tmp = x + (x * (y * z)) else: tmp = (z * x) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6500.0) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 1.0) tmp = Float64(x + Float64(x * Float64(y * z))); else tmp = Float64(Float64(z * x) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6500.0) tmp = z * (x * (y + -1.0)); elseif (z <= 1.0) tmp = x + (x * (y * z)); else tmp = (z * x) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6500.0], 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[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500:\\
\;\;\;\;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}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if z < -6500Initial program 92.8%
Taylor expanded in z around inf 92.5%
*-commutative92.5%
associate-*r*99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -6500 < z < 1Initial program 99.9%
Taylor expanded in y around inf 98.6%
mul-1-neg98.6%
distribute-lft-neg-out98.6%
*-commutative98.6%
Simplified98.6%
sub-neg98.6%
distribute-rgt-in98.6%
*-un-lft-identity98.6%
distribute-rgt-neg-out98.6%
remove-double-neg98.6%
Applied egg-rr98.6%
if 1 < z Initial program 86.7%
*-commutative86.7%
sub-neg86.7%
distribute-rgt-in86.7%
*-un-lft-identity86.7%
Applied egg-rr86.7%
Taylor expanded in z around inf 84.3%
mul-1-neg84.3%
*-commutative84.3%
mul-1-neg84.3%
sub-neg84.3%
*-commutative84.3%
associate-*r*97.4%
distribute-rgt-neg-in97.4%
sub-neg97.4%
mul-1-neg97.4%
distribute-neg-in97.4%
metadata-eval97.4%
mul-1-neg97.4%
remove-double-neg97.4%
Simplified97.4%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (<= z -2e-37) (* z (* x (+ y -1.0))) (if (<= z 5.5e-85) x (* (* z x) (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e-37) {
tmp = z * (x * (y + -1.0));
} else if (z <= 5.5e-85) {
tmp = x;
} 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-37)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 5.5d-85) then
tmp = x
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-37) {
tmp = z * (x * (y + -1.0));
} else if (z <= 5.5e-85) {
tmp = x;
} else {
tmp = (z * x) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e-37: tmp = z * (x * (y + -1.0)) elif z <= 5.5e-85: tmp = x else: tmp = (z * x) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e-37) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 5.5e-85) tmp = x; else tmp = Float64(Float64(z * x) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e-37) tmp = z * (x * (y + -1.0)); elseif (z <= 5.5e-85) tmp = x; else tmp = (z * x) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e-37], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.5e-85], x, N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{-37}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-85}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if z < -2.00000000000000013e-37Initial program 93.5%
Taylor expanded in z around inf 89.7%
*-commutative89.7%
associate-*r*96.1%
*-commutative96.1%
sub-neg96.1%
metadata-eval96.1%
Simplified96.1%
if -2.00000000000000013e-37 < z < 5.4999999999999997e-85Initial program 100.0%
Taylor expanded in z around 0 84.4%
if 5.4999999999999997e-85 < z Initial program 90.2%
*-commutative90.2%
sub-neg90.2%
distribute-rgt-in90.2%
*-un-lft-identity90.2%
Applied egg-rr90.2%
Taylor expanded in z around inf 79.4%
mul-1-neg79.4%
*-commutative79.4%
mul-1-neg79.4%
sub-neg79.4%
*-commutative79.4%
associate-*r*88.1%
distribute-rgt-neg-in88.1%
sub-neg88.1%
mul-1-neg88.1%
distribute-neg-in88.1%
metadata-eval88.1%
mul-1-neg88.1%
remove-double-neg88.1%
Simplified88.1%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (<= z -1.9e-36) (* z (* x (+ y -1.0))) (if (<= z 5.5e-85) x (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.9e-36) {
tmp = z * (x * (y + -1.0));
} else if (z <= 5.5e-85) {
tmp = 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 <= (-1.9d-36)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 5.5d-85) then
tmp = 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 <= -1.9e-36) {
tmp = z * (x * (y + -1.0));
} else if (z <= 5.5e-85) {
tmp = x;
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.9e-36: tmp = z * (x * (y + -1.0)) elif z <= 5.5e-85: tmp = x else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.9e-36) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 5.5e-85) tmp = 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 <= -1.9e-36) tmp = z * (x * (y + -1.0)); elseif (z <= 5.5e-85) tmp = x; else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.9e-36], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.5e-85], x, N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{-36}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 5.5 \cdot 10^{-85}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -1.89999999999999985e-36Initial program 93.5%
Taylor expanded in z around inf 89.7%
*-commutative89.7%
associate-*r*96.1%
*-commutative96.1%
sub-neg96.1%
metadata-eval96.1%
Simplified96.1%
if -1.89999999999999985e-36 < z < 5.4999999999999997e-85Initial program 100.0%
Taylor expanded in z around 0 84.4%
if 5.4999999999999997e-85 < z Initial program 90.2%
Taylor expanded in z around inf 79.4%
*-commutative79.4%
associate-*r*88.0%
*-commutative88.0%
sub-neg88.0%
metadata-eval88.0%
Simplified88.0%
distribute-lft-in88.0%
*-commutative88.0%
mul-1-neg88.0%
Applied egg-rr88.0%
Taylor expanded in z around 0 88.0%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -34000.0) (not (<= y 3.8e+28))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -34000.0) || !(y <= 3.8e+28)) {
tmp = z * (y * 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 <= (-34000.0d0)) .or. (.not. (y <= 3.8d+28))) then
tmp = z * (y * 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 <= -34000.0) || !(y <= 3.8e+28)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -34000.0) or not (y <= 3.8e+28): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -34000.0) || !(y <= 3.8e+28)) tmp = Float64(z * Float64(y * 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 <= -34000.0) || ~((y <= 3.8e+28))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -34000.0], N[Not[LessEqual[y, 3.8e+28]], $MachinePrecision]], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -34000 \lor \neg \left(y \leq 3.8 \cdot 10^{+28}\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -34000 or 3.7999999999999999e28 < y Initial program 90.3%
Taylor expanded in z around inf 72.4%
*-commutative72.4%
associate-*r*79.9%
*-commutative79.9%
sub-neg79.9%
metadata-eval79.9%
Simplified79.9%
Taylor expanded in y around inf 79.2%
if -34000 < y < 3.7999999999999999e28Initial program 100.0%
Taylor expanded in y around 0 97.7%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -34000.0) (not (<= y 9e+28))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -34000.0) || !(y <= 9e+28)) {
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 <= (-34000.0d0)) .or. (.not. (y <= 9d+28))) 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 <= -34000.0) || !(y <= 9e+28)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -34000.0) or not (y <= 9e+28): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -34000.0) || !(y <= 9e+28)) 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 <= -34000.0) || ~((y <= 9e+28))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -34000.0], N[Not[LessEqual[y, 9e+28]], $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 -34000 \lor \neg \left(y \leq 9 \cdot 10^{+28}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -34000 or 8.9999999999999994e28 < y Initial program 90.3%
Taylor expanded in y around inf 71.8%
*-commutative71.8%
Simplified71.8%
if -34000 < y < 8.9999999999999994e28Initial program 100.0%
Taylor expanded in y around 0 97.7%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.8e-35) (not (<= z 5.5e-85))) (* x (* y z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e-35) || !(z <= 5.5e-85)) {
tmp = x * (y * 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.8d-35)) .or. (.not. (z <= 5.5d-85))) then
tmp = x * (y * 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.8e-35) || !(z <= 5.5e-85)) {
tmp = x * (y * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.8e-35) or not (z <= 5.5e-85): tmp = x * (y * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.8e-35) || !(z <= 5.5e-85)) tmp = Float64(x * Float64(y * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.8e-35) || ~((z <= 5.5e-85))) tmp = x * (y * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e-35], N[Not[LessEqual[z, 5.5e-85]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{-35} \lor \neg \left(z \leq 5.5 \cdot 10^{-85}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.8000000000000003e-35 or 5.4999999999999997e-85 < z Initial program 91.7%
Taylor expanded in y around inf 56.5%
*-commutative56.5%
Simplified56.5%
if -4.8000000000000003e-35 < z < 5.4999999999999997e-85Initial program 100.0%
Taylor expanded in z around 0 84.4%
Final simplification66.6%
(FPCore (x y z) :precision binary64 (if (<= y -34000.0) (* y (* z x)) (if (<= y 3.5e+28) (* x (- 1.0 z)) (* z (* y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -34000.0) {
tmp = y * (z * x);
} else if (y <= 3.5e+28) {
tmp = x * (1.0 - z);
} else {
tmp = z * (y * 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 <= (-34000.0d0)) then
tmp = y * (z * x)
else if (y <= 3.5d+28) then
tmp = x * (1.0d0 - z)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -34000.0) {
tmp = y * (z * x);
} else if (y <= 3.5e+28) {
tmp = x * (1.0 - z);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -34000.0: tmp = y * (z * x) elif y <= 3.5e+28: tmp = x * (1.0 - z) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -34000.0) tmp = Float64(y * Float64(z * x)); elseif (y <= 3.5e+28) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -34000.0) tmp = y * (z * x); elseif (y <= 3.5e+28) tmp = x * (1.0 - z); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -34000.0], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.5e+28], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -34000:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+28}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -34000Initial program 89.5%
Taylor expanded in z around inf 75.1%
*-commutative75.1%
associate-*r*81.6%
*-commutative81.6%
sub-neg81.6%
metadata-eval81.6%
Simplified81.6%
associate-*r*82.3%
*-commutative82.3%
+-commutative82.3%
flip3-+32.3%
associate-*r/25.9%
metadata-eval25.9%
metadata-eval25.9%
cancel-sign-sub-inv25.9%
pow225.9%
metadata-eval25.9%
*-un-lft-identity25.9%
Applied egg-rr25.9%
associate-+r+25.9%
+-commutative25.9%
remove-double-neg25.9%
sub-neg25.9%
associate-+r-25.9%
unpow225.9%
fma-undefine26.0%
associate-/l*32.4%
fma-undefine32.3%
unpow232.3%
associate-+r-32.3%
sub-neg32.3%
+-commutative32.3%
remove-double-neg32.3%
associate-+r+32.3%
unpow232.3%
fma-define32.4%
Simplified32.4%
Taylor expanded in y around inf 81.1%
if -34000 < y < 3.5e28Initial program 100.0%
Taylor expanded in y around 0 97.7%
if 3.5e28 < y Initial program 91.2%
Taylor expanded in z around inf 69.4%
*-commutative69.4%
associate-*r*78.0%
*-commutative78.0%
sub-neg78.0%
metadata-eval78.0%
Simplified78.0%
Taylor expanded in y around inf 78.0%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.175) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.175) || !(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 <= (-0.175d0)) .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 <= -0.175) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.175) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.175) || !(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 <= -0.175) || ~((z <= 1.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.175], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.175 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.17499999999999999 or 1 < z Initial program 90.0%
Taylor expanded in z around inf 88.6%
*-commutative88.6%
associate-*r*98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
Simplified98.5%
Taylor expanded in y around 0 43.7%
associate-*r*43.7%
neg-mul-143.7%
*-commutative43.7%
Simplified43.7%
if -0.17499999999999999 < z < 1Initial program 99.9%
Taylor expanded in z around 0 72.1%
Final simplification57.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 94.7%
Taylor expanded in z around 0 35.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 2024091
(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))))