
(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 11 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 (or (<= t_0 -10000.0) (not (<= t_0 1.0)))
(* (* (- y x) z) -6.0)
(fma -3.0 x (* 4.0 y)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) {
tmp = ((y - x) * z) * -6.0;
} else {
tmp = fma(-3.0, x, (4.0 * y));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) 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_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1.0]], $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}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1\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 (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.9
Applied rewrites97.9%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
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%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification97.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 1.0)))
(* (fma -6.0 z 4.0) y)
(fma -3.0 x (* 4.0 y)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = fma(-3.0, x, (4.0 * y));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = fma(-3.0, x, Float64(4.0 * y)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1.0]], $MachinePrecision]], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1\right):\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6466.0
Applied rewrites66.0%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1Initial program 99.3%
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%
Taylor expanded in z around 0
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-+r+N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f6496.9
Applied rewrites96.9%
Final simplification81.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 1.0)))
(* (fma -6.0 z 4.0) y)
(fma (- y x) 4.0 x))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) {
tmp = fma(-6.0, z, 4.0) * y;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) tmp = Float64(fma(-6.0, z, 4.0) * y); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1.0]], $MachinePrecision]], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1\right):\\
\;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-lft-inN/A
associate-*r*N/A
metadata-evalN/A
metadata-evalN/A
lower-fma.f6466.0
Applied rewrites66.0%
if -1e4 < (-.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--.f6496.8
Applied rewrites96.8%
Final simplification81.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 1.0)))
(* (* y z) -6.0)
(fma (- y x) 4.0 x))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) {
tmp = (y * z) * -6.0;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) tmp = Float64(Float64(y * z) * -6.0); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1.0]], $MachinePrecision]], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1\right):\\
\;\;\;\;\left(y \cdot z\right) \cdot -6\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites64.6%
if -1e4 < (-.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--.f6496.8
Applied rewrites96.8%
Final simplification81.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 1.0)))
(* (* y -6.0) z)
(fma (- y x) 4.0 x))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) {
tmp = (y * -6.0) * z;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1.0)) tmp = Float64(Float64(y * -6.0) * z); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1.0]], $MachinePrecision]], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1\right):\\
\;\;\;\;\left(y \cdot -6\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6499.7
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6497.9
Applied rewrites97.9%
Taylor expanded in x around 0
Applied rewrites64.6%
if -1e4 < (-.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--.f6496.8
Applied rewrites96.8%
Final simplification81.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (or (<= t_0 -10000.0) (not (<= t_0 1000000000000.0)))
(* (* 6.0 z) x)
(fma (- y x) 4.0 x))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if ((t_0 <= -10000.0) || !(t_0 <= 1000000000000.0)) {
tmp = (6.0 * z) * x;
} else {
tmp = fma((y - x), 4.0, x);
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if ((t_0 <= -10000.0) || !(t_0 <= 1000000000000.0)) tmp = Float64(Float64(6.0 * z) * x); else tmp = fma(Float64(y - x), 4.0, x); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -10000.0], N[Not[LessEqual[t$95$0, 1000000000000.0]], $MachinePrecision]], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000 \lor \neg \left(t\_0 \leq 1000000000000\right):\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4 or 1e12 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.8%
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.9
Applied rewrites99.9%
Taylor expanded in x around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites41.9%
Taylor expanded in z around inf
Applied rewrites41.4%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1e12Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6494.9
Applied rewrites94.9%
Final simplification69.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ 2.0 3.0) z)))
(if (<= t_0 -10000.0)
(* (* 6.0 z) x)
(if (<= t_0 1000000000000.0) (fma (- y x) 4.0 x) (* (* x z) 6.0)))))
double code(double x, double y, double z) {
double t_0 = (2.0 / 3.0) - z;
double tmp;
if (t_0 <= -10000.0) {
tmp = (6.0 * z) * x;
} else if (t_0 <= 1000000000000.0) {
tmp = fma((y - x), 4.0, x);
} else {
tmp = (x * z) * 6.0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(2.0 / 3.0) - z) tmp = 0.0 if (t_0 <= -10000.0) tmp = Float64(Float64(6.0 * z) * x); elseif (t_0 <= 1000000000000.0) tmp = fma(Float64(y - x), 4.0, x); else tmp = Float64(Float64(x * z) * 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, -10000.0], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[t$95$0, 1000000000000.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * 6.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -10000:\\
\;\;\;\;\left(6 \cdot z\right) \cdot x\\
\mathbf{elif}\;t\_0 \leq 1000000000000:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot 6\\
\end{array}
\end{array}
if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e4Initial program 99.7%
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%
Taylor expanded in x around inf
*-commutativeN/A
+-commutativeN/A
distribute-lft-inN/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-inN/A
neg-mul-1N/A
sub-negN/A
+-commutativeN/A
lower-*.f64N/A
Applied rewrites37.1%
Taylor expanded in z around inf
Applied rewrites36.5%
if -1e4 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1e12Initial program 99.3%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6494.9
Applied rewrites94.9%
if 1e12 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) Initial program 99.9%
lift-+.f64N/A
flip-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip-+N/A
lift-+.f64N/A
lower-/.f6499.8
lift-+.f64N/A
+-commutativeN/A
Applied rewrites99.8%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites46.2%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.45e+16) (not (<= y 4.25e+68))) (* 4.0 y) (* -3.0 x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.45e+16) || !(y <= 4.25e+68)) {
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 <= (-2.45d+16)) .or. (.not. (y <= 4.25d+68))) 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 <= -2.45e+16) || !(y <= 4.25e+68)) {
tmp = 4.0 * y;
} else {
tmp = -3.0 * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.45e+16) or not (y <= 4.25e+68): tmp = 4.0 * y else: tmp = -3.0 * x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.45e+16) || !(y <= 4.25e+68)) 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 <= -2.45e+16) || ~((y <= 4.25e+68))) tmp = 4.0 * y; else tmp = -3.0 * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.45e+16], N[Not[LessEqual[y, 4.25e+68]], $MachinePrecision]], N[(4.0 * y), $MachinePrecision], N[(-3.0 * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45 \cdot 10^{+16} \lor \neg \left(y \leq 4.25 \cdot 10^{+68}\right):\\
\;\;\;\;4 \cdot y\\
\mathbf{else}:\\
\;\;\;\;-3 \cdot x\\
\end{array}
\end{array}
if y < -2.45e16 or 4.24999999999999983e68 < y Initial program 99.6%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6446.7
Applied rewrites46.7%
Taylor expanded in x around 0
Applied rewrites37.6%
if -2.45e16 < y < 4.24999999999999983e68Initial program 99.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.5
Applied rewrites56.5%
Taylor expanded in x around inf
Applied rewrites47.1%
Final simplification42.6%
(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--.f6451.8
Applied rewrites51.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.5%
Taylor expanded in z around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6451.8
Applied rewrites51.8%
Taylor expanded in x around inf
Applied rewrites29.7%
herbie shell --seed 2024313
(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))))