
(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
(let* ((t_0 (* (- 1.0 y) z)))
(if (<= t_0 (- INFINITY))
(* z (* y x))
(if (<= t_0 1e+109)
(* x (+ 1.0 (/ z (/ 1.0 (+ y -1.0)))))
(* z (* x (+ y -1.0)))))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = z * (y * x);
} else if (t_0 <= 1e+109) {
tmp = x * (1.0 + (z / (1.0 / (y + -1.0))));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = z * (y * x);
} else if (t_0 <= 1e+109) {
tmp = x * (1.0 + (z / (1.0 / (y + -1.0))));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z tmp = 0 if t_0 <= -math.inf: tmp = z * (y * x) elif t_0 <= 1e+109: tmp = x * (1.0 + (z / (1.0 / (y + -1.0)))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(z * Float64(y * x)); elseif (t_0 <= 1e+109) tmp = Float64(x * Float64(1.0 + Float64(z / Float64(1.0 / 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) t_0 = (1.0 - y) * z; tmp = 0.0; if (t_0 <= -Inf) tmp = z * (y * x); elseif (t_0 <= 1e+109) tmp = x * (1.0 + (z / (1.0 / (y + -1.0)))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+109], N[(x * N[(1.0 + N[(z / N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;t\_0 \leq 10^{+109}:\\
\;\;\;\;x \cdot \left(1 + \frac{z}{\frac{1}{y + -1}}\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) < -inf.0Initial program 69.9%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6469.9%
Applied egg-rr69.9%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64100.0%
Simplified100.0%
if -inf.0 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999982e108Initial program 99.9%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
if 9.99999999999999982e108 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 91.4%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6491.3%
Applied egg-rr91.3%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6499.9%
Simplified99.9%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- 1.0 y) z)) (t_1 (* z (* x (+ y -1.0)))))
(if (<= t_0 -5e+110)
t_1
(if (<= t_0 1e+109) (* x (+ 1.0 (* z (+ y -1.0)))) t_1))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double t_1 = z * (x * (y + -1.0));
double tmp;
if (t_0 <= -5e+110) {
tmp = t_1;
} else if (t_0 <= 1e+109) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (1.0d0 - y) * z
t_1 = z * (x * (y + (-1.0d0)))
if (t_0 <= (-5d+110)) then
tmp = t_1
else if (t_0 <= 1d+109) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double t_1 = z * (x * (y + -1.0));
double tmp;
if (t_0 <= -5e+110) {
tmp = t_1;
} else if (t_0 <= 1e+109) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z t_1 = z * (x * (y + -1.0)) tmp = 0 if t_0 <= -5e+110: tmp = t_1 elif t_0 <= 1e+109: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) t_1 = Float64(z * Float64(x * Float64(y + -1.0))) tmp = 0.0 if (t_0 <= -5e+110) tmp = t_1; elseif (t_0 <= 1e+109) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 - y) * z; t_1 = z * (x * (y + -1.0)); tmp = 0.0; if (t_0 <= -5e+110) tmp = t_1; elseif (t_0 <= 1e+109) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+110], t$95$1, If[LessEqual[t$95$0, 1e+109], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
t_1 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+110}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{+109}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -4.99999999999999978e110 or 9.99999999999999982e108 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 90.5%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6490.5%
Applied egg-rr90.5%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6499.9%
Simplified99.9%
if -4.99999999999999978e110 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999982e108Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (* x (+ y -1.0))))) (if (<= z -1.0) t_0 (if (<= z 1.0) (* x (+ 1.0 (* y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = z * (x * (y + -1.0));
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} 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) :: tmp
t_0 = z * (x * (y + (-1.0d0)))
if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (y * z))
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 * (y + -1.0));
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (x * (y + -1.0)) tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 1.0: tmp = x * (1.0 + (y * z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(x * Float64(y + -1.0))) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (x * (y + -1.0)); tmp = 0.0; if (z <= -1.0) tmp = t_0; elseif (z <= 1.0) tmp = x * (1.0 + (y * z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 91.4%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6491.4%
Applied egg-rr91.4%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6498.0%
Simplified98.0%
if -1 < z < 1Initial program 99.9%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
Taylor expanded in y around inf
*-lowering-*.f64N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6478.5%
Simplified78.5%
Taylor expanded in z around 0
/-lowering-/.f6478.5%
Simplified78.5%
Taylor expanded in y around 0
*-rgt-identityN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f6499.5%
Simplified99.5%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (+ 1.0 (* y z))))) (if (<= y -3.25) t_0 (if (<= y 2.8e-7) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 + (y * z));
double tmp;
if (y <= -3.25) {
tmp = t_0;
} else if (y <= 2.8e-7) {
tmp = x * (1.0 - z);
} 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) :: tmp
t_0 = x * (1.0d0 + (y * z))
if (y <= (-3.25d0)) then
tmp = t_0
else if (y <= 2.8d-7) then
tmp = x * (1.0d0 - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + (y * z));
double tmp;
if (y <= -3.25) {
tmp = t_0;
} else if (y <= 2.8e-7) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 + (y * z)) tmp = 0 if y <= -3.25: tmp = t_0 elif y <= 2.8e-7: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(y * z))) tmp = 0.0 if (y <= -3.25) tmp = t_0; elseif (y <= 2.8e-7) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 + (y * z)); tmp = 0.0; if (y <= -3.25) tmp = t_0; elseif (y <= 2.8e-7) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.25], t$95$0, If[LessEqual[y, 2.8e-7], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 + y \cdot z\right)\\
\mathbf{if}\;y \leq -3.25:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-7}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.25 or 2.80000000000000019e-7 < y Initial program 90.3%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6490.3%
Applied egg-rr90.3%
Taylor expanded in y around inf
*-lowering-*.f64N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
--lowering--.f6489.6%
Simplified89.6%
Taylor expanded in z around 0
/-lowering-/.f6488.4%
Simplified88.4%
Taylor expanded in y around 0
*-rgt-identityN/A
distribute-lft-inN/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
*-lowering-*.f6489.1%
Simplified89.1%
if -3.25 < y < 2.80000000000000019e-7Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6499.3%
Simplified99.3%
Final simplification94.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.5e+86) (* y (* z x)) (if (<= y 270.0) (* x (- 1.0 z)) (* z (* y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+86) {
tmp = y * (z * x);
} else if (y <= 270.0) {
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 <= (-1.5d+86)) then
tmp = y * (z * x)
else if (y <= 270.0d0) 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 <= -1.5e+86) {
tmp = y * (z * x);
} else if (y <= 270.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.5e+86: tmp = y * (z * x) elif y <= 270.0: tmp = x * (1.0 - z) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.5e+86) tmp = Float64(y * Float64(z * x)); elseif (y <= 270.0) 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 <= -1.5e+86) tmp = y * (z * x); elseif (y <= 270.0) tmp = x * (1.0 - z); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.5e+86], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 270.0], 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 -1.5 \cdot 10^{+86}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 270:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -1.49999999999999988e86Initial program 88.0%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6471.1%
Simplified71.1%
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f6481.3%
Applied egg-rr81.3%
if -1.49999999999999988e86 < y < 270Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6495.1%
Simplified95.1%
if 270 < y Initial program 88.8%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6488.8%
Applied egg-rr88.8%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6476.5%
Simplified76.5%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (* y x)))) (if (<= y -8.2e+85) t_0 (if (<= y 1.8) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * (y * x);
double tmp;
if (y <= -8.2e+85) {
tmp = t_0;
} else if (y <= 1.8) {
tmp = x * (1.0 - z);
} 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) :: tmp
t_0 = z * (y * x)
if (y <= (-8.2d+85)) then
tmp = t_0
else if (y <= 1.8d0) then
tmp = x * (1.0d0 - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y * x);
double tmp;
if (y <= -8.2e+85) {
tmp = t_0;
} else if (y <= 1.8) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y * x) tmp = 0 if y <= -8.2e+85: tmp = t_0 elif y <= 1.8: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y * x)) tmp = 0.0 if (y <= -8.2e+85) tmp = t_0; elseif (y <= 1.8) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y * x); tmp = 0.0; if (y <= -8.2e+85) tmp = t_0; elseif (y <= 1.8) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.2e+85], t$95$0, If[LessEqual[y, 1.8], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y \cdot x\right)\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.8:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.19999999999999957e85 or 1.80000000000000004 < y Initial program 88.4%
*-commutativeN/A
flip--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip--N/A
/-lowering-/.f64N/A
--lowering--.f6488.4%
Applied egg-rr88.4%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6479.0%
Simplified79.0%
if -8.19999999999999957e85 < y < 1.80000000000000004Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6495.1%
Simplified95.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= y -5.8e+85) t_0 (if (<= y 2.0) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -5.8e+85) {
tmp = t_0;
} else if (y <= 2.0) {
tmp = x * (1.0 - z);
} 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) :: tmp
t_0 = x * (y * z)
if (y <= (-5.8d+85)) then
tmp = t_0
else if (y <= 2.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -5.8e+85) {
tmp = t_0;
} else if (y <= 2.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if y <= -5.8e+85: tmp = t_0 elif y <= 2.0: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (y <= -5.8e+85) tmp = t_0; elseif (y <= 2.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * z); tmp = 0.0; if (y <= -5.8e+85) tmp = t_0; elseif (y <= 2.0) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.8e+85], t$95$0, If[LessEqual[y, 2.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.79999999999999995e85 or 2 < y Initial program 88.4%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6469.2%
Simplified69.2%
if -5.79999999999999995e85 < y < 2Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6495.1%
Simplified95.1%
Final simplification84.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= z -7.8e-12) t_0 (if (<= z 2.8e-110) x t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (z <= -7.8e-12) {
tmp = t_0;
} else if (z <= 2.8e-110) {
tmp = x;
} 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) :: tmp
t_0 = x * (y * z)
if (z <= (-7.8d-12)) then
tmp = t_0
else if (z <= 2.8d-110) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (z <= -7.8e-12) {
tmp = t_0;
} else if (z <= 2.8e-110) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if z <= -7.8e-12: tmp = t_0 elif z <= 2.8e-110: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -7.8e-12) tmp = t_0; elseif (z <= 2.8e-110) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * z); tmp = 0.0; if (z <= -7.8e-12) tmp = t_0; elseif (z <= 2.8e-110) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.8e-12], t$95$0, If[LessEqual[z, 2.8e-110], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -7.8 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -7.79999999999999988e-12 or 2.8e-110 < z Initial program 92.4%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6447.0%
Simplified47.0%
if -7.79999999999999988e-12 < z < 2.8e-110Initial program 100.0%
Taylor expanded in z around 0
Simplified87.4%
Final simplification61.8%
(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.2%
Taylor expanded in z around 0
Simplified37.1%
(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 2024161
(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))))