
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
return x + (((y - x) * 6.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) * z)
end function
public static double code(double x, double y, double z) {
return x + (((y - x) * 6.0) * z);
}
def code(x, y, z): return x + (((y - x) * 6.0) * z)
function code(x, y, z) return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z)) end
function tmp = code(x, y, z) tmp = x + (((y - x) * 6.0) * z); end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}
(FPCore (x y z) :precision binary64 (+ x (* (fma -6.0 x (* 6.0 y)) z)))
double code(double x, double y, double z) {
return x + (fma(-6.0, x, (6.0 * y)) * z);
}
function code(x, y, z) return Float64(x + Float64(fma(-6.0, x, Float64(6.0 * y)) * z)) end
code[x_, y_, z_] := N[(x + N[(N[(-6.0 * x + N[(6.0 * y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(-6, x, 6 \cdot y\right) \cdot z
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 99.8%
fma-define99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (fma z (* -6.0 (- x y)) x))
double code(double x, double y, double z) {
return fma(z, (-6.0 * (x - y)), x);
}
function code(x, y, z) return fma(z, Float64(-6.0 * Float64(x - y)), x) end
code[x_, y_, z_] := N[(z * N[(-6.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, -6 \cdot \left(x - y\right), x\right)
\end{array}
Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* x z))) (t_1 (* 6.0 (* y z))))
(if (<= z -2.8e+33)
t_0
(if (<= z -5.7e-58)
t_1
(if (<= z 1.75e-96) x (if (<= z 22500000000000.0) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (x * z);
double t_1 = 6.0 * (y * z);
double tmp;
if (z <= -2.8e+33) {
tmp = t_0;
} else if (z <= -5.7e-58) {
tmp = t_1;
} else if (z <= 1.75e-96) {
tmp = x;
} else if (z <= 22500000000000.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (-6.0d0) * (x * z)
t_1 = 6.0d0 * (y * z)
if (z <= (-2.8d+33)) then
tmp = t_0
else if (z <= (-5.7d-58)) then
tmp = t_1
else if (z <= 1.75d-96) then
tmp = x
else if (z <= 22500000000000.0d0) then
tmp = t_1
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 t_1 = 6.0 * (y * z);
double tmp;
if (z <= -2.8e+33) {
tmp = t_0;
} else if (z <= -5.7e-58) {
tmp = t_1;
} else if (z <= 1.75e-96) {
tmp = x;
} else if (z <= 22500000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (x * z) t_1 = 6.0 * (y * z) tmp = 0 if z <= -2.8e+33: tmp = t_0 elif z <= -5.7e-58: tmp = t_1 elif z <= 1.75e-96: tmp = x elif z <= 22500000000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(x * z)) t_1 = Float64(6.0 * Float64(y * z)) tmp = 0.0 if (z <= -2.8e+33) tmp = t_0; elseif (z <= -5.7e-58) tmp = t_1; elseif (z <= 1.75e-96) tmp = x; elseif (z <= 22500000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -6.0 * (x * z); t_1 = 6.0 * (y * z); tmp = 0.0; if (z <= -2.8e+33) tmp = t_0; elseif (z <= -5.7e-58) tmp = t_1; elseif (z <= 1.75e-96) tmp = x; elseif (z <= 22500000000000.0) tmp = t_1; 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]}, Block[{t$95$1 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.8e+33], t$95$0, If[LessEqual[z, -5.7e-58], t$95$1, If[LessEqual[z, 1.75e-96], x, If[LessEqual[z, 22500000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(x \cdot z\right)\\
t_1 := 6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{+33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -5.7 \cdot 10^{-58}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 22500000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.8000000000000001e33 or 2.25e13 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 99.7%
Taylor expanded in x around inf 60.4%
if -2.8000000000000001e33 < z < -5.70000000000000032e-58 or 1.7499999999999999e-96 < z < 2.25e13Initial program 99.7%
Taylor expanded in x around 0 99.6%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if -5.70000000000000032e-58 < z < 1.7499999999999999e-96Initial program 100.0%
Taylor expanded in z around 0 81.5%
Final simplification68.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -6.0 (* x z))))
(if (<= z -4.4e+33)
t_0
(if (<= z -1e-57)
(* (* 6.0 y) z)
(if (<= z 1.8e-96)
x
(if (<= z 85000000000000.0) (* 6.0 (* y z)) t_0))))))
double code(double x, double y, double z) {
double t_0 = -6.0 * (x * z);
double tmp;
if (z <= -4.4e+33) {
tmp = t_0;
} else if (z <= -1e-57) {
tmp = (6.0 * y) * z;
} else if (z <= 1.8e-96) {
tmp = x;
} else if (z <= 85000000000000.0) {
tmp = 6.0 * (y * z);
} 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 <= (-4.4d+33)) then
tmp = t_0
else if (z <= (-1d-57)) then
tmp = (6.0d0 * y) * z
else if (z <= 1.8d-96) then
tmp = x
else if (z <= 85000000000000.0d0) then
tmp = 6.0d0 * (y * z)
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 <= -4.4e+33) {
tmp = t_0;
} else if (z <= -1e-57) {
tmp = (6.0 * y) * z;
} else if (z <= 1.8e-96) {
tmp = x;
} else if (z <= 85000000000000.0) {
tmp = 6.0 * (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -6.0 * (x * z) tmp = 0 if z <= -4.4e+33: tmp = t_0 elif z <= -1e-57: tmp = (6.0 * y) * z elif z <= 1.8e-96: tmp = x elif z <= 85000000000000.0: tmp = 6.0 * (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-6.0 * Float64(x * z)) tmp = 0.0 if (z <= -4.4e+33) tmp = t_0; elseif (z <= -1e-57) tmp = Float64(Float64(6.0 * y) * z); elseif (z <= 1.8e-96) tmp = x; elseif (z <= 85000000000000.0) tmp = Float64(6.0 * Float64(y * z)); 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 <= -4.4e+33) tmp = t_0; elseif (z <= -1e-57) tmp = (6.0 * y) * z; elseif (z <= 1.8e-96) tmp = x; elseif (z <= 85000000000000.0) tmp = 6.0 * (y * z); 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, -4.4e+33], t$95$0, If[LessEqual[z, -1e-57], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 1.8e-96], x, If[LessEqual[z, 85000000000000.0], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -4.4 \cdot 10^{+33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1 \cdot 10^{-57}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 85000000000000:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -4.39999999999999988e33 or 8.5e13 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 99.7%
Taylor expanded in x around inf 60.4%
if -4.39999999999999988e33 < z < -9.99999999999999955e-58Initial program 99.8%
Taylor expanded in x around 0 99.5%
Taylor expanded in y around inf 63.4%
associate-*r*63.7%
*-commutative63.7%
Simplified63.7%
if -9.99999999999999955e-58 < z < 1.80000000000000004e-96Initial program 100.0%
Taylor expanded in z around 0 81.5%
if 1.80000000000000004e-96 < z < 8.5e13Initial program 99.6%
Taylor expanded in x around 0 99.6%
Taylor expanded in y around inf 62.3%
*-commutative62.3%
Simplified62.3%
Final simplification68.9%
(FPCore (x y z)
:precision binary64
(if (<= z -4.2e+33)
(* z (* x -6.0))
(if (<= z -1.02e-57)
(* (* 6.0 y) z)
(if (<= z 2.5e-97)
x
(if (<= z 1850000000000.0) (* 6.0 (* y z)) (* -6.0 (* x z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+33) {
tmp = z * (x * -6.0);
} else if (z <= -1.02e-57) {
tmp = (6.0 * y) * z;
} else if (z <= 2.5e-97) {
tmp = x;
} else if (z <= 1850000000000.0) {
tmp = 6.0 * (y * z);
} else {
tmp = -6.0 * (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 <= (-4.2d+33)) then
tmp = z * (x * (-6.0d0))
else if (z <= (-1.02d-57)) then
tmp = (6.0d0 * y) * z
else if (z <= 2.5d-97) then
tmp = x
else if (z <= 1850000000000.0d0) then
tmp = 6.0d0 * (y * z)
else
tmp = (-6.0d0) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+33) {
tmp = z * (x * -6.0);
} else if (z <= -1.02e-57) {
tmp = (6.0 * y) * z;
} else if (z <= 2.5e-97) {
tmp = x;
} else if (z <= 1850000000000.0) {
tmp = 6.0 * (y * z);
} else {
tmp = -6.0 * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e+33: tmp = z * (x * -6.0) elif z <= -1.02e-57: tmp = (6.0 * y) * z elif z <= 2.5e-97: tmp = x elif z <= 1850000000000.0: tmp = 6.0 * (y * z) else: tmp = -6.0 * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e+33) tmp = Float64(z * Float64(x * -6.0)); elseif (z <= -1.02e-57) tmp = Float64(Float64(6.0 * y) * z); elseif (z <= 2.5e-97) tmp = x; elseif (z <= 1850000000000.0) tmp = Float64(6.0 * Float64(y * z)); else tmp = Float64(-6.0 * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.2e+33) tmp = z * (x * -6.0); elseif (z <= -1.02e-57) tmp = (6.0 * y) * z; elseif (z <= 2.5e-97) tmp = x; elseif (z <= 1850000000000.0) tmp = 6.0 * (y * z); else tmp = -6.0 * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e+33], N[(z * N[(x * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.02e-57], N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, 2.5e-97], x, If[LessEqual[z, 1850000000000.0], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+33}:\\
\;\;\;\;z \cdot \left(x \cdot -6\right)\\
\mathbf{elif}\;z \leq -1.02 \cdot 10^{-57}:\\
\;\;\;\;\left(6 \cdot y\right) \cdot z\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-97}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1850000000000:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -4.2000000000000001e33Initial program 99.7%
Taylor expanded in x around 0 91.3%
Taylor expanded in z around inf 99.8%
metadata-eval99.8%
associate-*r*99.8%
neg-mul-199.8%
distribute-lft-in99.7%
sub-neg99.7%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 59.4%
associate-*r*59.5%
*-commutative59.5%
*-commutative59.5%
Simplified59.5%
if -4.2000000000000001e33 < z < -1.02e-57Initial program 99.8%
Taylor expanded in x around 0 99.5%
Taylor expanded in y around inf 63.4%
associate-*r*63.7%
*-commutative63.7%
Simplified63.7%
if -1.02e-57 < z < 2.4999999999999998e-97Initial program 100.0%
Taylor expanded in z around 0 81.5%
if 2.4999999999999998e-97 < z < 1.85e12Initial program 99.6%
Taylor expanded in x around 0 99.6%
Taylor expanded in y around inf 62.3%
*-commutative62.3%
Simplified62.3%
if 1.85e12 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
remove-double-neg99.7%
distribute-lft-neg-in99.7%
distribute-rgt-neg-in99.7%
sub-neg99.7%
distribute-neg-in99.7%
remove-double-neg99.7%
+-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 99.6%
Taylor expanded in x around inf 61.5%
Final simplification68.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.02e-57) (not (<= z 1.8e-96))) (* -6.0 (* z (- x y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02e-57) || !(z <= 1.8e-96)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.02d-57)) .or. (.not. (z <= 1.8d-96))) then
tmp = (-6.0d0) * (z * (x - y))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02e-57) || !(z <= 1.8e-96)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.02e-57) or not (z <= 1.8e-96): tmp = -6.0 * (z * (x - y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.02e-57) || !(z <= 1.8e-96)) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.02e-57) || ~((z <= 1.8e-96))) tmp = -6.0 * (z * (x - y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.02e-57], N[Not[LessEqual[z, 1.8e-96]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{-57} \lor \neg \left(z \leq 1.8 \cdot 10^{-96}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.02e-57 or 1.80000000000000004e-96 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 92.5%
if -1.02e-57 < z < 1.80000000000000004e-96Initial program 100.0%
Taylor expanded in z around 0 81.5%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (<= z -1.26e-58) (* -6.0 (* z (- x y))) (if (<= z 1.45e-96) x (* (- x y) (* -6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.26e-58) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 1.45e-96) {
tmp = x;
} else {
tmp = (x - y) * (-6.0 * 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 <= (-1.26d-58)) then
tmp = (-6.0d0) * (z * (x - y))
else if (z <= 1.45d-96) then
tmp = x
else
tmp = (x - y) * ((-6.0d0) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.26e-58) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 1.45e-96) {
tmp = x;
} else {
tmp = (x - y) * (-6.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.26e-58: tmp = -6.0 * (z * (x - y)) elif z <= 1.45e-96: tmp = x else: tmp = (x - y) * (-6.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.26e-58) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); elseif (z <= 1.45e-96) tmp = x; else tmp = Float64(Float64(x - y) * Float64(-6.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.26e-58) tmp = -6.0 * (z * (x - y)); elseif (z <= 1.45e-96) tmp = x; else tmp = (x - y) * (-6.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.26e-58], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e-96], x, N[(N[(x - y), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{-58}:\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-96}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \left(-6 \cdot z\right)\\
\end{array}
\end{array}
if z < -1.2600000000000001e-58Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 94.0%
if -1.2600000000000001e-58 < z < 1.44999999999999997e-96Initial program 100.0%
Taylor expanded in z around 0 81.5%
if 1.44999999999999997e-96 < z Initial program 99.7%
Taylor expanded in x around 0 97.0%
Taylor expanded in z around inf 90.8%
metadata-eval90.8%
associate-*r*90.8%
neg-mul-190.8%
distribute-lft-in90.8%
sub-neg90.8%
associate-*r*90.8%
*-commutative90.8%
Simplified90.8%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (<= z -0.165) (* -6.0 (* z (- x y))) (if (<= z 0.165) (+ x (* 6.0 (* y z))) (* (- x y) (* -6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 0.165) {
tmp = x + (6.0 * (y * z));
} else {
tmp = (x - y) * (-6.0 * 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.165d0)) then
tmp = (-6.0d0) * (z * (x - y))
else if (z <= 0.165d0) then
tmp = x + (6.0d0 * (y * z))
else
tmp = (x - y) * ((-6.0d0) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 0.165) {
tmp = x + (6.0 * (y * z));
} else {
tmp = (x - y) * (-6.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.165: tmp = -6.0 * (z * (x - y)) elif z <= 0.165: tmp = x + (6.0 * (y * z)) else: tmp = (x - y) * (-6.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.165) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); elseif (z <= 0.165) tmp = Float64(x + Float64(6.0 * Float64(y * z))); else tmp = Float64(Float64(x - y) * Float64(-6.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.165) tmp = -6.0 * (z * (x - y)); elseif (z <= 0.165) tmp = x + (6.0 * (y * z)); else tmp = (x - y) * (-6.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.165], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.165], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{elif}\;z \leq 0.165:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \left(-6 \cdot z\right)\\
\end{array}
\end{array}
if z < -0.165000000000000008Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 99.4%
if -0.165000000000000008 < z < 0.165000000000000008Initial program 99.9%
Taylor expanded in y around inf 98.8%
*-commutative98.8%
Simplified98.8%
if 0.165000000000000008 < z Initial program 99.7%
Taylor expanded in x around 0 96.2%
Taylor expanded in z around inf 98.5%
metadata-eval98.5%
associate-*r*98.5%
neg-mul-198.5%
distribute-lft-in98.5%
sub-neg98.5%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z -0.17) (* -6.0 (* z (- x y))) (if (<= z 1.8e-7) (+ x (* (* 6.0 y) z)) (* (- x y) (* -6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.17) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 1.8e-7) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = (x - y) * (-6.0 * 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.17d0)) then
tmp = (-6.0d0) * (z * (x - y))
else if (z <= 1.8d-7) then
tmp = x + ((6.0d0 * y) * z)
else
tmp = (x - y) * ((-6.0d0) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.17) {
tmp = -6.0 * (z * (x - y));
} else if (z <= 1.8e-7) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = (x - y) * (-6.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.17: tmp = -6.0 * (z * (x - y)) elif z <= 1.8e-7: tmp = x + ((6.0 * y) * z) else: tmp = (x - y) * (-6.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.17) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); elseif (z <= 1.8e-7) tmp = Float64(x + Float64(Float64(6.0 * y) * z)); else tmp = Float64(Float64(x - y) * Float64(-6.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.17) tmp = -6.0 * (z * (x - y)); elseif (z <= 1.8e-7) tmp = x + ((6.0 * y) * z); else tmp = (x - y) * (-6.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.17], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e-7], N[(x + N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.17:\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-7}:\\
\;\;\;\;x + \left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \left(-6 \cdot z\right)\\
\end{array}
\end{array}
if z < -0.170000000000000012Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 99.4%
if -0.170000000000000012 < z < 1.79999999999999997e-7Initial program 99.9%
Taylor expanded in y around inf 98.8%
if 1.79999999999999997e-7 < z Initial program 99.7%
Taylor expanded in x around 0 96.4%
Taylor expanded in z around inf 98.5%
metadata-eval98.5%
associate-*r*98.5%
neg-mul-198.5%
distribute-lft-in98.5%
sub-neg98.5%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z -0.165) (* z (+ (* 6.0 y) (* x -6.0))) (if (<= z 1.8e-7) (+ x (* (* 6.0 y) z)) (* (- x y) (* -6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = z * ((6.0 * y) + (x * -6.0));
} else if (z <= 1.8e-7) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = (x - y) * (-6.0 * 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.165d0)) then
tmp = z * ((6.0d0 * y) + (x * (-6.0d0)))
else if (z <= 1.8d-7) then
tmp = x + ((6.0d0 * y) * z)
else
tmp = (x - y) * ((-6.0d0) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.165) {
tmp = z * ((6.0 * y) + (x * -6.0));
} else if (z <= 1.8e-7) {
tmp = x + ((6.0 * y) * z);
} else {
tmp = (x - y) * (-6.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.165: tmp = z * ((6.0 * y) + (x * -6.0)) elif z <= 1.8e-7: tmp = x + ((6.0 * y) * z) else: tmp = (x - y) * (-6.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.165) tmp = Float64(z * Float64(Float64(6.0 * y) + Float64(x * -6.0))); elseif (z <= 1.8e-7) tmp = Float64(x + Float64(Float64(6.0 * y) * z)); else tmp = Float64(Float64(x - y) * Float64(-6.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.165) tmp = z * ((6.0 * y) + (x * -6.0)); elseif (z <= 1.8e-7) tmp = x + ((6.0 * y) * z); else tmp = (x - y) * (-6.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.165], N[(z * N[(N[(6.0 * y), $MachinePrecision] + N[(x * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e-7], N[(x + N[(N[(6.0 * y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165:\\
\;\;\;\;z \cdot \left(6 \cdot y + x \cdot -6\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-7}:\\
\;\;\;\;x + \left(6 \cdot y\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \left(-6 \cdot z\right)\\
\end{array}
\end{array}
if z < -0.165000000000000008Initial program 99.7%
Taylor expanded in x around 0 92.5%
Taylor expanded in z around inf 99.4%
if -0.165000000000000008 < z < 1.79999999999999997e-7Initial program 99.9%
Taylor expanded in y around inf 98.8%
if 1.79999999999999997e-7 < z Initial program 99.7%
Taylor expanded in x around 0 96.4%
Taylor expanded in z around inf 98.5%
metadata-eval98.5%
associate-*r*98.5%
neg-mul-198.5%
distribute-lft-in98.5%
sub-neg98.5%
associate-*r*98.5%
*-commutative98.5%
Simplified98.5%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 1600000.0))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 1600000.0)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-0.165d0)) .or. (.not. (z <= 1600000.0d0))) then
tmp = (-6.0d0) * (x * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 1600000.0)) {
tmp = -6.0 * (x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 1600000.0): tmp = -6.0 * (x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 1600000.0)) tmp = Float64(-6.0 * Float64(x * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 1600000.0))) tmp = -6.0 * (x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 1600000.0]], $MachinePrecision]], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 1600000\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 1.6e6 < z Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.8%
remove-double-neg99.8%
distribute-lft-neg-in99.8%
distribute-rgt-neg-in99.8%
sub-neg99.8%
distribute-neg-in99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 99.0%
Taylor expanded in x around inf 57.9%
if -0.165000000000000008 < z < 1.6e6Initial program 99.9%
Taylor expanded in z around 0 69.3%
Final simplification63.7%
(FPCore (x y z) :precision binary64 (+ x (* z (+ (* 6.0 y) (* x -6.0)))))
double code(double x, double y, double z) {
return x + (z * ((6.0 * y) + (x * -6.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 + (z * ((6.0d0 * y) + (x * (-6.0d0))))
end function
public static double code(double x, double y, double z) {
return x + (z * ((6.0 * y) + (x * -6.0)));
}
def code(x, y, z): return x + (z * ((6.0 * y) + (x * -6.0)))
function code(x, y, z) return Float64(x + Float64(z * Float64(Float64(6.0 * y) + Float64(x * -6.0)))) end
function tmp = code(x, y, z) tmp = x + (z * ((6.0 * y) + (x * -6.0))); end
code[x_, y_, z_] := N[(x + N[(z * N[(N[(6.0 * y), $MachinePrecision] + N[(x * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(6 \cdot y + x \cdot -6\right)
\end{array}
Initial program 99.8%
Taylor expanded in y around 0 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ x (* z (* 6.0 (- y x)))))
double code(double x, double y, double z) {
return x + (z * (6.0 * (y - 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 + (z * (6.0d0 * (y - x)))
end function
public static double code(double x, double y, double z) {
return x + (z * (6.0 * (y - x)));
}
def code(x, y, z): return x + (z * (6.0 * (y - x)))
function code(x, y, z) return Float64(x + Float64(z * Float64(6.0 * Float64(y - x)))) end
function tmp = code(x, y, z) tmp = x + (z * (6.0 * (y - x))); end
code[x_, y_, z_] := N[(x + N[(z * N[(6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(6 \cdot \left(y - x\right)\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(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.8%
Taylor expanded in z around 0 36.7%
Final simplification36.7%
(FPCore (x y z) :precision binary64 (- x (* (* 6.0 z) (- x y))))
double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - ((6.0d0 * z) * (x - y))
end function
public static double code(double x, double y, double z) {
return x - ((6.0 * z) * (x - y));
}
def code(x, y, z): return x - ((6.0 * z) * (x - y))
function code(x, y, z) return Float64(x - Float64(Float64(6.0 * z) * Float64(x - y))) end
function tmp = code(x, y, z) tmp = x - ((6.0 * z) * (x - y)); end
code[x_, y_, z_] := N[(x - N[(N[(6.0 * z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(6 \cdot z\right) \cdot \left(x - y\right)
\end{array}
herbie shell --seed 2024055
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
:precision binary64
:alt
(- x (* (* 6.0 z) (- x y)))
(+ x (* (* (- y x) 6.0) z)))