
(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 12 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-define99.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%
(FPCore (x y z)
:precision binary64
(if (<= y -4.1e+165)
(* y 4.0)
(if (<= y 2.4e-10)
(* x (+ -3.0 (* z 6.0)))
(if (<= y 2.2e+105) (* y (* z -6.0)) (* y 4.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+165) {
tmp = y * 4.0;
} else if (y <= 2.4e-10) {
tmp = x * (-3.0 + (z * 6.0));
} else if (y <= 2.2e+105) {
tmp = y * (z * -6.0);
} else {
tmp = 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 (y <= (-4.1d+165)) then
tmp = y * 4.0d0
else if (y <= 2.4d-10) then
tmp = x * ((-3.0d0) + (z * 6.0d0))
else if (y <= 2.2d+105) then
tmp = y * (z * (-6.0d0))
else
tmp = y * 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+165) {
tmp = y * 4.0;
} else if (y <= 2.4e-10) {
tmp = x * (-3.0 + (z * 6.0));
} else if (y <= 2.2e+105) {
tmp = y * (z * -6.0);
} else {
tmp = y * 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.1e+165: tmp = y * 4.0 elif y <= 2.4e-10: tmp = x * (-3.0 + (z * 6.0)) elif y <= 2.2e+105: tmp = y * (z * -6.0) else: tmp = y * 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.1e+165) tmp = Float64(y * 4.0); elseif (y <= 2.4e-10) tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0))); elseif (y <= 2.2e+105) tmp = Float64(y * Float64(z * -6.0)); else tmp = Float64(y * 4.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.1e+165) tmp = y * 4.0; elseif (y <= 2.4e-10) tmp = x * (-3.0 + (z * 6.0)); elseif (y <= 2.2e+105) tmp = y * (z * -6.0); else tmp = y * 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.1e+165], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 2.4e-10], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+105], N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+165}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{-10}:\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+105}:\\
\;\;\;\;y \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 4\\
\end{array}
\end{array}
if y < -4.1000000000000003e165 or 2.20000000000000007e105 < y Initial program 99.7%
+-commutative99.7%
associate-*l*99.9%
fma-define99.9%
sub-neg99.9%
distribute-rgt-in100.0%
metadata-eval100.0%
metadata-eval100.0%
distribute-lft-neg-out100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 97.1%
Taylor expanded in z around 0 55.9%
distribute-lft1-in55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in x around 0 52.1%
if -4.1000000000000003e165 < y < 2.4e-10Initial program 99.6%
+-commutative99.6%
associate-*l*99.7%
fma-define99.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 0 76.7%
*-lft-identity76.7%
*-commutative76.7%
+-commutative76.7%
*-commutative76.7%
fma-define76.7%
associate-*r*76.7%
fma-define76.7%
distribute-lft-in76.7%
neg-mul-176.7%
distribute-lft-neg-in76.7%
metadata-eval76.7%
metadata-eval76.7%
distribute-rgt-in76.7%
+-commutative76.7%
sub-neg76.7%
distribute-rgt-in76.7%
sub-neg76.7%
distribute-rgt-in76.7%
metadata-eval76.7%
distribute-lft-neg-in76.7%
associate-+r+76.7%
Simplified76.7%
if 2.4e-10 < y < 2.20000000000000007e105Initial program 99.4%
+-commutative99.4%
associate-*l*99.9%
fma-define99.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 y around inf 75.6%
Taylor expanded in z around inf 52.1%
*-commutative52.1%
Simplified52.1%
Final simplification67.7%
(FPCore (x y z) :precision binary64 (if (<= z -0.65) (* -6.0 (* y z)) (if (<= z 5.6e-111) (* y 4.0) (if (<= z 3.2) (* x -3.0) (* x (* z 6.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = -6.0 * (y * z);
} else if (z <= 5.6e-111) {
tmp = y * 4.0;
} else if (z <= 3.2) {
tmp = x * -3.0;
} else {
tmp = x * (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 (z <= (-0.65d0)) then
tmp = (-6.0d0) * (y * z)
else if (z <= 5.6d-111) then
tmp = y * 4.0d0
else if (z <= 3.2d0) then
tmp = x * (-3.0d0)
else
tmp = x * (z * 6.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = -6.0 * (y * z);
} else if (z <= 5.6e-111) {
tmp = y * 4.0;
} else if (z <= 3.2) {
tmp = x * -3.0;
} else {
tmp = x * (z * 6.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.65: tmp = -6.0 * (y * z) elif z <= 5.6e-111: tmp = y * 4.0 elif z <= 3.2: tmp = x * -3.0 else: tmp = x * (z * 6.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.65) tmp = Float64(-6.0 * Float64(y * z)); elseif (z <= 5.6e-111) tmp = Float64(y * 4.0); elseif (z <= 3.2) tmp = Float64(x * -3.0); else tmp = Float64(x * Float64(z * 6.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.65) tmp = -6.0 * (y * z); elseif (z <= 5.6e-111) tmp = y * 4.0; elseif (z <= 3.2) tmp = x * -3.0; else tmp = x * (z * 6.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.65], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.6e-111], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 3.2], N[(x * -3.0), $MachinePrecision], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{-111}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 3.2:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\end{array}
\end{array}
if z < -0.650000000000000022Initial program 99.8%
+-commutative99.8%
associate-*l*99.7%
fma-define99.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.6%
Taylor expanded in z around inf 56.3%
*-commutative56.3%
Simplified56.3%
if -0.650000000000000022 < z < 5.5999999999999999e-111Initial program 99.3%
+-commutative99.3%
associate-*l*99.7%
fma-define99.7%
sub-neg99.7%
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 93.7%
Taylor expanded in z around 0 90.1%
distribute-lft1-in90.6%
metadata-eval90.6%
Simplified90.6%
Taylor expanded in x around 0 52.1%
if 5.5999999999999999e-111 < z < 3.2000000000000002Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.7%
sub-neg99.7%
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 0 61.7%
*-lft-identity61.7%
*-commutative61.7%
+-commutative61.7%
*-commutative61.7%
fma-define61.7%
associate-*r*61.7%
fma-define61.7%
distribute-lft-in61.7%
neg-mul-161.7%
distribute-lft-neg-in61.7%
metadata-eval61.7%
metadata-eval61.7%
distribute-rgt-in61.7%
+-commutative61.7%
sub-neg61.7%
distribute-rgt-in61.6%
sub-neg61.6%
distribute-rgt-in61.7%
metadata-eval61.7%
distribute-lft-neg-in61.7%
associate-+r+61.7%
Simplified61.7%
Taylor expanded in z around 0 52.3%
*-commutative52.3%
Simplified52.3%
if 3.2000000000000002 < z Initial program 99.8%
+-commutative99.8%
associate-*l*99.9%
fma-define99.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 y around 0 73.7%
*-lft-identity73.7%
*-commutative73.7%
+-commutative73.7%
*-commutative73.7%
fma-define73.6%
associate-*r*73.6%
fma-define73.7%
distribute-lft-in73.7%
neg-mul-173.7%
distribute-lft-neg-in73.7%
metadata-eval73.7%
metadata-eval73.7%
distribute-rgt-in73.7%
+-commutative73.7%
sub-neg73.7%
distribute-rgt-in73.7%
sub-neg73.7%
distribute-rgt-in73.7%
metadata-eval73.7%
distribute-lft-neg-in73.7%
associate-+r+73.7%
Simplified73.7%
Taylor expanded in z around inf 72.6%
Final simplification58.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* y z))))
(if (<= z -0.65)
t_0
(if (<= z 1.26e-110) (* y 4.0) (if (<= z 0.6) (* 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.65) {
tmp = t_0;
} else if (z <= 1.26e-110) {
tmp = y * 4.0;
} else if (z <= 0.6) {
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.65d0)) then
tmp = t_0
else if (z <= 1.26d-110) then
tmp = y * 4.0d0
else if (z <= 0.6d0) 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.65) {
tmp = t_0;
} else if (z <= 1.26e-110) {
tmp = y * 4.0;
} else if (z <= 0.6) {
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.65: tmp = t_0 elif z <= 1.26e-110: tmp = y * 4.0 elif z <= 0.6: 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.65) tmp = t_0; elseif (z <= 1.26e-110) tmp = Float64(y * 4.0); elseif (z <= 0.6) 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.65) tmp = t_0; elseif (z <= 1.26e-110) tmp = y * 4.0; elseif (z <= 0.6) 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.65], t$95$0, If[LessEqual[z, 1.26e-110], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.6], 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.65:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.26 \cdot 10^{-110}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.6:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -0.650000000000000022 or 0.599999999999999978 < z Initial program 99.8%
+-commutative99.8%
associate-*l*99.8%
fma-define99.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 46.9%
Taylor expanded in z around inf 45.6%
*-commutative45.6%
Simplified45.6%
if -0.650000000000000022 < z < 1.2600000000000001e-110Initial program 99.3%
+-commutative99.3%
associate-*l*99.7%
fma-define99.7%
sub-neg99.7%
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 93.7%
Taylor expanded in z around 0 90.1%
distribute-lft1-in90.6%
metadata-eval90.6%
Simplified90.6%
Taylor expanded in x around 0 52.1%
if 1.2600000000000001e-110 < z < 0.599999999999999978Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.7%
sub-neg99.7%
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 0 63.9%
*-lft-identity63.9%
*-commutative63.9%
+-commutative63.9%
*-commutative63.9%
fma-define63.9%
associate-*r*63.9%
fma-define63.9%
distribute-lft-in63.9%
neg-mul-163.9%
distribute-lft-neg-in63.9%
metadata-eval63.9%
metadata-eval63.9%
distribute-rgt-in63.9%
+-commutative63.9%
sub-neg63.9%
distribute-rgt-in63.8%
sub-neg63.8%
distribute-rgt-in63.9%
metadata-eval63.9%
distribute-lft-neg-in63.9%
associate-+r+63.9%
Simplified63.9%
Taylor expanded in z around 0 53.9%
*-commutative53.9%
Simplified53.9%
Final simplification49.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.65) (not (<= z 0.62))) (+ 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.65) || !(z <= 0.62)) {
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.65d0)) .or. (.not. (z <= 0.62d0))) 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.65) || !(z <= 0.62)) {
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.65) or not (z <= 0.62): 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.65) || !(z <= 0.62)) 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.65) || ~((z <= 0.62))) 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.65], N[Not[LessEqual[z, 0.62]], $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.65 \lor \neg \left(z \leq 0.62\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.650000000000000022 or 0.619999999999999996 < z Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 97.9%
if -0.650000000000000022 < z < 0.619999999999999996Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 94.5%
Taylor expanded in x around 0 94.5%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.65) (+ x (* z (* (- y x) -6.0))) (if (<= z 0.52) (+ (* y 4.0) (* x -3.0)) (+ x (* (- y x) (* z -6.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = x + (z * ((y - x) * -6.0));
} else if (z <= 0.52) {
tmp = (y * 4.0) + (x * -3.0);
} else {
tmp = x + ((y - x) * (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 (z <= (-0.65d0)) then
tmp = x + (z * ((y - x) * (-6.0d0)))
else if (z <= 0.52d0) then
tmp = (y * 4.0d0) + (x * (-3.0d0))
else
tmp = x + ((y - x) * (z * (-6.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = x + (z * ((y - x) * -6.0));
} else if (z <= 0.52) {
tmp = (y * 4.0) + (x * -3.0);
} else {
tmp = x + ((y - x) * (z * -6.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.65: tmp = x + (z * ((y - x) * -6.0)) elif z <= 0.52: tmp = (y * 4.0) + (x * -3.0) else: tmp = x + ((y - x) * (z * -6.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.65) tmp = Float64(x + Float64(z * Float64(Float64(y - x) * -6.0))); elseif (z <= 0.52) tmp = Float64(Float64(y * 4.0) + Float64(x * -3.0)); else tmp = Float64(x + Float64(Float64(y - x) * Float64(z * -6.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.65) tmp = x + (z * ((y - x) * -6.0)); elseif (z <= 0.52) tmp = (y * 4.0) + (x * -3.0); else tmp = x + ((y - x) * (z * -6.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.65], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.52], N[(N[(y * 4.0), $MachinePrecision] + N[(x * -3.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65:\\
\;\;\;\;x + z \cdot \left(\left(y - x\right) \cdot -6\right)\\
\mathbf{elif}\;z \leq 0.52:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\
\end{array}
\end{array}
if z < -0.650000000000000022Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 98.5%
neg-mul-198.5%
Simplified98.5%
Taylor expanded in z around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
if -0.650000000000000022 < z < 0.52000000000000002Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 94.5%
Taylor expanded in x around 0 94.5%
if 0.52000000000000002 < z Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 97.2%
*-commutative97.2%
*-commutative97.2%
associate-*l*97.3%
*-commutative97.3%
Simplified97.3%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.65) (+ x (* z (* (- y x) -6.0))) (if (<= z 0.58) (+ (* y 4.0) (* x -3.0)) (+ x (* -6.0 (* (- y x) z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = x + (z * ((y - x) * -6.0));
} else if (z <= 0.58) {
tmp = (y * 4.0) + (x * -3.0);
} else {
tmp = x + (-6.0 * ((y - x) * 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 <= (-0.65d0)) then
tmp = x + (z * ((y - x) * (-6.0d0)))
else if (z <= 0.58d0) then
tmp = (y * 4.0d0) + (x * (-3.0d0))
else
tmp = x + ((-6.0d0) * ((y - x) * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.65) {
tmp = x + (z * ((y - x) * -6.0));
} else if (z <= 0.58) {
tmp = (y * 4.0) + (x * -3.0);
} else {
tmp = x + (-6.0 * ((y - x) * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.65: tmp = x + (z * ((y - x) * -6.0)) elif z <= 0.58: tmp = (y * 4.0) + (x * -3.0) else: tmp = x + (-6.0 * ((y - x) * z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.65) tmp = Float64(x + Float64(z * Float64(Float64(y - x) * -6.0))); elseif (z <= 0.58) tmp = Float64(Float64(y * 4.0) + Float64(x * -3.0)); else tmp = Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.65) tmp = x + (z * ((y - x) * -6.0)); elseif (z <= 0.58) tmp = (y * 4.0) + (x * -3.0); else tmp = x + (-6.0 * ((y - x) * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.65], N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.58], N[(N[(y * 4.0), $MachinePrecision] + N[(x * -3.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65:\\
\;\;\;\;x + z \cdot \left(\left(y - x\right) \cdot -6\right)\\
\mathbf{elif}\;z \leq 0.58:\\
\;\;\;\;y \cdot 4 + x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\
\end{array}
\end{array}
if z < -0.650000000000000022Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 98.5%
neg-mul-198.5%
Simplified98.5%
Taylor expanded in z around 0 98.5%
*-commutative98.5%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
if -0.650000000000000022 < z < 0.57999999999999996Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 94.5%
Taylor expanded in x around 0 94.5%
if 0.57999999999999996 < z Initial program 99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 97.2%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+58) (not (<= y 2.15e-11))) (* y (+ 4.0 (* z -6.0))) (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+58) || !(y <= 2.15e-11)) {
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 <= (-4.8d+58)) .or. (.not. (y <= 2.15d-11))) 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 <= -4.8e+58) || !(y <= 2.15e-11)) {
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 <= -4.8e+58) or not (y <= 2.15e-11): 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 <= -4.8e+58) || !(y <= 2.15e-11)) 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 <= -4.8e+58) || ~((y <= 2.15e-11))) 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, -4.8e+58], N[Not[LessEqual[y, 2.15e-11]], $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 -4.8 \cdot 10^{+58} \lor \neg \left(y \leq 2.15 \cdot 10^{-11}\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 < -4.8e58 or 2.15000000000000001e-11 < y Initial program 99.6%
+-commutative99.6%
associate-*l*99.9%
fma-define99.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 y around inf 83.8%
if -4.8e58 < y < 2.15000000000000001e-11Initial program 99.6%
+-commutative99.6%
associate-*l*99.7%
fma-define99.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 0 81.8%
*-lft-identity81.8%
*-commutative81.8%
+-commutative81.8%
*-commutative81.8%
fma-define81.8%
associate-*r*81.8%
fma-define81.8%
distribute-lft-in81.8%
neg-mul-181.8%
distribute-lft-neg-in81.8%
metadata-eval81.8%
metadata-eval81.8%
distribute-rgt-in81.8%
+-commutative81.8%
sub-neg81.8%
distribute-rgt-in81.8%
sub-neg81.8%
distribute-rgt-in81.8%
metadata-eval81.8%
distribute-lft-neg-in81.8%
associate-+r+81.8%
Simplified81.8%
Final simplification82.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.7e+59) (not (<= y 1.32e-82))) (* y 4.0) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.7e+59) || !(y <= 1.32e-82)) {
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 <= (-1.7d+59)) .or. (.not. (y <= 1.32d-82))) 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 <= -1.7e+59) || !(y <= 1.32e-82)) {
tmp = y * 4.0;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.7e+59) or not (y <= 1.32e-82): tmp = y * 4.0 else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.7e+59) || !(y <= 1.32e-82)) 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 <= -1.7e+59) || ~((y <= 1.32e-82))) tmp = y * 4.0; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.7e+59], N[Not[LessEqual[y, 1.32e-82]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+59} \lor \neg \left(y \leq 1.32 \cdot 10^{-82}\right):\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if y < -1.70000000000000003e59 or 1.32e-82 < y Initial program 99.6%
+-commutative99.6%
associate-*l*99.9%
fma-define99.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 y around inf 97.5%
Taylor expanded in z around 0 49.6%
distribute-lft1-in49.6%
metadata-eval49.6%
Simplified49.6%
Taylor expanded in x around 0 42.1%
if -1.70000000000000003e59 < y < 1.32e-82Initial program 99.5%
+-commutative99.5%
associate-*l*99.6%
fma-define99.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 0 83.5%
*-lft-identity83.5%
*-commutative83.5%
+-commutative83.5%
*-commutative83.5%
fma-define83.5%
associate-*r*83.5%
fma-define83.5%
distribute-lft-in83.5%
neg-mul-183.5%
distribute-lft-neg-in83.5%
metadata-eval83.5%
metadata-eval83.5%
distribute-rgt-in83.4%
+-commutative83.4%
sub-neg83.4%
distribute-rgt-in83.4%
sub-neg83.4%
distribute-rgt-in83.5%
metadata-eval83.5%
distribute-lft-neg-in83.5%
associate-+r+83.5%
Simplified83.5%
Taylor expanded in z around 0 40.5%
*-commutative40.5%
Simplified40.5%
Final simplification41.3%
(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%
(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.6%
+-commutative99.6%
associate-*l*99.8%
fma-define99.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 0 56.2%
*-lft-identity56.2%
*-commutative56.2%
+-commutative56.2%
*-commutative56.2%
fma-define56.2%
associate-*r*56.2%
fma-define56.2%
distribute-lft-in56.2%
neg-mul-156.2%
distribute-lft-neg-in56.2%
metadata-eval56.2%
metadata-eval56.2%
distribute-rgt-in56.2%
+-commutative56.2%
sub-neg56.2%
distribute-rgt-in56.2%
sub-neg56.2%
distribute-rgt-in56.2%
metadata-eval56.2%
distribute-lft-neg-in56.2%
associate-+r+56.2%
Simplified56.2%
Taylor expanded in z around 0 25.4%
*-commutative25.4%
Simplified25.4%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 51.1%
neg-mul-151.1%
Simplified51.1%
Taylor expanded in z around 0 2.9%
herbie shell --seed 2024165
(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))))