
(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 (- y x) (fma z -6.0 4.0) x))
double code(double x, double y, double z) {
return fma((y - x), fma(z, -6.0, 4.0), x);
}
function code(x, y, z) return fma(Float64(y - x), fma(z, -6.0, 4.0), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.7%
fma-def99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
neg-mul-199.7%
associate-*r*99.7%
*-commutative99.7%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* x z))))
(if (<= z -1.4e+161)
t_0
(if (<= z -3e+17)
(* -6.0 (* y z))
(if (<= z -1.5e-130)
(* x -3.0)
(if (<= z -6.6e-241)
(* y 4.0)
(if (<= z -1.3e-305)
(* x -3.0)
(if (<= z 0.55) (* y 4.0) t_0))))))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -1.4e+161) {
tmp = t_0;
} else if (z <= -3e+17) {
tmp = -6.0 * (y * z);
} else if (z <= -1.5e-130) {
tmp = x * -3.0;
} else if (z <= -6.6e-241) {
tmp = y * 4.0;
} else if (z <= -1.3e-305) {
tmp = x * -3.0;
} else if (z <= 0.55) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = 6.0d0 * (x * z)
if (z <= (-1.4d+161)) then
tmp = t_0
else if (z <= (-3d+17)) then
tmp = (-6.0d0) * (y * z)
else if (z <= (-1.5d-130)) then
tmp = x * (-3.0d0)
else if (z <= (-6.6d-241)) then
tmp = y * 4.0d0
else if (z <= (-1.3d-305)) then
tmp = x * (-3.0d0)
else if (z <= 0.55d0) then
tmp = y * 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -1.4e+161) {
tmp = t_0;
} else if (z <= -3e+17) {
tmp = -6.0 * (y * z);
} else if (z <= -1.5e-130) {
tmp = x * -3.0;
} else if (z <= -6.6e-241) {
tmp = y * 4.0;
} else if (z <= -1.3e-305) {
tmp = x * -3.0;
} else if (z <= 0.55) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (x * z) tmp = 0 if z <= -1.4e+161: tmp = t_0 elif z <= -3e+17: tmp = -6.0 * (y * z) elif z <= -1.5e-130: tmp = x * -3.0 elif z <= -6.6e-241: tmp = y * 4.0 elif z <= -1.3e-305: tmp = x * -3.0 elif z <= 0.55: tmp = y * 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(x * z)) tmp = 0.0 if (z <= -1.4e+161) tmp = t_0; elseif (z <= -3e+17) tmp = Float64(-6.0 * Float64(y * z)); elseif (z <= -1.5e-130) tmp = Float64(x * -3.0); elseif (z <= -6.6e-241) tmp = Float64(y * 4.0); elseif (z <= -1.3e-305) tmp = Float64(x * -3.0); elseif (z <= 0.55) tmp = Float64(y * 4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (x * z); tmp = 0.0; if (z <= -1.4e+161) tmp = t_0; elseif (z <= -3e+17) tmp = -6.0 * (y * z); elseif (z <= -1.5e-130) tmp = x * -3.0; elseif (z <= -6.6e-241) tmp = y * 4.0; elseif (z <= -1.3e-305) tmp = x * -3.0; elseif (z <= 0.55) tmp = y * 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.4e+161], t$95$0, If[LessEqual[z, -3e+17], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.5e-130], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -6.6e-241], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.3e-305], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.55], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{+161}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3 \cdot 10^{+17}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq -1.5 \cdot 10^{-130}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq -6.6 \cdot 10^{-241}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-305}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.4000000000000001e161 or 0.55000000000000004 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around inf 59.7%
*-commutative59.7%
fma-neg59.8%
metadata-eval59.8%
Simplified59.8%
Taylor expanded in z around inf 59.7%
if -1.4000000000000001e161 < z < -3e17Initial program 99.5%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 67.8%
Taylor expanded in z around inf 67.8%
*-commutative67.8%
Simplified67.8%
if -3e17 < z < -1.49999999999999993e-130 or -6.5999999999999998e-241 < z < -1.3000000000000001e-305Initial program 99.3%
Taylor expanded in x around inf 69.7%
*-commutative69.7%
+-commutative69.7%
sub-neg69.7%
distribute-rgt-in69.7%
metadata-eval69.7%
metadata-eval69.7%
neg-mul-169.7%
associate-*r*69.7%
*-commutative69.7%
distribute-lft-in69.7%
+-commutative69.7%
distribute-lft-in69.7%
associate-+r+69.8%
metadata-eval69.8%
metadata-eval69.8%
metadata-eval69.8%
distribute-lft-in69.8%
mul-1-neg69.8%
+-commutative69.8%
fma-def69.8%
Simplified69.8%
Taylor expanded in z around 0 65.9%
*-commutative65.9%
Simplified65.9%
if -1.49999999999999993e-130 < z < -6.5999999999999998e-241 or -1.3000000000000001e-305 < z < 0.55000000000000004Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-in99.8%
neg-mul-199.8%
associate-*r*99.8%
*-commutative99.8%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 59.4%
Taylor expanded in z around 0 59.0%
*-commutative59.0%
Simplified59.0%
Final simplification61.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* (- y x) z))))
(if (<= z -0.0095)
t_0
(if (<= z -5.5e-130)
(* x -3.0)
(if (<= z -1.4e-239)
(* y 4.0)
(if (<= z -5.8e-307) (* x -3.0) (if (<= z 0.56) (* y 4.0) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -0.0095) {
tmp = t_0;
} else if (z <= -5.5e-130) {
tmp = x * -3.0;
} else if (z <= -1.4e-239) {
tmp = y * 4.0;
} else if (z <= -5.8e-307) {
tmp = x * -3.0;
} else if (z <= 0.56) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-6.0d0) * ((y - x) * z)
if (z <= (-0.0095d0)) then
tmp = t_0
else if (z <= (-5.5d-130)) then
tmp = x * (-3.0d0)
else if (z <= (-1.4d-239)) then
tmp = y * 4.0d0
else if (z <= (-5.8d-307)) then
tmp = x * (-3.0d0)
else if (z <= 0.56d0) then
tmp = y * 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -0.0095) {
tmp = t_0;
} else if (z <= -5.5e-130) {
tmp = x * -3.0;
} else if (z <= -1.4e-239) {
tmp = y * 4.0;
} else if (z <= -5.8e-307) {
tmp = x * -3.0;
} else if (z <= 0.56) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * ((y - x) * z) tmp = 0 if z <= -0.0095: tmp = t_0 elif z <= -5.5e-130: tmp = x * -3.0 elif z <= -1.4e-239: tmp = y * 4.0 elif z <= -5.8e-307: tmp = x * -3.0 elif z <= 0.56: tmp = y * 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -0.0095) tmp = t_0; elseif (z <= -5.5e-130) tmp = Float64(x * -3.0); elseif (z <= -1.4e-239) tmp = Float64(y * 4.0); elseif (z <= -5.8e-307) tmp = Float64(x * -3.0); elseif (z <= 0.56) tmp = Float64(y * 4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * ((y - x) * z); tmp = 0.0; if (z <= -0.0095) tmp = t_0; elseif (z <= -5.5e-130) tmp = x * -3.0; elseif (z <= -1.4e-239) tmp = y * 4.0; elseif (z <= -5.8e-307) tmp = x * -3.0; elseif (z <= 0.56) tmp = y * 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.0095], t$95$0, If[LessEqual[z, -5.5e-130], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.4e-239], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -5.8e-307], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.56], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -0.0095:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{-130}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-239}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-307}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 0.56:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -0.00949999999999999976 or 0.56000000000000005 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 99.7%
if -0.00949999999999999976 < z < -5.50000000000000007e-130 or -1.40000000000000006e-239 < z < -5.8000000000000001e-307Initial program 99.3%
Taylor expanded in x around inf 69.2%
*-commutative69.2%
+-commutative69.2%
sub-neg69.2%
distribute-rgt-in69.2%
metadata-eval69.2%
metadata-eval69.2%
neg-mul-169.2%
associate-*r*69.2%
*-commutative69.2%
distribute-lft-in69.2%
+-commutative69.2%
distribute-lft-in69.2%
associate-+r+69.2%
metadata-eval69.2%
metadata-eval69.2%
metadata-eval69.2%
distribute-lft-in69.2%
mul-1-neg69.2%
+-commutative69.2%
fma-def69.2%
Simplified69.2%
Taylor expanded in z around 0 67.0%
*-commutative67.0%
Simplified67.0%
if -5.50000000000000007e-130 < z < -1.40000000000000006e-239 or -5.8000000000000001e-307 < z < 0.56000000000000005Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-in99.8%
neg-mul-199.8%
associate-*r*99.8%
*-commutative99.8%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 59.4%
Taylor expanded in z around 0 59.0%
*-commutative59.0%
Simplified59.0%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* (- y x) z))))
(if (<= z -0.0055)
t_0
(if (<= z -3.45e-131)
(* x -3.0)
(if (<= z -1.05e-240)
(* y 4.0)
(if (<= z -4.2e-305)
(* x -3.0)
(if (<= z 170000.0) (* y (+ 4.0 (* z -6.0))) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -0.0055) {
tmp = t_0;
} else if (z <= -3.45e-131) {
tmp = x * -3.0;
} else if (z <= -1.05e-240) {
tmp = y * 4.0;
} else if (z <= -4.2e-305) {
tmp = x * -3.0;
} else if (z <= 170000.0) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-6.0d0) * ((y - x) * z)
if (z <= (-0.0055d0)) then
tmp = t_0
else if (z <= (-3.45d-131)) then
tmp = x * (-3.0d0)
else if (z <= (-1.05d-240)) then
tmp = y * 4.0d0
else if (z <= (-4.2d-305)) then
tmp = x * (-3.0d0)
else if (z <= 170000.0d0) then
tmp = y * (4.0d0 + (z * (-6.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -6.0 * ((y - x) * z);
double tmp;
if (z <= -0.0055) {
tmp = t_0;
} else if (z <= -3.45e-131) {
tmp = x * -3.0;
} else if (z <= -1.05e-240) {
tmp = y * 4.0;
} else if (z <= -4.2e-305) {
tmp = x * -3.0;
} else if (z <= 170000.0) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * ((y - x) * z) tmp = 0 if z <= -0.0055: tmp = t_0 elif z <= -3.45e-131: tmp = x * -3.0 elif z <= -1.05e-240: tmp = y * 4.0 elif z <= -4.2e-305: tmp = x * -3.0 elif z <= 170000.0: tmp = y * (4.0 + (z * -6.0)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(Float64(y - x) * z)) tmp = 0.0 if (z <= -0.0055) tmp = t_0; elseif (z <= -3.45e-131) tmp = Float64(x * -3.0); elseif (z <= -1.05e-240) tmp = Float64(y * 4.0); elseif (z <= -4.2e-305) tmp = Float64(x * -3.0); elseif (z <= 170000.0) tmp = Float64(y * Float64(4.0 + Float64(z * -6.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * ((y - x) * z); tmp = 0.0; if (z <= -0.0055) tmp = t_0; elseif (z <= -3.45e-131) tmp = x * -3.0; elseif (z <= -1.05e-240) tmp = y * 4.0; elseif (z <= -4.2e-305) tmp = x * -3.0; elseif (z <= 170000.0) tmp = y * (4.0 + (z * -6.0)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.0055], t$95$0, If[LessEqual[z, -3.45e-131], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.05e-240], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -4.2e-305], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 170000.0], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{if}\;z \leq -0.0055:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.45 \cdot 10^{-131}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-240}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq -4.2 \cdot 10^{-305}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 170000:\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -0.0054999999999999997 or 1.7e5 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 99.7%
if -0.0054999999999999997 < z < -3.45000000000000008e-131 or -1.04999999999999997e-240 < z < -4.2e-305Initial program 99.3%
Taylor expanded in x around inf 69.2%
*-commutative69.2%
+-commutative69.2%
sub-neg69.2%
distribute-rgt-in69.2%
metadata-eval69.2%
metadata-eval69.2%
neg-mul-169.2%
associate-*r*69.2%
*-commutative69.2%
distribute-lft-in69.2%
+-commutative69.2%
distribute-lft-in69.2%
associate-+r+69.2%
metadata-eval69.2%
metadata-eval69.2%
metadata-eval69.2%
distribute-lft-in69.2%
mul-1-neg69.2%
+-commutative69.2%
fma-def69.2%
Simplified69.2%
Taylor expanded in z around 0 67.0%
*-commutative67.0%
Simplified67.0%
if -3.45000000000000008e-131 < z < -1.04999999999999997e-240Initial program 99.2%
+-commutative99.2%
associate-*l*99.9%
fma-def99.9%
sub-neg99.9%
+-commutative99.9%
distribute-lft-in99.9%
neg-mul-199.9%
associate-*r*99.9%
*-commutative99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 64.7%
Taylor expanded in z around 0 64.7%
*-commutative64.7%
Simplified64.7%
if -4.2e-305 < z < 1.7e5Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-in99.8%
neg-mul-199.8%
associate-*r*99.8%
*-commutative99.8%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 57.5%
Final simplification80.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* y z))))
(if (<= z -3e+17)
t_0
(if (<= z -2.8e-131)
(* x -3.0)
(if (<= z -7.2e-241)
(* y 4.0)
(if (<= z -1.25e-306)
(* x -3.0)
(if (<= z 7.2e+15) (* y 4.0) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -3e+17) {
tmp = t_0;
} else if (z <= -2.8e-131) {
tmp = x * -3.0;
} else if (z <= -7.2e-241) {
tmp = y * 4.0;
} else if (z <= -1.25e-306) {
tmp = x * -3.0;
} else if (z <= 7.2e+15) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-6.0d0) * (y * z)
if (z <= (-3d+17)) then
tmp = t_0
else if (z <= (-2.8d-131)) then
tmp = x * (-3.0d0)
else if (z <= (-7.2d-241)) then
tmp = y * 4.0d0
else if (z <= (-1.25d-306)) then
tmp = x * (-3.0d0)
else if (z <= 7.2d+15) then
tmp = y * 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -3e+17) {
tmp = t_0;
} else if (z <= -2.8e-131) {
tmp = x * -3.0;
} else if (z <= -7.2e-241) {
tmp = y * 4.0;
} else if (z <= -1.25e-306) {
tmp = x * -3.0;
} else if (z <= 7.2e+15) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (y * z) tmp = 0 if z <= -3e+17: tmp = t_0 elif z <= -2.8e-131: tmp = x * -3.0 elif z <= -7.2e-241: tmp = y * 4.0 elif z <= -1.25e-306: tmp = x * -3.0 elif z <= 7.2e+15: tmp = y * 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(y * z)) tmp = 0.0 if (z <= -3e+17) tmp = t_0; elseif (z <= -2.8e-131) tmp = Float64(x * -3.0); elseif (z <= -7.2e-241) tmp = Float64(y * 4.0); elseif (z <= -1.25e-306) tmp = Float64(x * -3.0); elseif (z <= 7.2e+15) tmp = Float64(y * 4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * (y * z); tmp = 0.0; if (z <= -3e+17) tmp = t_0; elseif (z <= -2.8e-131) tmp = x * -3.0; elseif (z <= -7.2e-241) tmp = y * 4.0; elseif (z <= -1.25e-306) tmp = x * -3.0; elseif (z <= 7.2e+15) tmp = y * 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3e+17], t$95$0, If[LessEqual[z, -2.8e-131], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -7.2e-241], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.25e-306], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 7.2e+15], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -3 \cdot 10^{+17}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{-131}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq -7.2 \cdot 10^{-241}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq -1.25 \cdot 10^{-306}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+15}:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3e17 or 7.2e15 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 49.6%
Taylor expanded in z around inf 49.6%
*-commutative49.6%
Simplified49.6%
if -3e17 < z < -2.8e-131 or -7.1999999999999998e-241 < z < -1.25e-306Initial program 99.3%
Taylor expanded in x around inf 69.7%
*-commutative69.7%
+-commutative69.7%
sub-neg69.7%
distribute-rgt-in69.7%
metadata-eval69.7%
metadata-eval69.7%
neg-mul-169.7%
associate-*r*69.7%
*-commutative69.7%
distribute-lft-in69.7%
+-commutative69.7%
distribute-lft-in69.7%
associate-+r+69.8%
metadata-eval69.8%
metadata-eval69.8%
metadata-eval69.8%
distribute-lft-in69.8%
mul-1-neg69.8%
+-commutative69.8%
fma-def69.8%
Simplified69.8%
Taylor expanded in z around 0 65.9%
*-commutative65.9%
Simplified65.9%
if -2.8e-131 < z < -7.1999999999999998e-241 or -1.25e-306 < z < 7.2e15Initial program 99.4%
+-commutative99.4%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
+-commutative99.8%
distribute-lft-in99.9%
neg-mul-199.9%
associate-*r*99.9%
*-commutative99.9%
fma-def99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 58.7%
Taylor expanded in z around 0 58.4%
*-commutative58.4%
Simplified58.4%
Final simplification55.8%
(FPCore (x y z) :precision binary64 (+ (* (- y x) 4.0) (+ x (* -6.0 (* (- y x) z)))))
double code(double x, double y, double z) {
return ((y - x) * 4.0) + (x + (-6.0 * ((y - x) * z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = ((y - x) * 4.0d0) + (x + ((-6.0d0) * ((y - x) * z)))
end function
public static double code(double x, double y, double z) {
return ((y - x) * 4.0) + (x + (-6.0 * ((y - x) * z)));
}
def code(x, y, z): return ((y - x) * 4.0) + (x + (-6.0 * ((y - x) * z)))
function code(x, y, z) return Float64(Float64(Float64(y - x) * 4.0) + Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z)))) end
function tmp = code(x, y, z) tmp = ((y - x) * 4.0) + (x + (-6.0 * ((y - x) * z))); end
code[x_, y_, z_] := N[(N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision] + N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y - x\right) \cdot 4 + \left(x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\right)
\end{array}
Initial program 99.5%
Taylor expanded in z around 0 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -50000000000000.0) (not (<= x 1.15e-24))) (* x (- (* z 6.0) 3.0)) (* y (+ 4.0 (* z -6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -50000000000000.0) || !(x <= 1.15e-24)) {
tmp = x * ((z * 6.0) - 3.0);
} else {
tmp = y * (4.0 + (z * -6.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 ((x <= (-50000000000000.0d0)) .or. (.not. (x <= 1.15d-24))) then
tmp = x * ((z * 6.0d0) - 3.0d0)
else
tmp = y * (4.0d0 + (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -50000000000000.0) || !(x <= 1.15e-24)) {
tmp = x * ((z * 6.0) - 3.0);
} else {
tmp = y * (4.0 + (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -50000000000000.0) or not (x <= 1.15e-24): tmp = x * ((z * 6.0) - 3.0) else: tmp = y * (4.0 + (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -50000000000000.0) || !(x <= 1.15e-24)) tmp = Float64(x * Float64(Float64(z * 6.0) - 3.0)); else tmp = Float64(y * Float64(4.0 + Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -50000000000000.0) || ~((x <= 1.15e-24))) tmp = x * ((z * 6.0) - 3.0); else tmp = y * (4.0 + (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -50000000000000.0], N[Not[LessEqual[x, 1.15e-24]], $MachinePrecision]], N[(x * N[(N[(z * 6.0), $MachinePrecision] - 3.0), $MachinePrecision]), $MachinePrecision], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -50000000000000 \lor \neg \left(x \leq 1.15 \cdot 10^{-24}\right):\\
\;\;\;\;x \cdot \left(z \cdot 6 - 3\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\
\end{array}
\end{array}
if x < -5e13 or 1.1500000000000001e-24 < x Initial program 99.5%
Taylor expanded in z around 0 99.8%
Taylor expanded in x around inf 85.1%
if -5e13 < x < 1.1500000000000001e-24Initial program 99.5%
+-commutative99.5%
associate-*l*99.7%
fma-def99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
neg-mul-199.7%
associate-*r*99.7%
*-commutative99.7%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 82.3%
Final simplification83.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.58) (not (<= z 0.6))) (* -6.0 (* (- y x) z)) (+ (* x -3.0) (* y 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.58) || !(z <= 0.6)) {
tmp = -6.0 * ((y - x) * z);
} else {
tmp = (x * -3.0) + (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 ((z <= (-0.58d0)) .or. (.not. (z <= 0.6d0))) then
tmp = (-6.0d0) * ((y - x) * z)
else
tmp = (x * (-3.0d0)) + (y * 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.58) || !(z <= 0.6)) {
tmp = -6.0 * ((y - x) * z);
} else {
tmp = (x * -3.0) + (y * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.58) or not (z <= 0.6): tmp = -6.0 * ((y - x) * z) else: tmp = (x * -3.0) + (y * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.58) || !(z <= 0.6)) tmp = Float64(-6.0 * Float64(Float64(y - x) * z)); else tmp = Float64(Float64(x * -3.0) + Float64(y * 4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.58) || ~((z <= 0.6))) tmp = -6.0 * ((y - x) * z); else tmp = (x * -3.0) + (y * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.58], N[Not[LessEqual[z, 0.6]], $MachinePrecision]], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(x * -3.0), $MachinePrecision] + N[(y * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.58 \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\
\end{array}
\end{array}
if z < -0.57999999999999996 or 0.599999999999999978 < z Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in z around inf 99.7%
if -0.57999999999999996 < z < 0.599999999999999978Initial program 99.4%
Taylor expanded in z around 0 98.5%
Taylor expanded in x around 0 98.5%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 (- 0.6666666666666666 z)))))
double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - 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 * (0.6666666666666666d0 - z)))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
def code(x, y, z): return x + ((y - x) * (6.0 * (0.6666666666666666 - z)))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(6.0 * Float64(0.6666666666666666 - z)))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (6.0 * (0.6666666666666666 - z))); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)
\end{array}
Initial program 99.5%
associate-*l*99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= x -5.3e-70) (* x -3.0) (if (<= x 2.1e-27) (* y 4.0) (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5.3e-70) {
tmp = x * -3.0;
} else if (x <= 2.1e-27) {
tmp = y * 4.0;
} else {
tmp = x * -3.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 (x <= (-5.3d-70)) then
tmp = x * (-3.0d0)
else if (x <= 2.1d-27) then
tmp = y * 4.0d0
else
tmp = x * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -5.3e-70) {
tmp = x * -3.0;
} else if (x <= 2.1e-27) {
tmp = y * 4.0;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5.3e-70: tmp = x * -3.0 elif x <= 2.1e-27: tmp = y * 4.0 else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -5.3e-70) tmp = Float64(x * -3.0); elseif (x <= 2.1e-27) tmp = Float64(y * 4.0); else tmp = Float64(x * -3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -5.3e-70) tmp = x * -3.0; elseif (x <= 2.1e-27) tmp = y * 4.0; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5.3e-70], N[(x * -3.0), $MachinePrecision], If[LessEqual[x, 2.1e-27], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.3 \cdot 10^{-70}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-27}:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if x < -5.29999999999999983e-70 or 2.10000000000000015e-27 < x Initial program 99.5%
Taylor expanded in x around inf 80.2%
*-commutative80.2%
+-commutative80.2%
sub-neg80.2%
distribute-rgt-in80.2%
metadata-eval80.2%
metadata-eval80.2%
neg-mul-180.2%
associate-*r*80.2%
*-commutative80.2%
distribute-lft-in80.2%
+-commutative80.2%
distribute-lft-in80.2%
associate-+r+80.2%
metadata-eval80.2%
metadata-eval80.2%
metadata-eval80.2%
distribute-lft-in80.2%
mul-1-neg80.2%
+-commutative80.2%
fma-def80.3%
Simplified80.3%
Taylor expanded in z around 0 43.1%
*-commutative43.1%
Simplified43.1%
if -5.29999999999999983e-70 < x < 2.10000000000000015e-27Initial program 99.5%
+-commutative99.5%
associate-*l*99.7%
fma-def99.7%
sub-neg99.7%
+-commutative99.7%
distribute-lft-in99.7%
neg-mul-199.7%
associate-*r*99.7%
*-commutative99.7%
fma-def99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 84.3%
Taylor expanded in z around 0 47.2%
*-commutative47.2%
Simplified47.2%
Final simplification44.8%
(FPCore (x y z) :precision binary64 (* x -3.0))
double code(double x, double y, double z) {
return x * -3.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (-3.0d0)
end function
public static double code(double x, double y, double z) {
return x * -3.0;
}
def code(x, y, z): return x * -3.0
function code(x, y, z) return Float64(x * -3.0) end
function tmp = code(x, y, z) tmp = x * -3.0; end
code[x_, y_, z_] := N[(x * -3.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot -3
\end{array}
Initial program 99.5%
Taylor expanded in x around inf 53.6%
*-commutative53.6%
+-commutative53.6%
sub-neg53.6%
distribute-rgt-in53.6%
metadata-eval53.6%
metadata-eval53.6%
neg-mul-153.6%
associate-*r*53.6%
*-commutative53.6%
distribute-lft-in53.6%
+-commutative53.6%
distribute-lft-in53.6%
associate-+r+53.6%
metadata-eval53.6%
metadata-eval53.6%
metadata-eval53.6%
distribute-lft-in53.6%
mul-1-neg53.6%
+-commutative53.6%
fma-def53.7%
Simplified53.7%
Taylor expanded in z around 0 28.2%
*-commutative28.2%
Simplified28.2%
Final simplification28.2%
herbie shell --seed 2023214
(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))))