
(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 10 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) (+ 4.0 (* z -6.0)) x))
double code(double x, double y, double z) {
return fma((y - x), (4.0 + (z * -6.0)), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(4.0 + Float64(z * -6.0)), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* y z))))
(if (<= z -0.68)
t_0
(if (<= z -2.15e-293)
(* y 4.0)
(if (<= z 4.8e-282)
(* x -3.0)
(if (<= z 3.2e-98) (* y 4.0) (if (<= z 0.52) (* x -3.0) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (y * z);
double tmp;
if (z <= -0.68) {
tmp = t_0;
} else if (z <= -2.15e-293) {
tmp = y * 4.0;
} else if (z <= 4.8e-282) {
tmp = x * -3.0;
} else if (z <= 3.2e-98) {
tmp = y * 4.0;
} else if (z <= 0.52) {
tmp = x * -3.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 <= (-0.68d0)) then
tmp = t_0
else if (z <= (-2.15d-293)) then
tmp = y * 4.0d0
else if (z <= 4.8d-282) then
tmp = x * (-3.0d0)
else if (z <= 3.2d-98) then
tmp = y * 4.0d0
else if (z <= 0.52d0) then
tmp = x * (-3.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 <= -0.68) {
tmp = t_0;
} else if (z <= -2.15e-293) {
tmp = y * 4.0;
} else if (z <= 4.8e-282) {
tmp = x * -3.0;
} else if (z <= 3.2e-98) {
tmp = y * 4.0;
} else if (z <= 0.52) {
tmp = x * -3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (y * z) tmp = 0 if z <= -0.68: tmp = t_0 elif z <= -2.15e-293: tmp = y * 4.0 elif z <= 4.8e-282: tmp = x * -3.0 elif z <= 3.2e-98: tmp = y * 4.0 elif z <= 0.52: tmp = x * -3.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 <= -0.68) tmp = t_0; elseif (z <= -2.15e-293) tmp = Float64(y * 4.0); elseif (z <= 4.8e-282) tmp = Float64(x * -3.0); elseif (z <= 3.2e-98) tmp = Float64(y * 4.0); elseif (z <= 0.52) tmp = Float64(x * -3.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 <= -0.68) tmp = t_0; elseif (z <= -2.15e-293) tmp = y * 4.0; elseif (z <= 4.8e-282) tmp = x * -3.0; elseif (z <= 3.2e-98) tmp = y * 4.0; elseif (z <= 0.52) tmp = x * -3.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, -0.68], t$95$0, If[LessEqual[z, -2.15e-293], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 4.8e-282], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 3.2e-98], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.52], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -0.68:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.15 \cdot 10^{-293}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-282}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-98}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.52:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.680000000000000049 or 0.52000000000000002 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.7%
fma-def99.7%
sub-neg99.7%
distribute-rgt-in99.7%
metadata-eval99.7%
metadata-eval99.7%
distribute-lft-neg-out99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 56.9%
Taylor expanded in z around inf 56.0%
if -0.680000000000000049 < z < -2.1499999999999999e-293 or 4.79999999999999994e-282 < z < 3.2000000000000001e-98Initial program 99.5%
+-commutative99.5%
associate-*l*99.9%
fma-def99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 100.0%
Taylor expanded in z around inf 60.6%
associate-*r*60.6%
*-commutative60.6%
Simplified60.6%
Taylor expanded in z around 0 59.2%
if -2.1499999999999999e-293 < z < 4.79999999999999994e-282 or 3.2000000000000001e-98 < z < 0.52000000000000002Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 73.6%
sub-neg73.6%
distribute-rgt-in73.6%
metadata-eval73.6%
metadata-eval73.6%
neg-mul-173.6%
associate-*r*73.6%
*-commutative73.6%
associate-+r+73.6%
*-commutative73.6%
metadata-eval73.6%
metadata-eval73.6%
*-commutative73.6%
associate-*l*73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in z around 0 71.7%
*-commutative71.7%
Simplified71.7%
Final simplification58.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1040000000.0)
(* 6.0 (* x z))
(if (<= z -1.05e-291)
(* y 4.0)
(if (<= z 2.25e-284)
(* x -3.0)
(if (<= z 1.6e-97)
(* y 4.0)
(if (<= z 0.55) (* x -3.0) (* -6.0 (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1040000000.0) {
tmp = 6.0 * (x * z);
} else if (z <= -1.05e-291) {
tmp = y * 4.0;
} else if (z <= 2.25e-284) {
tmp = x * -3.0;
} else if (z <= 1.6e-97) {
tmp = y * 4.0;
} else if (z <= 0.55) {
tmp = x * -3.0;
} else {
tmp = -6.0 * (y * z);
}
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 <= (-1040000000.0d0)) then
tmp = 6.0d0 * (x * z)
else if (z <= (-1.05d-291)) then
tmp = y * 4.0d0
else if (z <= 2.25d-284) then
tmp = x * (-3.0d0)
else if (z <= 1.6d-97) then
tmp = y * 4.0d0
else if (z <= 0.55d0) then
tmp = x * (-3.0d0)
else
tmp = (-6.0d0) * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1040000000.0) {
tmp = 6.0 * (x * z);
} else if (z <= -1.05e-291) {
tmp = y * 4.0;
} else if (z <= 2.25e-284) {
tmp = x * -3.0;
} else if (z <= 1.6e-97) {
tmp = y * 4.0;
} else if (z <= 0.55) {
tmp = x * -3.0;
} else {
tmp = -6.0 * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1040000000.0: tmp = 6.0 * (x * z) elif z <= -1.05e-291: tmp = y * 4.0 elif z <= 2.25e-284: tmp = x * -3.0 elif z <= 1.6e-97: tmp = y * 4.0 elif z <= 0.55: tmp = x * -3.0 else: tmp = -6.0 * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1040000000.0) tmp = Float64(6.0 * Float64(x * z)); elseif (z <= -1.05e-291) tmp = Float64(y * 4.0); elseif (z <= 2.25e-284) tmp = Float64(x * -3.0); elseif (z <= 1.6e-97) tmp = Float64(y * 4.0); elseif (z <= 0.55) tmp = Float64(x * -3.0); else tmp = Float64(-6.0 * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1040000000.0) tmp = 6.0 * (x * z); elseif (z <= -1.05e-291) tmp = y * 4.0; elseif (z <= 2.25e-284) tmp = x * -3.0; elseif (z <= 1.6e-97) tmp = y * 4.0; elseif (z <= 0.55) tmp = x * -3.0; else tmp = -6.0 * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1040000000.0], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.05e-291], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 2.25e-284], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.6e-97], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.55], N[(x * -3.0), $MachinePrecision], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1040000000:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq -1.05 \cdot 10^{-291}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{-284}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-97}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.04e9Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 55.9%
sub-neg55.9%
distribute-rgt-in55.9%
metadata-eval55.9%
metadata-eval55.9%
neg-mul-155.9%
associate-*r*55.9%
*-commutative55.9%
associate-+r+55.9%
*-commutative55.9%
metadata-eval55.9%
metadata-eval55.9%
*-commutative55.9%
associate-*l*55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in z around inf 55.2%
if -1.04e9 < z < -1.05e-291 or 2.25e-284 < z < 1.5999999999999999e-97Initial program 99.5%
+-commutative99.5%
associate-*l*99.9%
fma-def99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 100.0%
Taylor expanded in z around inf 61.5%
associate-*r*61.5%
*-commutative61.5%
Simplified61.5%
Taylor expanded in z around 0 58.1%
if -1.05e-291 < z < 2.25e-284 or 1.5999999999999999e-97 < z < 0.55000000000000004Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 73.6%
sub-neg73.6%
distribute-rgt-in73.6%
metadata-eval73.6%
metadata-eval73.6%
neg-mul-173.6%
associate-*r*73.6%
*-commutative73.6%
associate-+r+73.6%
*-commutative73.6%
metadata-eval73.6%
metadata-eval73.6%
*-commutative73.6%
associate-*l*73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in z around 0 71.7%
*-commutative71.7%
Simplified71.7%
if 0.55000000000000004 < z Initial program 99.6%
+-commutative99.6%
associate-*l*99.6%
fma-def99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 60.5%
Taylor expanded in z around inf 60.2%
Final simplification59.5%
(FPCore (x y z)
:precision binary64
(if (<= z -1040000000.0)
(* x (* z 6.0))
(if (<= z -5.6e-292)
(* y 4.0)
(if (<= z 3.6e-283)
(* x -3.0)
(if (<= z 1.45e-97)
(* y 4.0)
(if (<= z 0.65) (* x -3.0) (* -6.0 (* y z))))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1040000000.0) {
tmp = x * (z * 6.0);
} else if (z <= -5.6e-292) {
tmp = y * 4.0;
} else if (z <= 3.6e-283) {
tmp = x * -3.0;
} else if (z <= 1.45e-97) {
tmp = y * 4.0;
} else if (z <= 0.65) {
tmp = x * -3.0;
} else {
tmp = -6.0 * (y * z);
}
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 <= (-1040000000.0d0)) then
tmp = x * (z * 6.0d0)
else if (z <= (-5.6d-292)) then
tmp = y * 4.0d0
else if (z <= 3.6d-283) then
tmp = x * (-3.0d0)
else if (z <= 1.45d-97) then
tmp = y * 4.0d0
else if (z <= 0.65d0) then
tmp = x * (-3.0d0)
else
tmp = (-6.0d0) * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1040000000.0) {
tmp = x * (z * 6.0);
} else if (z <= -5.6e-292) {
tmp = y * 4.0;
} else if (z <= 3.6e-283) {
tmp = x * -3.0;
} else if (z <= 1.45e-97) {
tmp = y * 4.0;
} else if (z <= 0.65) {
tmp = x * -3.0;
} else {
tmp = -6.0 * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1040000000.0: tmp = x * (z * 6.0) elif z <= -5.6e-292: tmp = y * 4.0 elif z <= 3.6e-283: tmp = x * -3.0 elif z <= 1.45e-97: tmp = y * 4.0 elif z <= 0.65: tmp = x * -3.0 else: tmp = -6.0 * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1040000000.0) tmp = Float64(x * Float64(z * 6.0)); elseif (z <= -5.6e-292) tmp = Float64(y * 4.0); elseif (z <= 3.6e-283) tmp = Float64(x * -3.0); elseif (z <= 1.45e-97) tmp = Float64(y * 4.0); elseif (z <= 0.65) tmp = Float64(x * -3.0); else tmp = Float64(-6.0 * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1040000000.0) tmp = x * (z * 6.0); elseif (z <= -5.6e-292) tmp = y * 4.0; elseif (z <= 3.6e-283) tmp = x * -3.0; elseif (z <= 1.45e-97) tmp = y * 4.0; elseif (z <= 0.65) tmp = x * -3.0; else tmp = -6.0 * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1040000000.0], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5.6e-292], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 3.6e-283], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.45e-97], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.65], N[(x * -3.0), $MachinePrecision], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1040000000:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq -5.6 \cdot 10^{-292}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{-283}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-97}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.04e9Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 55.9%
sub-neg55.9%
distribute-rgt-in55.9%
metadata-eval55.9%
metadata-eval55.9%
neg-mul-155.9%
associate-*r*55.9%
*-commutative55.9%
associate-+r+55.9%
*-commutative55.9%
metadata-eval55.9%
metadata-eval55.9%
*-commutative55.9%
associate-*l*55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in z around inf 55.2%
*-commutative55.2%
Simplified55.2%
if -1.04e9 < z < -5.6000000000000003e-292 or 3.6e-283 < z < 1.45e-97Initial program 99.5%
+-commutative99.5%
associate-*l*99.9%
fma-def99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 100.0%
Taylor expanded in z around inf 61.5%
associate-*r*61.5%
*-commutative61.5%
Simplified61.5%
Taylor expanded in z around 0 58.1%
if -5.6000000000000003e-292 < z < 3.6e-283 or 1.45e-97 < z < 0.650000000000000022Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 73.6%
sub-neg73.6%
distribute-rgt-in73.6%
metadata-eval73.6%
metadata-eval73.6%
neg-mul-173.6%
associate-*r*73.6%
*-commutative73.6%
associate-+r+73.6%
*-commutative73.6%
metadata-eval73.6%
metadata-eval73.6%
*-commutative73.6%
associate-*l*73.6%
metadata-eval73.6%
Simplified73.6%
Taylor expanded in z around 0 71.7%
*-commutative71.7%
Simplified71.7%
if 0.650000000000000022 < z Initial program 99.6%
+-commutative99.6%
associate-*l*99.6%
fma-def99.6%
sub-neg99.6%
distribute-rgt-in99.6%
metadata-eval99.6%
metadata-eval99.6%
distribute-lft-neg-out99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 60.5%
Taylor expanded in z around inf 60.2%
Final simplification59.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (+ -3.0 (* z 6.0)))))
(if (<= x -3.75e-62)
t_0
(if (<= x 5.9e-102) (* -6.0 (* y z)) (if (<= x 1.85e-8) (* y 4.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (-3.0 + (z * 6.0));
double tmp;
if (x <= -3.75e-62) {
tmp = t_0;
} else if (x <= 5.9e-102) {
tmp = -6.0 * (y * z);
} else if (x <= 1.85e-8) {
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 = x * ((-3.0d0) + (z * 6.0d0))
if (x <= (-3.75d-62)) then
tmp = t_0
else if (x <= 5.9d-102) then
tmp = (-6.0d0) * (y * z)
else if (x <= 1.85d-8) 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 = x * (-3.0 + (z * 6.0));
double tmp;
if (x <= -3.75e-62) {
tmp = t_0;
} else if (x <= 5.9e-102) {
tmp = -6.0 * (y * z);
} else if (x <= 1.85e-8) {
tmp = y * 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (-3.0 + (z * 6.0)) tmp = 0 if x <= -3.75e-62: tmp = t_0 elif x <= 5.9e-102: tmp = -6.0 * (y * z) elif x <= 1.85e-8: tmp = y * 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-3.0 + Float64(z * 6.0))) tmp = 0.0 if (x <= -3.75e-62) tmp = t_0; elseif (x <= 5.9e-102) tmp = Float64(-6.0 * Float64(y * z)); elseif (x <= 1.85e-8) tmp = Float64(y * 4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (-3.0 + (z * 6.0)); tmp = 0.0; if (x <= -3.75e-62) tmp = t_0; elseif (x <= 5.9e-102) tmp = -6.0 * (y * z); elseif (x <= 1.85e-8) tmp = y * 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.75e-62], t$95$0, If[LessEqual[x, 5.9e-102], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.85e-8], N[(y * 4.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{if}\;x \leq -3.75 \cdot 10^{-62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5.9 \cdot 10^{-102}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{-8}:\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.75000000000000015e-62 or 1.85e-8 < x Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 75.3%
sub-neg75.3%
distribute-rgt-in75.3%
metadata-eval75.3%
metadata-eval75.3%
neg-mul-175.3%
associate-*r*75.3%
*-commutative75.3%
associate-+r+75.3%
*-commutative75.3%
metadata-eval75.3%
metadata-eval75.3%
*-commutative75.3%
associate-*l*75.3%
metadata-eval75.3%
Simplified75.3%
if -3.75000000000000015e-62 < x < 5.9000000000000003e-102Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 82.8%
Taylor expanded in z around inf 48.2%
if 5.9000000000000003e-102 < x < 1.85e-8Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 99.9%
Taylor expanded in z around inf 81.1%
associate-*r*81.1%
*-commutative81.1%
Simplified81.1%
Taylor expanded in z around 0 60.3%
Final simplification63.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.68) (not (<= z 0.6))) (+ x (* -6.0 (* (- y x) z))) (+ (* y 4.0) (* x -3.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.6)) {
tmp = x + (-6.0 * ((y - x) * z));
} else {
tmp = (y * 4.0) + (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 ((z <= (-0.68d0)) .or. (.not. (z <= 0.6d0))) then
tmp = x + ((-6.0d0) * ((y - x) * z))
else
tmp = (y * 4.0d0) + (x * (-3.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.6)) {
tmp = x + (-6.0 * ((y - x) * z));
} else {
tmp = (y * 4.0) + (x * -3.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.68) or not (z <= 0.6): tmp = x + (-6.0 * ((y - x) * z)) else: tmp = (y * 4.0) + (x * -3.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.68) || !(z <= 0.6)) tmp = Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z))); else tmp = Float64(Float64(y * 4.0) + Float64(x * -3.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.68) || ~((z <= 0.6))) tmp = x + (-6.0 * ((y - x) * z)); else tmp = (y * 4.0) + (x * -3.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.68], N[Not[LessEqual[z, 0.6]], $MachinePrecision]], N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * 4.0), $MachinePrecision] + N[(x * -3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.68 \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\
\end{array}
\end{array}
if z < -0.680000000000000049 or 0.599999999999999978 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 97.9%
if -0.680000000000000049 < z < 0.599999999999999978Initial program 99.5%
+-commutative99.5%
associate-*l*99.9%
fma-def99.9%
sub-neg99.9%
distribute-rgt-in99.9%
metadata-eval99.9%
metadata-eval99.9%
distribute-lft-neg-out99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around -inf 100.0%
Taylor expanded in z around 0 98.2%
Final simplification98.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -8e+48) (not (<= y 4.4e-122))) (* y (+ 4.0 (* z -6.0))) (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+48) || !(y <= 4.4e-122)) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = x * (-3.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 ((y <= (-8d+48)) .or. (.not. (y <= 4.4d-122))) then
tmp = y * (4.0d0 + (z * (-6.0d0)))
else
tmp = x * ((-3.0d0) + (z * 6.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+48) || !(y <= 4.4e-122)) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = x * (-3.0 + (z * 6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8e+48) or not (y <= 4.4e-122): tmp = y * (4.0 + (z * -6.0)) else: tmp = x * (-3.0 + (z * 6.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8e+48) || !(y <= 4.4e-122)) tmp = Float64(y * Float64(4.0 + Float64(z * -6.0))); else tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8e+48) || ~((y <= 4.4e-122))) tmp = y * (4.0 + (z * -6.0)); else tmp = x * (-3.0 + (z * 6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8e+48], N[Not[LessEqual[y, 4.4e-122]], $MachinePrecision]], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+48} \lor \neg \left(y \leq 4.4 \cdot 10^{-122}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\
\end{array}
\end{array}
if y < -8.00000000000000035e48 or 4.4e-122 < y Initial program 99.6%
+-commutative99.6%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 77.5%
if -8.00000000000000035e48 < y < 4.4e-122Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 79.9%
sub-neg79.9%
distribute-rgt-in79.9%
metadata-eval79.9%
metadata-eval79.9%
neg-mul-179.9%
associate-*r*79.9%
*-commutative79.9%
associate-+r+79.9%
*-commutative79.9%
metadata-eval79.9%
metadata-eval79.9%
*-commutative79.9%
associate-*l*79.9%
metadata-eval79.9%
Simplified79.9%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -9e+28) (not (<= y 1.5e-111))) (* y 4.0) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+28) || !(y <= 1.5e-111)) {
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 ((y <= (-9d+28)) .or. (.not. (y <= 1.5d-111))) 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 ((y <= -9e+28) || !(y <= 1.5e-111)) {
tmp = y * 4.0;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9e+28) or not (y <= 1.5e-111): tmp = y * 4.0 else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9e+28) || !(y <= 1.5e-111)) 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 ((y <= -9e+28) || ~((y <= 1.5e-111))) tmp = y * 4.0; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9e+28], N[Not[LessEqual[y, 1.5e-111]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+28} \lor \neg \left(y \leq 1.5 \cdot 10^{-111}\right):\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if y < -8.9999999999999994e28 or 1.50000000000000004e-111 < y Initial program 99.6%
+-commutative99.6%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around -inf 97.2%
Taylor expanded in z around inf 86.6%
associate-*r*86.7%
*-commutative86.7%
Simplified86.7%
Taylor expanded in z around 0 37.2%
if -8.9999999999999994e28 < y < 1.50000000000000004e-111Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 79.3%
sub-neg79.3%
distribute-rgt-in79.3%
metadata-eval79.3%
metadata-eval79.3%
neg-mul-179.3%
associate-*r*79.3%
*-commutative79.3%
associate-+r+79.3%
*-commutative79.3%
metadata-eval79.3%
metadata-eval79.3%
*-commutative79.3%
associate-*l*79.3%
metadata-eval79.3%
Simplified79.3%
Taylor expanded in z around 0 41.7%
*-commutative41.7%
Simplified41.7%
Final simplification39.0%
(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(Float64(y - x) * 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[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)
\end{array}
Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (* y 4.0))
double code(double x, double y, double z) {
return y * 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * 4.0d0
end function
public static double code(double x, double y, double z) {
return y * 4.0;
}
def code(x, y, z): return y * 4.0
function code(x, y, z) return Float64(y * 4.0) end
function tmp = code(x, y, z) tmp = y * 4.0; end
code[x_, y_, z_] := N[(y * 4.0), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 4
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-*l*99.8%
fma-def99.8%
sub-neg99.8%
distribute-rgt-in99.8%
metadata-eval99.8%
metadata-eval99.8%
distribute-lft-neg-out99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around -inf 97.9%
Taylor expanded in z around inf 75.5%
associate-*r*75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in z around 0 24.8%
Final simplification24.8%
herbie shell --seed 2024031
(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))))