
(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) -2e+110) (* (* z x) (+ y -1.0)) (+ x (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -2e+110) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (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) <= (-2d+110)) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x + (x * (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) <= -2e+110) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -2e+110: tmp = (z * x) * (y + -1.0) else: tmp = x + (x * (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -2e+110) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x + Float64(x * 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) <= -2e+110) tmp = (z * x) * (y + -1.0); else tmp = x + (x * (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -2e+110], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * 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 -2 \cdot 10^{+110}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -2e110Initial program 87.5%
Taylor expanded in z around inf 87.5%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in90.0%
metadata-eval90.0%
Applied egg-rr90.0%
distribute-lft-out99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -2e110 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 98.4%
Taylor expanded in z around 0 98.5%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
(if (<= z -4.2e+39)
t_0
(if (<= z -9.5e-81)
t_1
(if (<= z 0.095) x (if (<= z 1.36e+107) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -4.2e+39) {
tmp = t_0;
} else if (z <= -9.5e-81) {
tmp = t_1;
} else if (z <= 0.095) {
tmp = x;
} else if (z <= 1.36e+107) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = x * (y * z)
if (z <= (-4.2d+39)) then
tmp = t_0
else if (z <= (-9.5d-81)) then
tmp = t_1
else if (z <= 0.095d0) then
tmp = x
else if (z <= 1.36d+107) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -4.2e+39) {
tmp = t_0;
} else if (z <= -9.5e-81) {
tmp = t_1;
} else if (z <= 0.095) {
tmp = x;
} else if (z <= 1.36e+107) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (y * z) tmp = 0 if z <= -4.2e+39: tmp = t_0 elif z <= -9.5e-81: tmp = t_1 elif z <= 0.095: tmp = x elif z <= 1.36e+107: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -4.2e+39) tmp = t_0; elseif (z <= -9.5e-81) tmp = t_1; elseif (z <= 0.095) tmp = x; elseif (z <= 1.36e+107) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (y * z); tmp = 0.0; if (z <= -4.2e+39) tmp = t_0; elseif (z <= -9.5e-81) tmp = t_1; elseif (z <= 0.095) tmp = x; elseif (z <= 1.36e+107) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+39], t$95$0, If[LessEqual[z, -9.5e-81], t$95$1, If[LessEqual[z, 0.095], x, If[LessEqual[z, 1.36e+107], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-81}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 0.095:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.36 \cdot 10^{+107}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.1999999999999997e39 or 1.35999999999999998e107 < z Initial program 91.0%
Taylor expanded in z around inf 91.0%
Taylor expanded in y around 0 67.4%
mul-1-neg67.4%
distribute-rgt-neg-out67.4%
Simplified67.4%
if -4.1999999999999997e39 < z < -9.49999999999999917e-81 or 0.095000000000000001 < z < 1.35999999999999998e107Initial program 97.3%
Taylor expanded in y around inf 73.4%
*-commutative73.4%
Simplified73.4%
if -9.49999999999999917e-81 < z < 0.095000000000000001Initial program 99.9%
Taylor expanded in z around 0 75.4%
Final simplification71.8%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -2e+110) (* (* 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) <= -2e+110) {
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) <= (-2d+110)) 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) <= -2e+110) {
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) <= -2e+110: 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) <= -2e+110) 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) <= -2e+110) 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], -2e+110], 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 -2 \cdot 10^{+110}:\\
\;\;\;\;\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) < -2e110Initial program 87.5%
Taylor expanded in z around inf 87.5%
associate-*r*99.9%
sub-neg99.9%
distribute-lft-in90.0%
metadata-eval90.0%
Applied egg-rr90.0%
distribute-lft-out99.9%
*-commutative99.9%
Applied egg-rr99.9%
if -2e110 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 98.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -3600000000.0) (not (<= z 1.0))) (* (* z x) (+ y -1.0)) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3600000000.0) || !(z <= 1.0)) {
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 <= (-3600000000.0d0)) .or. (.not. (z <= 1.0d0))) 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 <= -3600000000.0) || !(z <= 1.0)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3600000000.0) or not (z <= 1.0): tmp = (z * x) * (y + -1.0) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3600000000.0) || !(z <= 1.0)) tmp = Float64(Float64(z * 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 <= -3600000000.0) || ~((z <= 1.0))) 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, -3600000000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3600000000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -3.6e9 or 1 < z Initial program 92.2%
Taylor expanded in z around inf 92.1%
associate-*r*99.8%
sub-neg99.8%
distribute-lft-in83.4%
metadata-eval83.4%
Applied egg-rr83.4%
distribute-lft-out99.8%
*-commutative99.8%
Applied egg-rr99.8%
if -3.6e9 < z < 1Initial program 99.8%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 97.6%
*-commutative97.6%
Simplified97.6%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.00021) (not (<= z 0.9))) (* (* z x) (+ y -1.0)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.00021) || !(z <= 0.9)) {
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 <= (-0.00021d0)) .or. (.not. (z <= 0.9d0))) 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 <= -0.00021) || !(z <= 0.9)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.00021) or not (z <= 0.9): tmp = (z * x) * (y + -1.0) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.00021) || !(z <= 0.9)) tmp = Float64(Float64(z * 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 <= -0.00021) || ~((z <= 0.9))) tmp = (z * x) * (y + -1.0); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.00021], N[Not[LessEqual[z, 0.9]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00021 \lor \neg \left(z \leq 0.9\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -2.1000000000000001e-4 or 0.900000000000000022 < z Initial program 92.4%
Taylor expanded in z around inf 92.2%
associate-*r*99.8%
sub-neg99.8%
distribute-lft-in83.7%
metadata-eval83.7%
Applied egg-rr83.7%
distribute-lft-out99.8%
*-commutative99.8%
Applied egg-rr99.8%
if -2.1000000000000001e-4 < z < 0.900000000000000022Initial program 99.8%
Taylor expanded in y around 0 75.1%
sub-neg75.1%
distribute-rgt-in75.1%
*-un-lft-identity75.1%
Applied egg-rr75.1%
*-commutative75.1%
distribute-rgt-neg-out75.1%
unsub-neg75.1%
Applied egg-rr75.1%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e+111) (not (<= y 72000000000000.0))) (* z (* y x)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+111) || !(y <= 72000000000000.0)) {
tmp = z * (y * x);
} else {
tmp = x - (z * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.2d+111)) .or. (.not. (y <= 72000000000000.0d0))) then
tmp = z * (y * x)
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+111) || !(y <= 72000000000000.0)) {
tmp = z * (y * x);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e+111) or not (y <= 72000000000000.0): tmp = z * (y * x) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e+111) || !(y <= 72000000000000.0)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.2e+111) || ~((y <= 72000000000000.0))) tmp = z * (y * x); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e+111], N[Not[LessEqual[y, 72000000000000.0]], $MachinePrecision]], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+111} \lor \neg \left(y \leq 72000000000000\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -1.20000000000000003e111 or 7.2e13 < y Initial program 90.3%
Taylor expanded in y around inf 72.9%
associate-*r*78.0%
Simplified78.0%
if -1.20000000000000003e111 < y < 7.2e13Initial program 99.3%
Taylor expanded in y around 0 93.5%
sub-neg93.5%
distribute-rgt-in93.5%
*-un-lft-identity93.5%
Applied egg-rr93.5%
*-commutative93.5%
distribute-rgt-neg-out93.5%
unsub-neg93.5%
Applied egg-rr93.5%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e+110) (not (<= y 1.04e+14))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+110) || !(y <= 1.04e+14)) {
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 <= (-3.4d+110)) .or. (.not. (y <= 1.04d+14))) 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 <= -3.4e+110) || !(y <= 1.04e+14)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+110) or not (y <= 1.04e+14): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+110) || !(y <= 1.04e+14)) 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 <= -3.4e+110) || ~((y <= 1.04e+14))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+110], N[Not[LessEqual[y, 1.04e+14]], $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 -3.4 \cdot 10^{+110} \lor \neg \left(y \leq 1.04 \cdot 10^{+14}\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.4000000000000001e110 or 1.04e14 < y Initial program 90.3%
Taylor expanded in y around inf 72.9%
associate-*r*78.0%
Simplified78.0%
if -3.4000000000000001e110 < y < 1.04e14Initial program 99.3%
Taylor expanded in y around 0 93.5%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.5e+110) (not (<= y 1.7e+15))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.5e+110) || !(y <= 1.7e+15)) {
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 <= (-3.5d+110)) .or. (.not. (y <= 1.7d+15))) 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 <= -3.5e+110) || !(y <= 1.7e+15)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.5e+110) or not (y <= 1.7e+15): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.5e+110) || !(y <= 1.7e+15)) 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 <= -3.5e+110) || ~((y <= 1.7e+15))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.5e+110], N[Not[LessEqual[y, 1.7e+15]], $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 -3.5 \cdot 10^{+110} \lor \neg \left(y \leq 1.7 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.4999999999999999e110 or 1.7e15 < y Initial program 90.3%
Taylor expanded in y around inf 72.9%
*-commutative72.9%
Simplified72.9%
if -3.4999999999999999e110 < y < 1.7e15Initial program 99.3%
Taylor expanded in y around 0 93.5%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= y -4e+110) (* y (* z x)) (if (<= y 3.6e+14) (* x (- 1.0 z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+110) {
tmp = y * (z * x);
} else if (y <= 3.6e+14) {
tmp = x * (1.0 - 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 <= (-4d+110)) then
tmp = y * (z * x)
else if (y <= 3.6d+14) then
tmp = x * (1.0d0 - 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 <= -4e+110) {
tmp = y * (z * x);
} else if (y <= 3.6e+14) {
tmp = x * (1.0 - z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+110: tmp = y * (z * x) elif y <= 3.6e+14: tmp = x * (1.0 - z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+110) tmp = Float64(y * Float64(z * x)); elseif (y <= 3.6e+14) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+110) tmp = y * (z * x); elseif (y <= 3.6e+14) tmp = x * (1.0 - z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+110], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e+14], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+110}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+14}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -4.0000000000000001e110Initial program 84.2%
Taylor expanded in y around inf 86.8%
+-commutative86.8%
associate-/l*86.8%
distribute-lft-out86.8%
Simplified86.8%
Taylor expanded in y around inf 82.5%
if -4.0000000000000001e110 < y < 3.6e14Initial program 99.3%
Taylor expanded in y around 0 93.5%
if 3.6e14 < y Initial program 93.7%
Taylor expanded in y around inf 73.4%
*-commutative73.4%
Simplified73.4%
Final simplification87.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(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.0d0)) .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.0) || !(z <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(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.0) || ~((z <= 1.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 92.3%
Taylor expanded in z around inf 92.2%
Taylor expanded in y around 0 57.1%
mul-1-neg57.1%
distribute-rgt-neg-out57.1%
Simplified57.1%
if -1 < z < 1Initial program 99.8%
Taylor expanded in z around 0 72.2%
Final simplification64.1%
(FPCore (x y z) :precision binary64 (if (<= z -6.2e+109) (* z x) x))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.2e+109) {
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 <= (-6.2d+109)) 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 <= -6.2e+109) {
tmp = z * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.2e+109: tmp = z * x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.2e+109) tmp = Float64(z * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.2e+109) tmp = z * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.2e+109], N[(z * x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+109}:\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.19999999999999985e109Initial program 93.8%
Taylor expanded in z around inf 93.8%
Taylor expanded in y around 0 61.8%
mul-1-neg61.8%
distribute-rgt-neg-out61.8%
Simplified61.8%
neg-sub061.8%
sub-neg61.8%
add-sqr-sqrt61.6%
sqrt-unprod41.1%
sqr-neg41.1%
sqrt-unprod0.0%
add-sqr-sqrt21.2%
Applied egg-rr21.2%
+-lft-identity21.2%
Simplified21.2%
if -6.19999999999999985e109 < z Initial program 96.3%
Taylor expanded in z around 0 42.3%
Final simplification38.6%
(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.8%
Taylor expanded in z around 0 35.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t\_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024137
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(! :herbie-platform default (if (< (* x (- 1 (* (- 1 y) z))) -161819597360704900000000000000000000000000000000000) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 389223764966390300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x))))))
(* x (- 1.0 (* (- 1.0 y) z))))