
(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 (+ 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}
Initial program 99.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (fma -6.0 z 4.0) y)))
(if (<= z -2.4e+216)
(* (* -6.0 y) z)
(if (<= z -1.65e+120)
(* (* x 6.0) z)
(if (<= z -1.8e-12)
t_0
(if (<= z 0.245)
(fma -3.0 x (* 4.0 y))
(if (<= z 3.8e+63) t_0 (* (* x z) 6.0))))))))
double code(double x, double y, double z) {
double t_0 = fma(-6.0, z, 4.0) * y;
double tmp;
if (z <= -2.4e+216) {
tmp = (-6.0 * y) * z;
} else if (z <= -1.65e+120) {
tmp = (x * 6.0) * z;
} else if (z <= -1.8e-12) {
tmp = t_0;
} else if (z <= 0.245) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 3.8e+63) {
tmp = t_0;
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(-6.0, z, 4.0) * y) tmp = 0.0 if (z <= -2.4e+216) tmp = Float64(Float64(-6.0 * y) * z); elseif (z <= -1.65e+120) tmp = Float64(Float64(x * 6.0) * z); elseif (z <= -1.8e-12) tmp = t_0; elseif (z <= 0.245) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 3.8e+63) tmp = t_0; else tmp = Float64(Float64(x * z) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -2.4e+216], N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -1.65e+120], N[(N[(x * 6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -1.8e-12], t$95$0, If[LessEqual[z, 0.245], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.8e+63], t$95$0, N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+216}:\\
\;\;\;\;\left(-6 \cdot y\right) \cdot z\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{+120}:\\
\;\;\;\;\left(x \cdot 6\right) \cdot z\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.245:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.3999999999999999e216Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.7
lift-/.f64N/A
metadata-eval99.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites68.1%
if -2.3999999999999999e216 < z < -1.64999999999999995e120Initial program 99.8%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6474.1
Applied rewrites74.1%
Taylor expanded in z around inf
Applied rewrites74.1%
Applied rewrites74.1%
if -1.64999999999999995e120 < z < -1.8e-12 or 0.245 < z < 3.8000000000000001e63Initial program 99.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6470.9
Applied rewrites70.9%
if -1.8e-12 < z < 0.245Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6498.5
Applied rewrites98.5%
Taylor expanded in x around 0
Applied rewrites98.6%
if 3.8000000000000001e63 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6467.4
Applied rewrites67.4%
Taylor expanded in z around inf
Applied rewrites67.4%
Final simplification82.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* -6.0 y) z)))
(if (<= z -2.4e+216)
t_0
(if (<= z -1.65e+120)
(* (* x 6.0) z)
(if (<= z -38000.0)
(* (* y z) -6.0)
(if (<= z 0.6)
(fma -3.0 x (* 4.0 y))
(if (<= z 3.8e+63) t_0 (* (* x z) 6.0))))))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * y) * z;
double tmp;
if (z <= -2.4e+216) {
tmp = t_0;
} else if (z <= -1.65e+120) {
tmp = (x * 6.0) * z;
} else if (z <= -38000.0) {
tmp = (y * z) * -6.0;
} else if (z <= 0.6) {
tmp = fma(-3.0, x, (4.0 * y));
} else if (z <= 3.8e+63) {
tmp = t_0;
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * y) * z) tmp = 0.0 if (z <= -2.4e+216) tmp = t_0; elseif (z <= -1.65e+120) tmp = Float64(Float64(x * 6.0) * z); elseif (z <= -38000.0) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= 0.6) tmp = fma(-3.0, x, Float64(4.0 * y)); elseif (z <= 3.8e+63) tmp = t_0; else tmp = Float64(Float64(x * z) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.4e+216], t$95$0, If[LessEqual[z, -1.65e+120], N[(N[(x * 6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -38000.0], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, 0.6], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.8e+63], t$95$0, N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+216}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{+120}:\\
\;\;\;\;\left(x \cdot 6\right) \cdot z\\
\mathbf{elif}\;z \leq -38000:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.3999999999999999e216 or 0.599999999999999978 < z < 3.8000000000000001e63Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.7
lift-/.f64N/A
metadata-eval99.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6496.3
Applied rewrites96.3%
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites70.1%
if -2.3999999999999999e216 < z < -1.64999999999999995e120Initial program 99.8%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6474.1
Applied rewrites74.1%
Taylor expanded in z around inf
Applied rewrites74.1%
Applied rewrites74.1%
if -1.64999999999999995e120 < z < -38000Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.5
lift-/.f64N/A
metadata-eval99.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites68.5%
if -38000 < z < 0.599999999999999978Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
Applied rewrites96.6%
if 3.8000000000000001e63 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6467.4
Applied rewrites67.4%
Taylor expanded in z around inf
Applied rewrites67.4%
Final simplification82.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* -6.0 y) z)))
(if (<= z -2.4e+216)
t_0
(if (<= z -1.65e+120)
(* (* x 6.0) z)
(if (<= z -38000.0)
(* (* y z) -6.0)
(if (<= z 0.6)
(fma (- y x) 4.0 x)
(if (<= z 3.8e+63) t_0 (* (* x z) 6.0))))))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * y) * z;
double tmp;
if (z <= -2.4e+216) {
tmp = t_0;
} else if (z <= -1.65e+120) {
tmp = (x * 6.0) * z;
} else if (z <= -38000.0) {
tmp = (y * z) * -6.0;
} else if (z <= 0.6) {
tmp = fma((y - x), 4.0, x);
} else if (z <= 3.8e+63) {
tmp = t_0;
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * y) * z) tmp = 0.0 if (z <= -2.4e+216) tmp = t_0; elseif (z <= -1.65e+120) tmp = Float64(Float64(x * 6.0) * z); elseif (z <= -38000.0) tmp = Float64(Float64(y * z) * -6.0); elseif (z <= 0.6) tmp = fma(Float64(y - x), 4.0, x); elseif (z <= 3.8e+63) tmp = t_0; else tmp = Float64(Float64(x * z) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.4e+216], t$95$0, If[LessEqual[z, -1.65e+120], N[(N[(x * 6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -38000.0], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[z, 0.6], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[z, 3.8e+63], t$95$0, N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+216}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{+120}:\\
\;\;\;\;\left(x \cdot 6\right) \cdot z\\
\mathbf{elif}\;z \leq -38000:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.3999999999999999e216 or 0.599999999999999978 < z < 3.8000000000000001e63Initial program 99.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.7
lift-/.f64N/A
metadata-eval99.7
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6496.3
Applied rewrites96.3%
Applied rewrites96.4%
Taylor expanded in x around 0
Applied rewrites70.1%
if -2.3999999999999999e216 < z < -1.64999999999999995e120Initial program 99.8%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6474.1
Applied rewrites74.1%
Taylor expanded in z around inf
Applied rewrites74.1%
Applied rewrites74.1%
if -1.64999999999999995e120 < z < -38000Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.5
lift-/.f64N/A
metadata-eval99.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites68.5%
if -38000 < z < 0.599999999999999978Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6496.5
Applied rewrites96.5%
if 3.8000000000000001e63 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6467.4
Applied rewrites67.4%
Taylor expanded in z around inf
Applied rewrites67.4%
Final simplification82.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (* -6.0 y) z)))
(if (<= z -2.4e+216)
t_0
(if (<= z -1.65e+120)
(* (* x 6.0) z)
(if (<= z -38000.0)
t_0
(if (<= z 0.6)
(fma (- y x) 4.0 x)
(if (<= z 3.8e+63) t_0 (* (* x z) 6.0))))))))
double code(double x, double y, double z) {
double t_0 = (-6.0 * y) * z;
double tmp;
if (z <= -2.4e+216) {
tmp = t_0;
} else if (z <= -1.65e+120) {
tmp = (x * 6.0) * z;
} else if (z <= -38000.0) {
tmp = t_0;
} else if (z <= 0.6) {
tmp = fma((y - x), 4.0, x);
} else if (z <= 3.8e+63) {
tmp = t_0;
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(-6.0 * y) * z) tmp = 0.0 if (z <= -2.4e+216) tmp = t_0; elseif (z <= -1.65e+120) tmp = Float64(Float64(x * 6.0) * z); elseif (z <= -38000.0) tmp = t_0; elseif (z <= 0.6) tmp = fma(Float64(y - x), 4.0, x); elseif (z <= 3.8e+63) tmp = t_0; else tmp = Float64(Float64(x * z) * 6.0); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(-6.0 * y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -2.4e+216], t$95$0, If[LessEqual[z, -1.65e+120], N[(N[(x * 6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -38000.0], t$95$0, If[LessEqual[z, 0.6], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[z, 3.8e+63], t$95$0, N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-6 \cdot y\right) \cdot z\\
\mathbf{if}\;z \leq -2.4 \cdot 10^{+216}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{+120}:\\
\;\;\;\;\left(x \cdot 6\right) \cdot z\\
\mathbf{elif}\;z \leq -38000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{+63}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if z < -2.3999999999999999e216 or -1.64999999999999995e120 < z < -38000 or 0.599999999999999978 < z < 3.8000000000000001e63Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.6
lift-/.f64N/A
metadata-eval99.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Applied rewrites97.0%
Taylor expanded in x around 0
Applied rewrites69.4%
if -2.3999999999999999e216 < z < -1.64999999999999995e120Initial program 99.8%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6474.1
Applied rewrites74.1%
Taylor expanded in z around inf
Applied rewrites74.1%
Applied rewrites74.1%
if -38000 < z < 0.599999999999999978Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6496.5
Applied rewrites96.5%
if 3.8000000000000001e63 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6467.4
Applied rewrites67.4%
Taylor expanded in z around inf
Applied rewrites67.4%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.55) (not (<= z 0.58))) (* (* (- y x) z) -6.0) (fma -3.0 x (* 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.55) || !(z <= 0.58)) {
tmp = ((y - x) * z) * -6.0;
} else {
tmp = fma(-3.0, x, (4.0 * y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -0.55) || !(z <= 0.58)) tmp = Float64(Float64(Float64(y - x) * z) * -6.0); else tmp = fma(-3.0, x, Float64(4.0 * y)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.55], N[Not[LessEqual[z, 0.58]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.55 \lor \neg \left(z \leq 0.58\right):\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\end{array}
\end{array}
if z < -0.55000000000000004 or 0.57999999999999996 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.5
Applied rewrites97.5%
if -0.55000000000000004 < z < 0.57999999999999996Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites98.0%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.45e-76) (not (<= x 7.8e-28))) (* (fma 6.0 z -3.0) x) (* (fma -6.0 z 4.0) y)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45e-76) || !(x <= 7.8e-28)) {
tmp = fma(6.0, z, -3.0) * x;
} else {
tmp = fma(-6.0, z, 4.0) * y;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((x <= -1.45e-76) || !(x <= 7.8e-28)) tmp = Float64(fma(6.0, z, -3.0) * x); else tmp = Float64(fma(-6.0, z, 4.0) * y); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.45e-76], N[Not[LessEqual[x, 7.8e-28]], $MachinePrecision]], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{-76} \lor \neg \left(x \leq 7.8 \cdot 10^{-28}\right):\\
\;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\end{array}
\end{array}
if x < -1.4500000000000001e-76 or 7.79999999999999998e-28 < x Initial program 99.6%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6481.1
Applied rewrites81.1%
Applied rewrites81.1%
if -1.4500000000000001e-76 < x < 7.79999999999999998e-28Initial program 99.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
mul-1-negN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6478.9
Applied rewrites78.9%
Final simplification80.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.2) (not (<= z 0.5))) (* (* x z) 6.0) (fma (- y x) 4.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.2) || !(z <= 0.5)) {
tmp = (x * z) * 6.0;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -3.2) || !(z <= 0.5)) tmp = Float64(Float64(x * z) * 6.0); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.2], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if z < -3.2000000000000002 or 0.5 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6454.2
Applied rewrites54.2%
Taylor expanded in z around inf
Applied rewrites52.6%
if -3.2000000000000002 < z < 0.5Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.9
Applied rewrites97.9%
Final simplification73.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.2) (not (<= z 0.5))) (* (* x 6.0) z) (fma (- y x) 4.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.2) || !(z <= 0.5)) {
tmp = (x * 6.0) * z;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((z <= -3.2) || !(z <= 0.5)) tmp = Float64(Float64(x * 6.0) * z); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.2], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(N[(x * 6.0), $MachinePrecision] * z), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;\left(x \cdot 6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if z < -3.2000000000000002 or 0.5 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6454.2
Applied rewrites54.2%
Taylor expanded in z around inf
Applied rewrites52.6%
Applied rewrites52.5%
if -3.2000000000000002 < z < 0.5Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.9
Applied rewrites97.9%
Final simplification73.6%
(FPCore (x y z) :precision binary64 (if (<= z -3.2) (* (* 6.0 z) x) (if (<= z 0.5) (fma (- y x) 4.0 x) (* (* x z) 6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.2) {
tmp = (6.0 * z) * x;
} else if (z <= 0.5) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3.2) tmp = Float64(Float64(6.0 * z) * x); elseif (z <= 0.5) tmp = fma(Float64(y - x), 4.0, x); else tmp = Float64(Float64(x * z) * 6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3.2], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 0.5], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2:\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if z < -3.2000000000000002Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6449.6
Applied rewrites49.6%
Applied rewrites49.6%
Taylor expanded in z around inf
Applied rewrites47.9%
if -3.2000000000000002 < z < 0.5Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.9
Applied rewrites97.9%
if 0.5 < z Initial program 99.7%
Taylor expanded in x around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6459.8
Applied rewrites59.8%
Taylor expanded in z around inf
Applied rewrites58.5%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.4e+56) (not (<= y 1.6e+23))) (* 4.0 y) (* -3.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e+56) || !(y <= 1.6e+23)) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * 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 <= (-6.4d+56)) .or. (.not. (y <= 1.6d+23))) then
tmp = 4.0d0 * y
else
tmp = (-3.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e+56) || !(y <= 1.6e+23)) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.4e+56) or not (y <= 1.6e+23): tmp = 4.0 * y else: tmp = -3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.4e+56) || !(y <= 1.6e+23)) tmp = Float64(4.0 * y); else tmp = Float64(-3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.4e+56) || ~((y <= 1.6e+23))) tmp = 4.0 * y; else tmp = -3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.4e+56], N[Not[LessEqual[y, 1.6e+23]], $MachinePrecision]], N[(4.0 * y), $MachinePrecision], N[(-3.0 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+56} \lor \neg \left(y \leq 1.6 \cdot 10^{+23}\right):\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot x\\
\end{array}
\end{array}
if y < -6.40000000000000007e56 or 1.6e23 < y Initial program 99.7%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6441.8
Applied rewrites41.8%
Taylor expanded in x around 0
Applied rewrites31.7%
if -6.40000000000000007e56 < y < 1.6e23Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.7
Applied rewrites51.7%
Taylor expanded in x around inf
Applied rewrites40.8%
Final simplification37.2%
(FPCore (x y z) :precision binary64 (fma (- 0.6666666666666666 z) (* 6.0 (- y x)) x))
double code(double x, double y, double z) {
return fma((0.6666666666666666 - z), (6.0 * (y - x)), x);
}
function code(x, y, z) return fma(Float64(0.6666666666666666 - z), Float64(6.0 * Float64(y - x)), x) end
code[x_, y_, z_] := N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.6666666666666666 - z, 6 \cdot \left(y - x\right), x\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6499.5
lift-/.f64N/A
metadata-eval99.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (fma (* (- 0.6666666666666666 z) (- y x)) 6.0 x))
double code(double x, double y, double z) {
return fma(((0.6666666666666666 - z) * (y - x)), 6.0, x);
}
function code(x, y, z) return fma(Float64(Float64(0.6666666666666666 - z) * Float64(y - x)), 6.0, x) end
code[x_, y_, z_] := N[(N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(0.6666666666666666 - z\right) \cdot \left(y - x\right), 6, x\right)
\end{array}
Initial program 99.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift-/.f64N/A
metadata-eval99.5
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 (fma (- y x) 4.0 x))
double code(double x, double y, double z) {
return fma((y - x), 4.0, x);
}
function code(x, y, z) return fma(Float64(y - x), 4.0, x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 4, x\right)
\end{array}
Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6447.8
Applied rewrites47.8%
Final simplification47.8%
(FPCore (x y z) :precision binary64 (* -3.0 x))
double code(double x, double y, double z) {
return -3.0 * x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-3.0d0) * x
end function
public static double code(double x, double y, double z) {
return -3.0 * x;
}
def code(x, y, z): return -3.0 * x
function code(x, y, z) return Float64(-3.0 * x) end
function tmp = code(x, y, z) tmp = -3.0 * x; end
code[x_, y_, z_] := N[(-3.0 * x), $MachinePrecision]
\begin{array}{l}
\\
-3 \cdot x
\end{array}
Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6447.8
Applied rewrites47.8%
Taylor expanded in x around inf
Applied rewrites29.1%
Final simplification29.1%
herbie shell --seed 2024338
(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))))