
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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 + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - 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 + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z): return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z))) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z)); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma 6.0 (* z (- x y)) (fma 4.0 (- y x) x)))
double code(double x, double y, double z) {
return fma(6.0, (z * (x - y)), fma(4.0, (y - x), x));
}
function code(x, y, z) return fma(6.0, Float64(z * Float64(x - y)), fma(4.0, Float64(y - x), x)) end
code[x_, y_, z_] := N[(6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(6, z \cdot \left(x - y\right), \mathsf{fma}\left(4, y - x, x\right)\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around -inf
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
distribute-neg-inN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
metadata-evalN/A
sub-negN/A
*-commutativeN/A
associate-*r/N/A
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (fma 6.0 z -3.0))) (t_1 (- (/ 2.0 3.0) z)))
(if (<= t_1 -1e+135)
(* y (* z -6.0))
(if (<= t_1 0.6666666666666665)
t_0
(if (<= t_1 1.0) (fma 4.0 (- y x) x) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * fma(6.0, z, -3.0);
double t_1 = (2.0 / 3.0) - z;
double tmp;
if (t_1 <= -1e+135) {
tmp = y * (z * -6.0);
} else if (t_1 <= 0.6666666666666665) {
tmp = t_0;
} else if (t_1 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * fma(6.0, z, -3.0)) t_1 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_1 <= -1e+135) tmp = Float64(y * Float64(z * -6.0)); elseif (t_1 <= 0.6666666666666665) tmp = t_0; elseif (t_1 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+135], N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.6666666666666665], t$95$0, If[LessEqual[t$95$1, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\
t_1 := \frac{2}{3} - z\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+135}:\\
\;\;\;\;y \cdot \left(z \cdot -6\right)\\
\mathbf{elif}\;t\_1 \leq 0.6666666666666665:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -9.99999999999999962e134Initial program 99.8%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified75.9%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6475.9
Simplified75.9%
if -9.99999999999999962e134 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.66666666666666652 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around inf
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+l+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
metadata-eval63.4
Simplified63.4%
if 0.66666666666666652 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -1.0)
(* z (* 6.0 (- x y)))
(if (<= t_0 1.0) (fma 4.0 (- y x) x) (fma (* z (- x y)) 6.0 x)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -1.0) {
tmp = z * (6.0 * (x - y));
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = fma((z * (x - y)), 6.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -1.0) tmp = Float64(z * Float64(6.0 * Float64(x - y))); elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = fma(Float64(z * Float64(x - y)), 6.0, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], N[(z * N[(6.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;z \cdot \left(6 \cdot \left(x - y\right)\right)\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(x - y\right), 6, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1Initial program 99.7%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f6496.5
Simplified96.5%
if -1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
+-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
--lowering--.f64N/A
metadata-eval99.8
Applied egg-rr99.8%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
sub-negN/A
*-lowering-*.f64N/A
--lowering--.f6499.8
Simplified99.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* z (* 6.0 (- x y))))) (if (<= t_0 -1.0) t_1 (if (<= t_0 1.0) (fma 4.0 (- y x) x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = z * (6.0 * (x - y));
double tmp;
if (t_0 <= -1.0) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(z * Float64(6.0 * Float64(x - y))) tmp = 0.0 if (t_0 <= -1.0) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(4.0, Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(6.0 * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := z \cdot \left(6 \cdot \left(x - y\right)\right)\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
--lowering--.f6498.3
Simplified98.3%
if -1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -1.0)
(* y (* z -6.0))
(if (<= t_0 3e+19) (fma 4.0 (- y x) x) (* z (* y -6.0))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -1.0) {
tmp = y * (z * -6.0);
} else if (t_0 <= 3e+19) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = z * (y * -6.0);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -1.0) tmp = Float64(y * Float64(z * -6.0)); elseif (t_0 <= 3e+19) tmp = fma(4.0, Float64(y - x), x); else tmp = Float64(z * Float64(y * -6.0)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 3e+19], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(y * -6.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;y \cdot \left(z \cdot -6\right)\\
\mathbf{elif}\;t\_0 \leq 3 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot -6\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1Initial program 99.7%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified58.3%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6458.3
Simplified58.3%
if -1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 3e19Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6498.6
Simplified98.6%
if 3e19 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified44.8%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6444.8
Simplified44.8%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6446.1
Applied egg-rr46.1%
Final simplification74.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* y (* z -6.0)))) (if (<= t_0 -1.0) t_1 (if (<= t_0 3e+19) (fma 4.0 (- y x) x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = y * (z * -6.0);
double tmp;
if (t_0 <= -1.0) {
tmp = t_1;
} else if (t_0 <= 3e+19) {
tmp = fma(4.0, (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(y * Float64(z * -6.0)) tmp = 0.0 if (t_0 <= -1.0) tmp = t_1; elseif (t_0 <= 3e+19) tmp = fma(4.0, Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1.0], t$95$1, If[LessEqual[t$95$0, 3e+19], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := y \cdot \left(z \cdot -6\right)\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 3 \cdot 10^{+19}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1 or 3e19 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified50.9%
Taylor expanded in z around inf
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6450.9
Simplified50.9%
if -1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 3e19Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6498.6
Simplified98.6%
(FPCore (x y z)
:precision binary64
(if (<= z -180.0)
(fma (* z x) 6.0 x)
(if (<= z 1.95e-19)
(fma x -3.0 (* y 4.0))
(if (<= z 4e+133) (* x (fma 6.0 z -3.0)) (* y (fma z -6.0 4.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -180.0) {
tmp = fma((z * x), 6.0, x);
} else if (z <= 1.95e-19) {
tmp = fma(x, -3.0, (y * 4.0));
} else if (z <= 4e+133) {
tmp = x * fma(6.0, z, -3.0);
} else {
tmp = y * fma(z, -6.0, 4.0);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -180.0) tmp = fma(Float64(z * x), 6.0, x); elseif (z <= 1.95e-19) tmp = fma(x, -3.0, Float64(y * 4.0)); elseif (z <= 4e+133) tmp = Float64(x * fma(6.0, z, -3.0)); else tmp = Float64(y * fma(z, -6.0, 4.0)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -180.0], N[(N[(z * x), $MachinePrecision] * 6.0 + x), $MachinePrecision], If[LessEqual[z, 1.95e-19], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e+133], N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * -6.0 + 4.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -180:\\
\;\;\;\;\mathsf{fma}\left(z \cdot x, 6, x\right)\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+133}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(6, z, -3\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(z, -6, 4\right)\\
\end{array}
\end{array}
if z < -180Initial program 99.7%
+-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
--lowering--.f64N/A
metadata-eval99.8
Applied egg-rr99.8%
Taylor expanded in y around 0
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-+.f6462.0
Simplified62.0%
Taylor expanded in z around inf
Simplified62.0%
if -180 < z < 1.94999999999999998e-19Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
Taylor expanded in y around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6499.3
Simplified99.3%
if 1.94999999999999998e-19 < z < 4.0000000000000001e133Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+l+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
metadata-eval68.5
Simplified68.5%
if 4.0000000000000001e133 < z Initial program 99.8%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified75.9%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f6475.9
Applied egg-rr75.9%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (fma 6.0 z -3.0))))
(if (<= z -6e-8)
t_0
(if (<= z 1.95e-19)
(fma x -3.0 (* y 4.0))
(if (<= z 5.8e+134) t_0 (* y (fma z -6.0 4.0)))))))
double code(double x, double y, double z) {
double t_0 = x * fma(6.0, z, -3.0);
double tmp;
if (z <= -6e-8) {
tmp = t_0;
} else if (z <= 1.95e-19) {
tmp = fma(x, -3.0, (y * 4.0));
} else if (z <= 5.8e+134) {
tmp = t_0;
} else {
tmp = y * fma(z, -6.0, 4.0);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * fma(6.0, z, -3.0)) tmp = 0.0 if (z <= -6e-8) tmp = t_0; elseif (z <= 1.95e-19) tmp = fma(x, -3.0, Float64(y * 4.0)); elseif (z <= 5.8e+134) tmp = t_0; else tmp = Float64(y * fma(z, -6.0, 4.0)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6e-8], t$95$0, If[LessEqual[z, 1.95e-19], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.8e+134], t$95$0, N[(y * N[(z * -6.0 + 4.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{+134}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(z, -6, 4\right)\\
\end{array}
\end{array}
if z < -5.99999999999999946e-8 or 1.94999999999999998e-19 < z < 5.80000000000000023e134Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+l+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
metadata-eval63.8
Simplified63.8%
if -5.99999999999999946e-8 < z < 1.94999999999999998e-19Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
Taylor expanded in y around 0
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f6499.3
Simplified99.3%
if 5.80000000000000023e134 < z Initial program 99.8%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified75.9%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f6475.9
Applied egg-rr75.9%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (fma 6.0 z -3.0))))
(if (<= z -6e-7)
t_0
(if (<= z 1.95e-19)
(fma 4.0 (- y x) x)
(if (<= z 1.95e+133) t_0 (* y (fma z -6.0 4.0)))))))
double code(double x, double y, double z) {
double t_0 = x * fma(6.0, z, -3.0);
double tmp;
if (z <= -6e-7) {
tmp = t_0;
} else if (z <= 1.95e-19) {
tmp = fma(4.0, (y - x), x);
} else if (z <= 1.95e+133) {
tmp = t_0;
} else {
tmp = y * fma(z, -6.0, 4.0);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * fma(6.0, z, -3.0)) tmp = 0.0 if (z <= -6e-7) tmp = t_0; elseif (z <= 1.95e-19) tmp = fma(4.0, Float64(y - x), x); elseif (z <= 1.95e+133) tmp = t_0; else tmp = Float64(y * fma(z, -6.0, 4.0)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6e-7], t$95$0, If[LessEqual[z, 1.95e-19], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 1.95e+133], t$95$0, N[(y * N[(z * -6.0 + 4.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
\mathbf{elif}\;z \leq 1.95 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \mathsf{fma}\left(z, -6, 4\right)\\
\end{array}
\end{array}
if z < -5.9999999999999997e-7 or 1.94999999999999998e-19 < z < 1.95000000000000007e133Initial program 99.6%
Taylor expanded in x around inf
*-lowering-*.f64N/A
+-commutativeN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+l+N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
metadata-evalN/A
accelerator-lowering-fma.f64N/A
metadata-eval63.8
Simplified63.8%
if -5.9999999999999997e-7 < z < 1.94999999999999998e-19Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6499.3
Simplified99.3%
if 1.95000000000000007e133 < z Initial program 99.8%
Taylor expanded in x around 0
*-rgt-identityN/A
*-inversesN/A
associate-/l*N/A
associate-*l/N/A
associate-*r/N/A
+-rgt-identityN/A
associate-*r/N/A
associate-*l/N/A
associate-/l*N/A
*-inversesN/A
*-rgt-identityN/A
metadata-evalN/A
distribute-lft-neg-inN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
distribute-lft-neg-inN/A
Simplified75.9%
+-rgt-identityN/A
*-commutativeN/A
*-lowering-*.f64N/A
accelerator-lowering-fma.f6475.9
Applied egg-rr75.9%
Final simplification82.5%
(FPCore (x y z) :precision binary64 (if (<= y -6e-180) (* y 4.0) (if (<= y 5.4e+79) (* x -3.0) (fma 4.0 y x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e-180) {
tmp = y * 4.0;
} else if (y <= 5.4e+79) {
tmp = x * -3.0;
} else {
tmp = fma(4.0, y, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6e-180) tmp = Float64(y * 4.0); elseif (y <= 5.4e+79) tmp = Float64(x * -3.0); else tmp = fma(4.0, y, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6e-180], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 5.4e+79], N[(x * -3.0), $MachinePrecision], N[(4.0 * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-180}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+79}:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, y, x\right)\\
\end{array}
\end{array}
if y < -6.0000000000000001e-180Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6452.7
Simplified52.7%
Taylor expanded in y around inf
*-lowering-*.f6440.6
Simplified40.6%
if -6.0000000000000001e-180 < y < 5.3999999999999999e79Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6445.2
Simplified45.2%
Taylor expanded in y around 0
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f6434.1
Simplified34.1%
if 5.3999999999999999e79 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6458.4
Simplified58.4%
Taylor expanded in y around inf
Simplified48.7%
Final simplification39.6%
(FPCore (x y z) :precision binary64 (if (<= y -6e-180) (* y 4.0) (if (<= y 1.9e+72) (* x -3.0) (* y 4.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e-180) {
tmp = y * 4.0;
} else if (y <= 1.9e+72) {
tmp = x * -3.0;
} else {
tmp = y * 4.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 (y <= (-6d-180)) then
tmp = y * 4.0d0
else if (y <= 1.9d+72) then
tmp = x * (-3.0d0)
else
tmp = y * 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6e-180) {
tmp = y * 4.0;
} else if (y <= 1.9e+72) {
tmp = x * -3.0;
} else {
tmp = y * 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e-180: tmp = y * 4.0 elif y <= 1.9e+72: tmp = x * -3.0 else: tmp = y * 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e-180) tmp = Float64(y * 4.0); elseif (y <= 1.9e+72) tmp = Float64(x * -3.0); else tmp = Float64(y * 4.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e-180) tmp = y * 4.0; elseif (y <= 1.9e+72) tmp = x * -3.0; else tmp = y * 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e-180], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 1.9e+72], N[(x * -3.0), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-180}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+72}:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4\\
\end{array}
\end{array}
if y < -6.0000000000000001e-180 or 1.90000000000000003e72 < y Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6454.8
Simplified54.8%
Taylor expanded in y around inf
*-lowering-*.f6443.1
Simplified43.1%
if -6.0000000000000001e-180 < y < 1.90000000000000003e72Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6444.6
Simplified44.6%
Taylor expanded in y around 0
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f6434.1
Simplified34.1%
Final simplification39.6%
(FPCore (x y z) :precision binary64 (fma (* (- y x) (- 0.6666666666666666 z)) 6.0 x))
double code(double x, double y, double z) {
return fma(((y - x) * (0.6666666666666666 - z)), 6.0, x);
}
function code(x, y, z) return fma(Float64(Float64(y - x) * Float64(0.6666666666666666 - z)), 6.0, x) end
code[x_, y_, z_] := N[(N[(N[(y - x), $MachinePrecision] * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y - x\right) \cdot \left(0.6666666666666666 - z\right), 6, x\right)
\end{array}
Initial program 99.5%
+-commutativeN/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
--lowering--.f64N/A
metadata-eval99.6
Applied egg-rr99.6%
(FPCore (x y z) :precision binary64 (fma 4.0 (- y x) x))
double code(double x, double y, double z) {
return fma(4.0, (y - x), x);
}
function code(x, y, z) return fma(4.0, Float64(y - x), x) end
code[x_, y_, z_] := N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, y - x, x\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6450.8
Simplified50.8%
(FPCore (x y z) :precision binary64 (* y 4.0))
double code(double x, double y, double z) {
return y * 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * 4.0d0
end function
public static double code(double x, double y, double z) {
return y * 4.0;
}
def code(x, y, z): return y * 4.0
function code(x, y, z) return Float64(y * 4.0) end
function tmp = code(x, y, z) tmp = y * 4.0; end
code[x_, y_, z_] := N[(y * 4.0), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 4
\end{array}
Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6450.8
Simplified50.8%
Taylor expanded in y around inf
*-lowering-*.f6430.9
Simplified30.9%
Final simplification30.9%
(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 99.5%
Taylor expanded in z around 0
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6450.8
Simplified50.8%
Taylor expanded in y around inf
Simplified30.8%
Taylor expanded in y around 0
Simplified2.7%
herbie shell --seed 2024198
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
:precision binary64
(+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))