
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (* x (+ y -1.0))))) (if (<= z -1.1) 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.1) {
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.1d0)) 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.1) {
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.1: 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.1) 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.1) 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.1], 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.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.1000000000000001 or 1 < z Initial program 90.7%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6490.7%
Applied egg-rr90.7%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6498.9%
Simplified98.9%
if -1.1000000000000001 < z < 1Initial program 99.9%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.9%
Applied egg-rr99.9%
*-commutativeN/A
flip--N/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
associate-/l*N/A
metadata-evalN/A
flip--N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf
associate-/l/N/A
metadata-evalN/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f6499.8%
Simplified99.8%
sub-negN/A
+-commutativeN/A
distribute-neg-fracN/A
associate-/l/N/A
associate-/r/N/A
metadata-evalN/A
frac-2negN/A
/-rgt-identityN/A
*-rgt-identityN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6499.8%
Applied egg-rr99.8%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (+ 1.0 (* y z))))) (if (<= y -1000000.0) t_0 (if (<= y 2e-22) (* 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 <= -1000000.0) {
tmp = t_0;
} else if (y <= 2e-22) {
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 <= (-1000000.0d0)) then
tmp = t_0
else if (y <= 2d-22) 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 <= -1000000.0) {
tmp = t_0;
} else if (y <= 2e-22) {
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 <= -1000000.0: tmp = t_0 elif y <= 2e-22: 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 <= -1000000.0) tmp = t_0; elseif (y <= 2e-22) 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 <= -1000000.0) tmp = t_0; elseif (y <= 2e-22) 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, -1000000.0], t$95$0, If[LessEqual[y, 2e-22], 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 -1000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-22}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1e6 or 2.0000000000000001e-22 < y Initial program 90.7%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6490.7%
Applied egg-rr90.7%
*-commutativeN/A
flip--N/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
/-lowering-/.f64N/A
associate-/l*N/A
metadata-evalN/A
flip--N/A
*-commutativeN/A
*-lowering-*.f64N/A
--lowering--.f6490.7%
Applied egg-rr90.7%
Taylor expanded in y around inf
associate-/l/N/A
metadata-evalN/A
distribute-neg-fracN/A
/-lowering-/.f64N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f6491.6%
Simplified91.6%
sub-negN/A
+-commutativeN/A
distribute-neg-fracN/A
associate-/l/N/A
associate-/r/N/A
metadata-evalN/A
frac-2negN/A
/-rgt-identityN/A
*-rgt-identityN/A
distribute-lft-outN/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f6489.7%
Applied egg-rr89.7%
if -1e6 < y < 2.0000000000000001e-22Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f64100.0%
Simplified100.0%
Final simplification95.1%
(FPCore (x y z) :precision binary64 (if (<= y -6.8e+146) (* z (* x y)) (if (<= y 1.1e+14) (* x (- 1.0 z)) (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.8e+146) {
tmp = z * (x * y);
} else if (y <= 1.1e+14) {
tmp = x * (1.0 - z);
} else {
tmp = y * (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 (y <= (-6.8d+146)) then
tmp = z * (x * y)
else if (y <= 1.1d+14) then
tmp = x * (1.0d0 - z)
else
tmp = y * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.8e+146) {
tmp = z * (x * y);
} else if (y <= 1.1e+14) {
tmp = x * (1.0 - z);
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.8e+146: tmp = z * (x * y) elif y <= 1.1e+14: tmp = x * (1.0 - z) else: tmp = y * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.8e+146) tmp = Float64(z * Float64(x * y)); elseif (y <= 1.1e+14) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.8e+146) tmp = z * (x * y); elseif (y <= 1.1e+14) tmp = x * (1.0 - z); else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.8e+146], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+14], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+146}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+14}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if y < -6.79999999999999981e146Initial program 79.4%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6468.4%
Simplified68.4%
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6485.9%
Applied egg-rr85.9%
if -6.79999999999999981e146 < y < 1.1e14Initial program 98.9%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6493.2%
Simplified93.2%
if 1.1e14 < y Initial program 95.2%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6475.8%
Simplified75.8%
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6479.0%
Applied egg-rr79.0%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* z (* x y)))) (if (<= y -4.5e+146) t_0 (if (<= y 1600000000000.0) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = z * (x * y);
double tmp;
if (y <= -4.5e+146) {
tmp = t_0;
} else if (y <= 1600000000000.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 = z * (x * y)
if (y <= (-4.5d+146)) then
tmp = t_0
else if (y <= 1600000000000.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 = z * (x * y);
double tmp;
if (y <= -4.5e+146) {
tmp = t_0;
} else if (y <= 1600000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (x * y) tmp = 0 if y <= -4.5e+146: tmp = t_0 elif y <= 1600000000000.0: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(x * y)) tmp = 0.0 if (y <= -4.5e+146) tmp = t_0; elseif (y <= 1600000000000.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 = z * (x * y); tmp = 0.0; if (y <= -4.5e+146) tmp = t_0; elseif (y <= 1600000000000.0) 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.5e+146], t$95$0, If[LessEqual[y, 1600000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(x \cdot y\right)\\
\mathbf{if}\;y \leq -4.5 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1600000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.50000000000000026e146 or 1.6e12 < y Initial program 89.7%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6473.2%
Simplified73.2%
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6481.3%
Applied egg-rr81.3%
if -4.50000000000000026e146 < y < 1.6e12Initial program 98.9%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6493.2%
Simplified93.2%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= y -4.4e+146) t_0 (if (<= y 2000000000000.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 <= -4.4e+146) {
tmp = t_0;
} else if (y <= 2000000000000.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 <= (-4.4d+146)) then
tmp = t_0
else if (y <= 2000000000000.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 <= -4.4e+146) {
tmp = t_0;
} else if (y <= 2000000000000.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 <= -4.4e+146: tmp = t_0 elif y <= 2000000000000.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 <= -4.4e+146) tmp = t_0; elseif (y <= 2000000000000.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 <= -4.4e+146) tmp = t_0; elseif (y <= 2000000000000.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, -4.4e+146], t$95$0, If[LessEqual[y, 2000000000000.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 -4.4 \cdot 10^{+146}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2000000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -4.3999999999999996e146 or 2e12 < y Initial program 89.7%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6473.2%
Simplified73.2%
if -4.3999999999999996e146 < y < 2e12Initial program 98.9%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6493.2%
Simplified93.2%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= z -1.4e-16) t_0 (if (<= z 1.8e-7) x t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (z <= -1.4e-16) {
tmp = t_0;
} else if (z <= 1.8e-7) {
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 <= (-1.4d-16)) then
tmp = t_0
else if (z <= 1.8d-7) 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 <= -1.4e-16) {
tmp = t_0;
} else if (z <= 1.8e-7) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if z <= -1.4e-16: tmp = t_0 elif z <= 1.8e-7: 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 <= -1.4e-16) tmp = t_0; elseif (z <= 1.8e-7) 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 <= -1.4e-16) tmp = t_0; elseif (z <= 1.8e-7) 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, -1.4e-16], t$95$0, If[LessEqual[z, 1.8e-7], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.4000000000000001e-16 or 1.79999999999999997e-7 < z Initial program 90.9%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6447.5%
Simplified47.5%
if -1.4000000000000001e-16 < z < 1.79999999999999997e-7Initial program 99.9%
Taylor expanded in z around 0
Simplified82.1%
Final simplification65.5%
(FPCore (x y z) :precision binary64 (if (<= z -106.0) (* z (* x (+ y -1.0))) (+ x (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -106.0) {
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 (z <= (-106.0d0)) 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 (z <= -106.0) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -106.0: 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 (z <= -106.0) tmp = Float64(z * Float64(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 (z <= -106.0) 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[z, -106.0], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -106:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -106Initial program 87.6%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6487.5%
Applied egg-rr87.5%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6499.0%
Simplified99.0%
if -106 < z Initial program 98.4%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6498.5%
Applied egg-rr98.5%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (<= z -106.0) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -106.0) {
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 (z <= (-106.0d0)) 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 (z <= -106.0) {
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 z <= -106.0: 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 (z <= -106.0) tmp = Float64(z * Float64(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 (z <= -106.0) 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[z, -106.0], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $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}\;z \leq -106:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -106Initial program 87.6%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6487.5%
Applied egg-rr87.5%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-sub0N/A
associate--r-N/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f6499.0%
Simplified99.0%
if -106 < z Initial program 98.4%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (+ x (* (* x z) (+ y -1.0))))
double code(double x, double y, double z) {
return x + ((x * z) * (y + -1.0));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((x * z) * (y + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return x + ((x * z) * (y + -1.0));
}
def code(x, y, z): return x + ((x * z) * (y + -1.0))
function code(x, y, z) return Float64(x + Float64(Float64(x * z) * Float64(y + -1.0))) end
function tmp = code(x, y, z) tmp = x + ((x * z) * (y + -1.0)); end
code[x_, y_, z_] := N[(x + N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot z\right) \cdot \left(y + -1\right)
\end{array}
Initial program 95.6%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6495.6%
Applied egg-rr95.6%
--lowering--.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f6498.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.6%
Taylor expanded in z around 0
Simplified44.3%
(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 2024138
(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))))