
(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 13 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 (fma -6.0 z 4.0) (- y x) x))
double code(double x, double y, double z) {
return fma(fma(-6.0, z, 4.0), (y - x), x);
}
function code(x, y, z) return fma(fma(-6.0, z, 4.0), Float64(y - x), x) end
code[x_, y_, z_] := N[(N[(-6.0 * z + 4.0), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-6, z, 4\right), y - x, x\right)
\end{array}
Initial program 99.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
distribute-lft-inN/A
neg-mul-1N/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lift-/.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -0.2)
(* (* 6.0 z) x)
(if (<= t_0 500.0)
(fma (- y x) 4.0 x)
(if (<= t_0 4e+145) (* (* y z) -6.0) (* (* 6.0 x) z))))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -0.2) {
tmp = (6.0 * z) * x;
} else if (t_0 <= 500.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 4e+145) {
tmp = (y * z) * -6.0;
} else {
tmp = (6.0 * x) * z;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -0.2) tmp = Float64(Float64(6.0 * z) * x); elseif (t_0 <= 500.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 4e+145) tmp = Float64(Float64(y * z) * -6.0); else tmp = Float64(Float64(6.0 * x) * z); 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, -0.2], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 500.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 4e+145], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+145}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;\left(6 \cdot x\right) \cdot z\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6493.1
Applied rewrites93.1%
Applied rewrites93.2%
Taylor expanded in y around 0
Applied rewrites55.8%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 500Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
if 500 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e145Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in y around inf
Applied rewrites60.7%
if 4e145 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6499.7
Applied rewrites99.7%
Applied rewrites99.9%
Taylor expanded in y around 0
Applied rewrites71.6%
Final simplification82.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* 6.0 z) x)))
(if (<= t_0 -0.2)
t_1
(if (<= t_0 500.0)
(fma (- y x) 4.0 x)
(if (<= t_0 4e+145) (* (* y z) -6.0) t_1)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (6.0 * z) * x;
double tmp;
if (t_0 <= -0.2) {
tmp = t_1;
} else if (t_0 <= 500.0) {
tmp = fma((y - x), 4.0, x);
} else if (t_0 <= 4e+145) {
tmp = (y * z) * -6.0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(6.0 * z) * x) tmp = 0.0 if (t_0 <= -0.2) tmp = t_1; elseif (t_0 <= 500.0) tmp = fma(Float64(y - x), 4.0, x); elseif (t_0 <= 4e+145) tmp = Float64(Float64(y * z) * -6.0); 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[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], t$95$1, If[LessEqual[t$95$0, 500.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[t$95$0, 4e+145], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(6 \cdot z\right) \cdot x\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 500:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+145}:\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001 or 4e145 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
Applied rewrites96.8%
Taylor expanded in y around 0
Applied rewrites64.2%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 500Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
if 500 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 4e145Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6498.8
Applied rewrites98.8%
Taylor expanded in y around inf
Applied rewrites60.7%
Final simplification82.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* (- y x) z) -6.0))) (if (<= t_0 -0.2) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = ((y - x) * z) * -6.0;
double tmp;
if (t_0 <= -0.2) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(Float64(y - x) * z) * -6.0) tmp = 0.0 if (t_0 <= -0.2) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(Float64(y - x), 4.0, 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[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(\left(y - x\right) \cdot z\right) \cdot -6\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (fma 6.0 z -3.0) x))) (if (<= t_0 -0.2) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = fma(6.0, z, -3.0) * x;
double tmp;
if (t_0 <= -0.2) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(fma(6.0, z, -3.0) * x) tmp = 0.0 if (t_0 <= -0.2) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(Float64(y - x), 4.0, 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[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in y around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
*-lft-identityN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
associate-*r*N/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.1%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* 6.0 z) x))) (if (<= t_0 -0.2) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (6.0 * z) * x;
double tmp;
if (t_0 <= -0.2) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(6.0 * z) * x) tmp = 0.0 if (t_0 <= -0.2) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(Float64(y - x), 4.0, 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[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(6 \cdot z\right) \cdot x\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
Applied rewrites96.7%
Taylor expanded in y around 0
Applied rewrites58.8%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* (* x z) 6.0))) (if (<= t_0 -0.2) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double t_1 = (x * z) * 6.0;
double tmp;
if (t_0 <= -0.2) {
tmp = t_1;
} else if (t_0 <= 1.0) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) t_1 = Float64(Float64(x * z) * 6.0) tmp = 0.0 if (t_0 <= -0.2) tmp = t_1; elseif (t_0 <= 1.0) tmp = fma(Float64(y - x), 4.0, 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[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -0.2], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := \left(x \cdot z\right) \cdot 6\\
\mathbf{if}\;t\_0 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -0.20000000000000001 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
Taylor expanded in y around 0
Applied rewrites58.7%
if -0.20000000000000001 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
Final simplification80.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (* z -6.0) (- y x)))) (if (<= z -0.56) t_0 (if (<= z 0.55) (fma (- y x) 4.0 x) t_0))))
double code(double x, double y, double z) {
double t_0 = (z * -6.0) * (y - x);
double tmp;
if (z <= -0.56) {
tmp = t_0;
} else if (z <= 0.55) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(z * -6.0) * Float64(y - x)) tmp = 0.0 if (z <= -0.56) tmp = t_0; elseif (z <= 0.55) tmp = fma(Float64(y - x), 4.0, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.56], t$95$0, If[LessEqual[z, 0.55], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(z \cdot -6\right) \cdot \left(y - x\right)\\
\mathbf{if}\;z \leq -0.56:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.56000000000000005 or 0.55000000000000004 < z Initial program 99.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
Applied rewrites96.7%
if -0.56000000000000005 < z < 0.55000000000000004Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.56) (* (* (- y x) -6.0) z) (if (<= z 0.55) (fma (- y x) 4.0 x) (* (* (- y x) z) -6.0))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.56) {
tmp = ((y - x) * -6.0) * z;
} else if (z <= 0.55) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = ((y - x) * z) * -6.0;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -0.56) tmp = Float64(Float64(Float64(y - x) * -6.0) * z); elseif (z <= 0.55) tmp = fma(Float64(y - x), 4.0, x); else tmp = Float64(Float64(Float64(y - x) * z) * -6.0); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -0.56], N[(N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 0.55], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.56:\\
\;\;\;\;\left(\left(y - x\right) \cdot -6\right) \cdot z\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
\end{array}
\end{array}
if z < -0.56000000000000005Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6498.5
Applied rewrites98.5%
Applied rewrites98.5%
if -0.56000000000000005 < z < 0.55000000000000004Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.6
Applied rewrites97.6%
if 0.55000000000000004 < z Initial program 99.5%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f6493.1
Applied rewrites93.1%
Final simplification97.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (fma 6.0 z -3.0) x)))
(if (<= x -1.2e+69)
t_0
(if (<= x 800000000.0) (* (fma z -6.0 4.0) y) t_0))))
double code(double x, double y, double z) {
double t_0 = fma(6.0, z, -3.0) * x;
double tmp;
if (x <= -1.2e+69) {
tmp = t_0;
} else if (x <= 800000000.0) {
tmp = fma(z, -6.0, 4.0) * y;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(fma(6.0, z, -3.0) * x) tmp = 0.0 if (x <= -1.2e+69) tmp = t_0; elseif (x <= 800000000.0) tmp = Float64(fma(z, -6.0, 4.0) * y); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -1.2e+69], t$95$0, If[LessEqual[x, 800000000.0], N[(N[(z * -6.0 + 4.0), $MachinePrecision] * y), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(6, z, -3\right) \cdot x\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 800000000:\\
\;\;\;\;\mathsf{fma}\left(z, -6, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.2000000000000001e69 or 8e8 < x Initial program 99.5%
Taylor expanded in y around 0
metadata-evalN/A
cancel-sign-sub-invN/A
*-commutativeN/A
associate-*r*N/A
sub-negN/A
*-lft-identityN/A
distribute-rgt-neg-inN/A
neg-mul-1N/A
associate-*r*N/A
distribute-rgt-inN/A
metadata-evalN/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
neg-mul-1N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.0%
if -1.2000000000000001e69 < x < 8e8Initial program 99.4%
Taylor expanded in y around inf
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
associate-*r*N/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6478.7
Applied rewrites78.7%
(FPCore (x y z) :precision binary64 (if (<= x -8.2e+68) (* -3.0 x) (if (<= x 1.8e-46) (* y 4.0) (* -3.0 x))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e+68) {
tmp = -3.0 * x;
} else if (x <= 1.8e-46) {
tmp = y * 4.0;
} 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 (x <= (-8.2d+68)) then
tmp = (-3.0d0) * x
else if (x <= 1.8d-46) then
tmp = y * 4.0d0
else
tmp = (-3.0d0) * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -8.2e+68) {
tmp = -3.0 * x;
} else if (x <= 1.8e-46) {
tmp = y * 4.0;
} else {
tmp = -3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.2e+68: tmp = -3.0 * x elif x <= 1.8e-46: tmp = y * 4.0 else: tmp = -3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.2e+68) tmp = Float64(-3.0 * x); elseif (x <= 1.8e-46) tmp = Float64(y * 4.0); else tmp = Float64(-3.0 * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -8.2e+68) tmp = -3.0 * x; elseif (x <= 1.8e-46) tmp = y * 4.0; else tmp = -3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.2e+68], N[(-3.0 * x), $MachinePrecision], If[LessEqual[x, 1.8e-46], N[(y * 4.0), $MachinePrecision], N[(-3.0 * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.2 \cdot 10^{+68}:\\
\;\;\;\;-3 \cdot x\\
\mathbf{elif}\;x \leq 1.8 \cdot 10^{-46}:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot x\\
\end{array}
\end{array}
if x < -8.1999999999999998e68 or 1.8e-46 < x Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.3
Applied rewrites54.3%
Taylor expanded in y around 0
Applied rewrites47.5%
if -8.1999999999999998e68 < x < 1.8e-46Initial program 99.4%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6460.7
Applied rewrites60.7%
Taylor expanded in y around inf
Applied rewrites52.2%
(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.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.5
Applied rewrites57.5%
(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.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.5
Applied rewrites57.5%
Taylor expanded in y around 0
Applied rewrites28.6%
herbie shell --seed 2024255
(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))))