
(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 13 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) (* 6.0 (- 0.6666666666666666 z)) x))
double code(double x, double y, double z) {
return fma((y - x), (6.0 * (0.6666666666666666 - z)), x);
}
function code(x, y, z) return fma(Float64(y - x), Float64(6.0 * Float64(0.6666666666666666 - z)), x) end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-*l*99.8%
fma-define99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* x z))))
(if (<= z -60000000000000.0)
t_0
(if (<= z 4.4e-86) (* y 4.0) (if (<= z 0.5) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (x * z);
double tmp;
if (z <= -60000000000000.0) {
tmp = t_0;
} else if (z <= 4.4e-86) {
tmp = y * 4.0;
} else if (z <= 0.5) {
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 * (x * z)
if (z <= (-60000000000000.0d0)) then
tmp = t_0
else if (z <= 4.4d-86) then
tmp = y * 4.0d0
else if (z <= 0.5d0) 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 * (x * z);
double tmp;
if (z <= -60000000000000.0) {
tmp = t_0;
} else if (z <= 4.4e-86) {
tmp = y * 4.0;
} else if (z <= 0.5) {
tmp = x * -3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (x * z) tmp = 0 if z <= -60000000000000.0: tmp = t_0 elif z <= 4.4e-86: tmp = y * 4.0 elif z <= 0.5: tmp = x * -3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(x * z)) tmp = 0.0 if (z <= -60000000000000.0) tmp = t_0; elseif (z <= 4.4e-86) tmp = Float64(y * 4.0); elseif (z <= 0.5) tmp = Float64(x * -3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (x * z); tmp = 0.0; if (z <= -60000000000000.0) tmp = t_0; elseif (z <= 4.4e-86) tmp = y * 4.0; elseif (z <= 0.5) 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[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -60000000000000.0], t$95$0, If[LessEqual[z, 4.4e-86], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -60000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-86}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6e13 or 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 59.3%
metadata-eval59.3%
cancel-sign-sub-inv59.3%
*-commutative59.3%
cancel-sign-sub-inv59.3%
distribute-lft-neg-in59.3%
*-commutative59.3%
sub-neg59.3%
distribute-lft-in59.3%
metadata-eval59.3%
distribute-rgt-neg-out59.3%
distribute-lft-neg-in59.3%
metadata-eval59.3%
mul-1-neg59.3%
distribute-lft-in59.3%
metadata-eval59.3%
associate-+r+59.3%
metadata-eval59.3%
associate-*r*59.3%
metadata-eval59.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in z around inf 58.3%
*-commutative58.3%
Simplified58.3%
if -6e13 < z < 4.4000000000000003e-86Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 97.9%
Taylor expanded in x around 0 63.8%
*-commutative63.8%
Simplified63.8%
if 4.4000000000000003e-86 < z < 0.5Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 66.6%
metadata-eval66.6%
cancel-sign-sub-inv66.6%
*-commutative66.6%
cancel-sign-sub-inv66.6%
distribute-lft-neg-in66.6%
*-commutative66.6%
sub-neg66.6%
distribute-lft-in66.6%
metadata-eval66.6%
distribute-rgt-neg-out66.6%
distribute-lft-neg-in66.6%
metadata-eval66.6%
mul-1-neg66.6%
distribute-lft-in66.6%
metadata-eval66.6%
associate-+r+66.6%
metadata-eval66.6%
associate-*r*66.6%
metadata-eval66.6%
*-commutative66.6%
Simplified66.6%
Taylor expanded in z around 0 62.5%
*-commutative62.5%
Simplified62.5%
Final simplification60.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* 6.0 z))))
(if (<= z -60000000000000.0)
t_0
(if (<= z 7.5e-86) (* y 4.0) (if (<= z 0.5) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (6.0 * z);
double tmp;
if (z <= -60000000000000.0) {
tmp = t_0;
} else if (z <= 7.5e-86) {
tmp = y * 4.0;
} else if (z <= 0.5) {
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 = x * (6.0d0 * z)
if (z <= (-60000000000000.0d0)) then
tmp = t_0
else if (z <= 7.5d-86) then
tmp = y * 4.0d0
else if (z <= 0.5d0) 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 = x * (6.0 * z);
double tmp;
if (z <= -60000000000000.0) {
tmp = t_0;
} else if (z <= 7.5e-86) {
tmp = y * 4.0;
} else if (z <= 0.5) {
tmp = x * -3.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (6.0 * z) tmp = 0 if z <= -60000000000000.0: tmp = t_0 elif z <= 7.5e-86: tmp = y * 4.0 elif z <= 0.5: tmp = x * -3.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(6.0 * z)) tmp = 0.0 if (z <= -60000000000000.0) tmp = t_0; elseif (z <= 7.5e-86) tmp = Float64(y * 4.0); elseif (z <= 0.5) tmp = Float64(x * -3.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (6.0 * z); tmp = 0.0; if (z <= -60000000000000.0) tmp = t_0; elseif (z <= 7.5e-86) tmp = y * 4.0; elseif (z <= 0.5) tmp = x * -3.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -60000000000000.0], t$95$0, If[LessEqual[z, 7.5e-86], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(6 \cdot z\right)\\
\mathbf{if}\;z \leq -60000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{-86}:\\
\;\;\;\;y \cdot 4\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6e13 or 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 59.3%
metadata-eval59.3%
cancel-sign-sub-inv59.3%
*-commutative59.3%
cancel-sign-sub-inv59.3%
distribute-lft-neg-in59.3%
*-commutative59.3%
sub-neg59.3%
distribute-lft-in59.3%
metadata-eval59.3%
distribute-rgt-neg-out59.3%
distribute-lft-neg-in59.3%
metadata-eval59.3%
mul-1-neg59.3%
distribute-lft-in59.3%
metadata-eval59.3%
associate-+r+59.3%
metadata-eval59.3%
associate-*r*59.3%
metadata-eval59.3%
*-commutative59.3%
Simplified59.3%
Taylor expanded in z around inf 58.4%
if -6e13 < z < 7.50000000000000055e-86Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 97.9%
Taylor expanded in x around 0 63.8%
*-commutative63.8%
Simplified63.8%
if 7.50000000000000055e-86 < z < 0.5Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 66.6%
metadata-eval66.6%
cancel-sign-sub-inv66.6%
*-commutative66.6%
cancel-sign-sub-inv66.6%
distribute-lft-neg-in66.6%
*-commutative66.6%
sub-neg66.6%
distribute-lft-in66.6%
metadata-eval66.6%
distribute-rgt-neg-out66.6%
distribute-lft-neg-in66.6%
metadata-eval66.6%
mul-1-neg66.6%
distribute-lft-in66.6%
metadata-eval66.6%
associate-+r+66.6%
metadata-eval66.6%
associate-*r*66.6%
metadata-eval66.6%
*-commutative66.6%
Simplified66.6%
Taylor expanded in z around 0 62.5%
*-commutative62.5%
Simplified62.5%
Final simplification60.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.65) (not (<= z 0.62))) (+ x (* -6.0 (* (- y x) z))) (+ x (* (- y x) 4.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 = x + ((y - x) * 4.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-0.65d0)) .or. (.not. (z <= 0.62d0))) then
tmp = x + ((-6.0d0) * ((y - x) * z))
else
tmp = x + ((y - x) * 4.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 = x + ((y - x) * 4.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 = x + ((y - x) * 4.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(x + Float64(Float64(y - x) * 4.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 = x + ((y - x) * 4.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[(x + N[(N[(y - x), $MachinePrecision] * 4.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}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\end{array}
\end{array}
if z < -0.650000000000000022 or 0.619999999999999996 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 98.3%
if -0.650000000000000022 < z < 0.619999999999999996Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 98.2%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.65) (not (<= z 0.5))) (+ x (* (- y x) (* z -6.0))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.65) || !(z <= 0.5)) {
tmp = x + ((y - x) * (z * -6.0));
} else {
tmp = x + ((y - x) * 4.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-0.65d0)) .or. (.not. (z <= 0.5d0))) then
tmp = x + ((y - x) * (z * (-6.0d0)))
else
tmp = x + ((y - x) * 4.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.5)) {
tmp = x + ((y - x) * (z * -6.0));
} else {
tmp = x + ((y - x) * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.65) or not (z <= 0.5): tmp = x + ((y - x) * (z * -6.0)) else: tmp = x + ((y - x) * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.65) || !(z <= 0.5)) tmp = Float64(x + Float64(Float64(y - x) * Float64(z * -6.0))); else tmp = Float64(x + Float64(Float64(y - x) * 4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.65) || ~((z <= 0.5))) tmp = x + ((y - x) * (z * -6.0)); else tmp = x + ((y - x) * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.65], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.65 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\end{array}
\end{array}
if z < -0.650000000000000022 or 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 98.3%
associate-*r*98.4%
*-commutative98.4%
Simplified98.4%
if -0.650000000000000022 < z < 0.5Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 98.2%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (<= z -0.65) (+ x (* z (* (- y x) -6.0))) (if (<= z 0.5) (+ x (* (- y x) 4.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.5) {
tmp = x + ((y - x) * 4.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.5d0) then
tmp = x + ((y - x) * 4.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.5) {
tmp = x + ((y - x) * 4.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.5: tmp = x + ((y - x) * 4.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.5) tmp = Float64(x + Float64(Float64(y - x) * 4.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.5) tmp = x + ((y - x) * 4.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.5], N[(x + N[(N[(y - x), $MachinePrecision] * 4.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.5:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\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 99.6%
associate-*r*99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in z around 0 99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
Simplified99.6%
if -0.650000000000000022 < z < 0.5Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around 0 98.2%
if 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 97.1%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.4e-159) (not (<= y 9.4e-54))) (* 6.0 (* y (- 0.6666666666666666 z))) (* x (* 6.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e-159) || !(y <= 9.4e-54)) {
tmp = 6.0 * (y * (0.6666666666666666 - z));
} else {
tmp = x * (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 ((y <= (-6.4d-159)) .or. (.not. (y <= 9.4d-54))) then
tmp = 6.0d0 * (y * (0.6666666666666666d0 - z))
else
tmp = x * (6.0d0 * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e-159) || !(y <= 9.4e-54)) {
tmp = 6.0 * (y * (0.6666666666666666 - z));
} else {
tmp = x * (6.0 * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.4e-159) or not (y <= 9.4e-54): tmp = 6.0 * (y * (0.6666666666666666 - z)) else: tmp = x * (6.0 * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.4e-159) || !(y <= 9.4e-54)) tmp = Float64(6.0 * Float64(y * Float64(0.6666666666666666 - z))); else tmp = Float64(x * Float64(6.0 * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.4e-159) || ~((y <= 9.4e-54))) tmp = 6.0 * (y * (0.6666666666666666 - z)); else tmp = x * (6.0 * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.4e-159], N[Not[LessEqual[y, 9.4e-54]], $MachinePrecision]], N[(6.0 * N[(y * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{-159} \lor \neg \left(y \leq 9.4 \cdot 10^{-54}\right):\\
\;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(6 \cdot z\right)\\
\end{array}
\end{array}
if y < -6.3999999999999999e-159 or 9.4e-54 < y Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 83.3%
Taylor expanded in x around 0 76.2%
if -6.3999999999999999e-159 < y < 9.4e-54Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 86.7%
metadata-eval86.7%
cancel-sign-sub-inv86.7%
*-commutative86.7%
cancel-sign-sub-inv86.7%
distribute-lft-neg-in86.7%
*-commutative86.7%
sub-neg86.7%
distribute-lft-in86.7%
metadata-eval86.7%
distribute-rgt-neg-out86.7%
distribute-lft-neg-in86.7%
metadata-eval86.7%
mul-1-neg86.7%
distribute-lft-in86.7%
metadata-eval86.7%
associate-+r+86.7%
metadata-eval86.7%
associate-*r*86.7%
metadata-eval86.7%
*-commutative86.7%
Simplified86.7%
Taylor expanded in z around inf 53.4%
Final simplification67.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -7e-58) (not (<= y 2.7e-53))) (* 6.0 (* y (- 0.6666666666666666 z))) (* x (+ -3.0 (* 6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7e-58) || !(y <= 2.7e-53)) {
tmp = 6.0 * (y * (0.6666666666666666 - z));
} else {
tmp = x * (-3.0 + (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 ((y <= (-7d-58)) .or. (.not. (y <= 2.7d-53))) then
tmp = 6.0d0 * (y * (0.6666666666666666d0 - z))
else
tmp = x * ((-3.0d0) + (6.0d0 * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7e-58) || !(y <= 2.7e-53)) {
tmp = 6.0 * (y * (0.6666666666666666 - z));
} else {
tmp = x * (-3.0 + (6.0 * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7e-58) or not (y <= 2.7e-53): tmp = 6.0 * (y * (0.6666666666666666 - z)) else: tmp = x * (-3.0 + (6.0 * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7e-58) || !(y <= 2.7e-53)) tmp = Float64(6.0 * Float64(y * Float64(0.6666666666666666 - z))); else tmp = Float64(x * Float64(-3.0 + Float64(6.0 * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7e-58) || ~((y <= 2.7e-53))) tmp = 6.0 * (y * (0.6666666666666666 - z)); else tmp = x * (-3.0 + (6.0 * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7e-58], N[Not[LessEqual[y, 2.7e-53]], $MachinePrecision]], N[(6.0 * N[(y * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-58} \lor \neg \left(y \leq 2.7 \cdot 10^{-53}\right):\\
\;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-3 + 6 \cdot z\right)\\
\end{array}
\end{array}
if y < -6.9999999999999998e-58 or 2.6999999999999999e-53 < y Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 82.0%
Taylor expanded in x around 0 80.2%
if -6.9999999999999998e-58 < y < 2.6999999999999999e-53Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 82.7%
metadata-eval82.7%
cancel-sign-sub-inv82.7%
*-commutative82.7%
cancel-sign-sub-inv82.7%
distribute-lft-neg-in82.7%
*-commutative82.7%
sub-neg82.7%
distribute-lft-in82.7%
metadata-eval82.7%
distribute-rgt-neg-out82.7%
distribute-lft-neg-in82.7%
metadata-eval82.7%
mul-1-neg82.7%
distribute-lft-in82.7%
metadata-eval82.7%
associate-+r+82.7%
metadata-eval82.7%
associate-*r*82.7%
metadata-eval82.7%
*-commutative82.7%
Simplified82.7%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -9.6e-60) (not (<= y 2.8e-53))) (* y (+ (* z -6.0) 4.0)) (* x (+ -3.0 (* 6.0 z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9.6e-60) || !(y <= 2.8e-53)) {
tmp = y * ((z * -6.0) + 4.0);
} else {
tmp = x * (-3.0 + (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 ((y <= (-9.6d-60)) .or. (.not. (y <= 2.8d-53))) then
tmp = y * ((z * (-6.0d0)) + 4.0d0)
else
tmp = x * ((-3.0d0) + (6.0d0 * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9.6e-60) || !(y <= 2.8e-53)) {
tmp = y * ((z * -6.0) + 4.0);
} else {
tmp = x * (-3.0 + (6.0 * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9.6e-60) or not (y <= 2.8e-53): tmp = y * ((z * -6.0) + 4.0) else: tmp = x * (-3.0 + (6.0 * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9.6e-60) || !(y <= 2.8e-53)) tmp = Float64(y * Float64(Float64(z * -6.0) + 4.0)); else tmp = Float64(x * Float64(-3.0 + Float64(6.0 * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9.6e-60) || ~((y <= 2.8e-53))) tmp = y * ((z * -6.0) + 4.0); else tmp = x * (-3.0 + (6.0 * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9.6e-60], N[Not[LessEqual[y, 2.8e-53]], $MachinePrecision]], N[(y * N[(N[(z * -6.0), $MachinePrecision] + 4.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.6 \cdot 10^{-60} \lor \neg \left(y \leq 2.8 \cdot 10^{-53}\right):\\
\;\;\;\;y \cdot \left(z \cdot -6 + 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-3 + 6 \cdot z\right)\\
\end{array}
\end{array}
if y < -9.60000000000000038e-60 or 2.79999999999999985e-53 < 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 79.9%
if -9.60000000000000038e-60 < y < 2.79999999999999985e-53Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 83.2%
metadata-eval83.2%
cancel-sign-sub-inv83.2%
*-commutative83.2%
cancel-sign-sub-inv83.2%
distribute-lft-neg-in83.2%
*-commutative83.2%
sub-neg83.2%
distribute-lft-in83.2%
metadata-eval83.2%
distribute-rgt-neg-out83.2%
distribute-lft-neg-in83.2%
metadata-eval83.2%
mul-1-neg83.2%
distribute-lft-in83.2%
metadata-eval83.2%
associate-+r+83.2%
metadata-eval83.2%
associate-*r*83.2%
metadata-eval83.2%
*-commutative83.2%
Simplified83.2%
Final simplification81.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.5e-80) (not (<= y 5.3e-55))) (* y 4.0) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.5e-80) || !(y <= 5.3e-55)) {
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 <= (-8.5d-80)) .or. (.not. (y <= 5.3d-55))) 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 <= -8.5e-80) || !(y <= 5.3e-55)) {
tmp = y * 4.0;
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.5e-80) or not (y <= 5.3e-55): tmp = y * 4.0 else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.5e-80) || !(y <= 5.3e-55)) 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 <= -8.5e-80) || ~((y <= 5.3e-55))) tmp = y * 4.0; else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e-80], N[Not[LessEqual[y, 5.3e-55]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-80} \lor \neg \left(y \leq 5.3 \cdot 10^{-55}\right):\\
\;\;\;\;y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if y < -8.49999999999999939e-80 or 5.3000000000000003e-55 < y Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around 0 50.9%
Taylor expanded in x around 0 42.8%
*-commutative42.8%
Simplified42.8%
if -8.49999999999999939e-80 < y < 5.3000000000000003e-55Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 83.7%
metadata-eval83.7%
cancel-sign-sub-inv83.7%
*-commutative83.7%
cancel-sign-sub-inv83.7%
distribute-lft-neg-in83.7%
*-commutative83.7%
sub-neg83.7%
distribute-lft-in83.7%
metadata-eval83.7%
distribute-rgt-neg-out83.7%
distribute-lft-neg-in83.7%
metadata-eval83.7%
mul-1-neg83.7%
distribute-lft-in83.7%
metadata-eval83.7%
associate-+r+83.7%
metadata-eval83.7%
associate-*r*83.7%
metadata-eval83.7%
*-commutative83.7%
Simplified83.7%
Taylor expanded in z around 0 36.3%
*-commutative36.3%
Simplified36.3%
Final simplification40.1%
(FPCore (x y z) :precision binary64 (+ x (* (- 0.6666666666666666 z) (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((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 + ((0.6666666666666666d0 - z) * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + ((0.6666666666666666 - z) * ((y - x) * 6.0));
}
def code(x, y, z): return x + ((0.6666666666666666 - z) * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(Float64(0.6666666666666666 - z) * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + ((0.6666666666666666 - z) * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.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%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 51.4%
metadata-eval51.4%
cancel-sign-sub-inv51.4%
*-commutative51.4%
cancel-sign-sub-inv51.4%
distribute-lft-neg-in51.4%
*-commutative51.4%
sub-neg51.4%
distribute-lft-in51.4%
metadata-eval51.4%
distribute-rgt-neg-out51.4%
distribute-lft-neg-in51.4%
metadata-eval51.4%
mul-1-neg51.4%
distribute-lft-in51.4%
metadata-eval51.4%
associate-+r+51.4%
metadata-eval51.4%
associate-*r*51.4%
metadata-eval51.4%
*-commutative51.4%
Simplified51.4%
Taylor expanded in z around 0 20.8%
*-commutative20.8%
Simplified20.8%
Final simplification20.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.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 53.7%
associate-*r*53.7%
Simplified53.7%
Taylor expanded in x around inf 2.7%
Final simplification2.7%
herbie shell --seed 2024096
(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))))