
(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) (+ 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.5%
+-commutative99.5%
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 (<= z -6500.0)
(* x (* z 6.0))
(if (<= z 2.6e-192)
(* x -3.0)
(if (<= z 0.0026) (+ x (* y 4.0)) (* 6.0 (* x z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6500.0) {
tmp = x * (z * 6.0);
} else if (z <= 2.6e-192) {
tmp = x * -3.0;
} else if (z <= 0.0026) {
tmp = x + (y * 4.0);
} 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 <= (-6500.0d0)) then
tmp = x * (z * 6.0d0)
else if (z <= 2.6d-192) then
tmp = x * (-3.0d0)
else if (z <= 0.0026d0) then
tmp = x + (y * 4.0d0)
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 <= -6500.0) {
tmp = x * (z * 6.0);
} else if (z <= 2.6e-192) {
tmp = x * -3.0;
} else if (z <= 0.0026) {
tmp = x + (y * 4.0);
} else {
tmp = 6.0 * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6500.0: tmp = x * (z * 6.0) elif z <= 2.6e-192: tmp = x * -3.0 elif z <= 0.0026: tmp = x + (y * 4.0) else: tmp = 6.0 * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6500.0) tmp = Float64(x * Float64(z * 6.0)); elseif (z <= 2.6e-192) tmp = Float64(x * -3.0); elseif (z <= 0.0026) tmp = Float64(x + Float64(y * 4.0)); else tmp = Float64(6.0 * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6500.0) tmp = x * (z * 6.0); elseif (z <= 2.6e-192) tmp = x * -3.0; elseif (z <= 0.0026) tmp = x + (y * 4.0); else tmp = 6.0 * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6500.0], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.6e-192], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.0026], N[(x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-192}:\\
\;\;\;\;x \cdot -3\\
\mathbf{elif}\;z \leq 0.0026:\\
\;\;\;\;x + y \cdot 4\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -6500Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 41.0%
metadata-eval41.0%
cancel-sign-sub-inv41.0%
*-commutative41.0%
cancel-sign-sub-inv41.0%
distribute-lft-neg-in41.0%
*-commutative41.0%
sub-neg41.0%
distribute-lft-in41.0%
metadata-eval41.0%
distribute-rgt-neg-out41.0%
distribute-lft-neg-in41.0%
metadata-eval41.0%
mul-1-neg41.0%
distribute-lft-in41.0%
metadata-eval41.0%
associate-+r+41.0%
metadata-eval41.0%
associate-*r*41.0%
metadata-eval41.0%
*-commutative41.0%
Simplified41.0%
Taylor expanded in z around inf 40.8%
*-commutative40.8%
Simplified40.8%
if -6500 < z < 2.6000000000000002e-192Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 54.6%
metadata-eval54.6%
cancel-sign-sub-inv54.6%
*-commutative54.6%
cancel-sign-sub-inv54.6%
distribute-lft-neg-in54.6%
*-commutative54.6%
sub-neg54.6%
distribute-lft-in54.6%
metadata-eval54.6%
distribute-rgt-neg-out54.6%
distribute-lft-neg-in54.6%
metadata-eval54.6%
mul-1-neg54.6%
distribute-lft-in54.6%
metadata-eval54.6%
associate-+r+54.6%
metadata-eval54.6%
associate-*r*54.6%
metadata-eval54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in z around 0 52.9%
*-commutative52.9%
Simplified52.9%
if 2.6000000000000002e-192 < z < 0.0025999999999999999Initial program 99.0%
+-commutative99.0%
associate-*l*99.6%
fma-define99.5%
metadata-eval99.5%
Simplified99.5%
fma-undefine99.6%
Applied egg-rr99.6%
Taylor expanded in y around inf 62.0%
associate-*r*62.1%
Simplified62.1%
Taylor expanded in z around 0 57.5%
if 0.0025999999999999999 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 46.8%
metadata-eval46.8%
cancel-sign-sub-inv46.8%
*-commutative46.8%
cancel-sign-sub-inv46.8%
distribute-lft-neg-in46.8%
*-commutative46.8%
sub-neg46.8%
distribute-lft-in46.8%
metadata-eval46.8%
distribute-rgt-neg-out46.8%
distribute-lft-neg-in46.8%
metadata-eval46.8%
mul-1-neg46.8%
distribute-lft-in46.8%
metadata-eval46.8%
associate-+r+46.8%
metadata-eval46.8%
associate-*r*46.8%
metadata-eval46.8%
*-commutative46.8%
Simplified46.8%
Taylor expanded in z around inf 42.9%
Final simplification47.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.68) (not (<= z 0.53))) (+ x (* (- y x) (* z -6.0))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.53)) {
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.68d0)) .or. (.not. (z <= 0.53d0))) 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.68) || !(z <= 0.53)) {
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.68) or not (z <= 0.53): 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.68) || !(z <= 0.53)) 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.68) || ~((z <= 0.53))) 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.68], N[Not[LessEqual[z, 0.53]], $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.68 \lor \neg \left(z \leq 0.53\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.680000000000000049 or 0.53000000000000003 < z Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 97.0%
associate-*r*97.1%
*-commutative97.1%
Simplified97.1%
if -0.680000000000000049 < z < 0.53000000000000003Initial program 99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in z around 0 96.0%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.68) (not (<= z 0.6))) (+ x (* -6.0 (* (- y x) z))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.68) || !(z <= 0.6)) {
tmp = x + (-6.0 * ((y - x) * z));
} else {
tmp = 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.68d0)) .or. (.not. (z <= 0.6d0))) 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.68) || !(z <= 0.6)) {
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.68) or not (z <= 0.6): 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.68) || !(z <= 0.6)) 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.68) || ~((z <= 0.6))) 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.68], N[Not[LessEqual[z, 0.6]], $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.68 \lor \neg \left(z \leq 0.6\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.680000000000000049 or 0.599999999999999978 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 97.0%
if -0.680000000000000049 < z < 0.599999999999999978Initial program 99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in z around 0 96.0%
Final simplification96.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.18) (not (<= z 3.4e-10))) (* y (+ 4.0 (* z -6.0))) (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.18) || !(z <= 3.4e-10)) {
tmp = y * (4.0 + (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.18d0)) .or. (.not. (z <= 3.4d-10))) then
tmp = y * (4.0d0 + (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.18) || !(z <= 3.4e-10)) {
tmp = y * (4.0 + (z * -6.0));
} else {
tmp = x + ((y - x) * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.18) or not (z <= 3.4e-10): tmp = y * (4.0 + (z * -6.0)) else: tmp = x + ((y - x) * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.18) || !(z <= 3.4e-10)) tmp = Float64(y * Float64(4.0 + 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.18) || ~((z <= 3.4e-10))) tmp = y * (4.0 + (z * -6.0)); else tmp = x + ((y - x) * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.18], N[Not[LessEqual[z, 3.4e-10]], $MachinePrecision]], N[(y * N[(4.0 + 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.18 \lor \neg \left(z \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y - x\right) \cdot 4\\
\end{array}
\end{array}
if z < -0.17999999999999999 or 3.40000000000000015e-10 < z Initial program 99.7%
+-commutative99.7%
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 62.5%
if -0.17999999999999999 < z < 3.40000000000000015e-10Initial program 99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in z around 0 98.0%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.8e-78) (not (<= y 3.6e+30))) (* y (+ 4.0 (* z -6.0))) (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.8e-78) || !(y <= 3.6e+30)) {
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 <= (-5.8d-78)) .or. (.not. (y <= 3.6d+30))) 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 <= -5.8e-78) || !(y <= 3.6e+30)) {
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 <= -5.8e-78) or not (y <= 3.6e+30): 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 <= -5.8e-78) || !(y <= 3.6e+30)) 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 <= -5.8e-78) || ~((y <= 3.6e+30))) 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, -5.8e-78], N[Not[LessEqual[y, 3.6e+30]], $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 -5.8 \cdot 10^{-78} \lor \neg \left(y \leq 3.6 \cdot 10^{+30}\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 < -5.8000000000000001e-78 or 3.6000000000000002e30 < y 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 inf 79.2%
if -5.8000000000000001e-78 < y < 3.6000000000000002e30Initial program 99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around inf 76.7%
metadata-eval76.7%
cancel-sign-sub-inv76.7%
*-commutative76.7%
cancel-sign-sub-inv76.7%
distribute-lft-neg-in76.7%
*-commutative76.7%
sub-neg76.7%
distribute-lft-in76.7%
metadata-eval76.7%
distribute-rgt-neg-out76.7%
distribute-lft-neg-in76.7%
metadata-eval76.7%
mul-1-neg76.7%
distribute-lft-in76.7%
metadata-eval76.7%
associate-+r+76.7%
metadata-eval76.7%
associate-*r*76.7%
metadata-eval76.7%
*-commutative76.7%
Simplified76.7%
Final simplification78.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.5e-109) (not (<= x 1.6e-174))) (* x (+ -3.0 (* z 6.0))) (+ x (* y 4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.5e-109) || !(x <= 1.6e-174)) {
tmp = x * (-3.0 + (z * 6.0));
} else {
tmp = x + (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 ((x <= (-2.5d-109)) .or. (.not. (x <= 1.6d-174))) then
tmp = x * ((-3.0d0) + (z * 6.0d0))
else
tmp = x + (y * 4.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.5e-109) || !(x <= 1.6e-174)) {
tmp = x * (-3.0 + (z * 6.0));
} else {
tmp = x + (y * 4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.5e-109) or not (x <= 1.6e-174): tmp = x * (-3.0 + (z * 6.0)) else: tmp = x + (y * 4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.5e-109) || !(x <= 1.6e-174)) tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0))); else tmp = Float64(x + Float64(y * 4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.5e-109) || ~((x <= 1.6e-174))) tmp = x * (-3.0 + (z * 6.0)); else tmp = x + (y * 4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.5e-109], N[Not[LessEqual[x, 1.6e-174]], $MachinePrecision]], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-109} \lor \neg \left(x \leq 1.6 \cdot 10^{-174}\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot 4\\
\end{array}
\end{array}
if x < -2.5000000000000001e-109 or 1.6e-174 < x Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 63.2%
metadata-eval63.2%
cancel-sign-sub-inv63.2%
*-commutative63.2%
cancel-sign-sub-inv63.2%
distribute-lft-neg-in63.2%
*-commutative63.2%
sub-neg63.2%
distribute-lft-in63.2%
metadata-eval63.2%
distribute-rgt-neg-out63.2%
distribute-lft-neg-in63.2%
metadata-eval63.2%
mul-1-neg63.2%
distribute-lft-in63.2%
metadata-eval63.2%
associate-+r+63.2%
metadata-eval63.2%
associate-*r*63.2%
metadata-eval63.2%
*-commutative63.2%
Simplified63.2%
if -2.5000000000000001e-109 < x < 1.6e-174Initial program 99.6%
+-commutative99.6%
associate-*l*99.9%
fma-define99.9%
metadata-eval99.9%
Simplified99.9%
fma-undefine99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 91.7%
associate-*r*91.8%
Simplified91.8%
Taylor expanded in z around 0 46.0%
Final simplification57.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -6500.0) (not (<= z 0.5))) (* 6.0 (* x z)) (* x -3.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6500.0) || !(z <= 0.5)) {
tmp = 6.0 * (x * z);
} 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 ((z <= (-6500.0d0)) .or. (.not. (z <= 0.5d0))) then
tmp = 6.0d0 * (x * z)
else
tmp = x * (-3.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6500.0) || !(z <= 0.5)) {
tmp = 6.0 * (x * z);
} else {
tmp = x * -3.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6500.0) or not (z <= 0.5): tmp = 6.0 * (x * z) else: tmp = x * -3.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6500.0) || !(z <= 0.5)) tmp = Float64(6.0 * Float64(x * z)); else tmp = Float64(x * -3.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6500.0) || ~((z <= 0.5))) tmp = 6.0 * (x * z); else tmp = x * -3.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6500.0], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500 \lor \neg \left(z \leq 0.5\right):\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot -3\\
\end{array}
\end{array}
if z < -6500 or 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 43.4%
metadata-eval43.4%
cancel-sign-sub-inv43.4%
*-commutative43.4%
cancel-sign-sub-inv43.4%
distribute-lft-neg-in43.4%
*-commutative43.4%
sub-neg43.4%
distribute-lft-in43.4%
metadata-eval43.4%
distribute-rgt-neg-out43.4%
distribute-lft-neg-in43.4%
metadata-eval43.4%
mul-1-neg43.4%
distribute-lft-in43.4%
metadata-eval43.4%
associate-+r+43.4%
metadata-eval43.4%
associate-*r*43.4%
metadata-eval43.4%
*-commutative43.4%
Simplified43.4%
Taylor expanded in z around inf 42.1%
if -6500 < z < 0.5Initial program 99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around inf 49.3%
metadata-eval49.3%
cancel-sign-sub-inv49.3%
*-commutative49.3%
cancel-sign-sub-inv49.3%
distribute-lft-neg-in49.3%
*-commutative49.3%
sub-neg49.3%
distribute-lft-in49.3%
metadata-eval49.3%
distribute-rgt-neg-out49.3%
distribute-lft-neg-in49.3%
metadata-eval49.3%
mul-1-neg49.3%
distribute-lft-in49.3%
metadata-eval49.3%
associate-+r+49.3%
metadata-eval49.3%
associate-*r*49.3%
metadata-eval49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in z around 0 47.4%
*-commutative47.4%
Simplified47.4%
Final simplification44.6%
(FPCore (x y z) :precision binary64 (if (<= z -6500.0) (* x (* z 6.0)) (if (<= z 0.5) (* x -3.0) (* 6.0 (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6500.0) {
tmp = x * (z * 6.0);
} else if (z <= 0.5) {
tmp = x * -3.0;
} 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 <= (-6500.0d0)) then
tmp = x * (z * 6.0d0)
else if (z <= 0.5d0) then
tmp = x * (-3.0d0)
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 <= -6500.0) {
tmp = x * (z * 6.0);
} else if (z <= 0.5) {
tmp = x * -3.0;
} else {
tmp = 6.0 * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6500.0: tmp = x * (z * 6.0) elif z <= 0.5: tmp = x * -3.0 else: tmp = 6.0 * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6500.0) tmp = Float64(x * Float64(z * 6.0)); elseif (z <= 0.5) tmp = Float64(x * -3.0); else tmp = Float64(6.0 * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6500.0) tmp = x * (z * 6.0); elseif (z <= 0.5) tmp = x * -3.0; else tmp = 6.0 * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6500.0], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6500:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;x \cdot -3\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -6500Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 41.0%
metadata-eval41.0%
cancel-sign-sub-inv41.0%
*-commutative41.0%
cancel-sign-sub-inv41.0%
distribute-lft-neg-in41.0%
*-commutative41.0%
sub-neg41.0%
distribute-lft-in41.0%
metadata-eval41.0%
distribute-rgt-neg-out41.0%
distribute-lft-neg-in41.0%
metadata-eval41.0%
mul-1-neg41.0%
distribute-lft-in41.0%
metadata-eval41.0%
associate-+r+41.0%
metadata-eval41.0%
associate-*r*41.0%
metadata-eval41.0%
*-commutative41.0%
Simplified41.0%
Taylor expanded in z around inf 40.8%
*-commutative40.8%
Simplified40.8%
if -6500 < z < 0.5Initial program 99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in x around inf 49.3%
metadata-eval49.3%
cancel-sign-sub-inv49.3%
*-commutative49.3%
cancel-sign-sub-inv49.3%
distribute-lft-neg-in49.3%
*-commutative49.3%
sub-neg49.3%
distribute-lft-in49.3%
metadata-eval49.3%
distribute-rgt-neg-out49.3%
distribute-lft-neg-in49.3%
metadata-eval49.3%
mul-1-neg49.3%
distribute-lft-in49.3%
metadata-eval49.3%
associate-+r+49.3%
metadata-eval49.3%
associate-*r*49.3%
metadata-eval49.3%
*-commutative49.3%
Simplified49.3%
Taylor expanded in z around 0 47.4%
*-commutative47.4%
Simplified47.4%
if 0.5 < z Initial program 99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 45.9%
metadata-eval45.9%
cancel-sign-sub-inv45.9%
*-commutative45.9%
cancel-sign-sub-inv45.9%
distribute-lft-neg-in45.9%
*-commutative45.9%
sub-neg45.9%
distribute-lft-in46.0%
metadata-eval46.0%
distribute-rgt-neg-out46.0%
distribute-lft-neg-in46.0%
metadata-eval46.0%
mul-1-neg46.0%
distribute-lft-in46.0%
metadata-eval46.0%
associate-+r+46.0%
metadata-eval46.0%
associate-*r*46.0%
metadata-eval46.0%
*-commutative46.0%
Simplified46.0%
Taylor expanded in z around inf 43.6%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 (- 0.6666666666666666 z)))))
double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((y - x) * (6.0d0 * (0.6666666666666666d0 - z)))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (6.0 * (0.6666666666666666 - z)));
}
def code(x, y, z): return x + ((y - x) * (6.0 * (0.6666666666666666 - z)))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(6.0 * Float64(0.6666666666666666 - z)))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (6.0 * (0.6666666666666666 - z))); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)
\end{array}
Initial program 99.5%
+-commutative99.5%
associate-*l*99.8%
fma-define99.8%
metadata-eval99.8%
Simplified99.8%
fma-undefine99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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.5%
metadata-eval99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (* x -3.0))
double code(double x, double y, double z) {
return x * -3.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (-3.0d0)
end function
public static double code(double x, double y, double z) {
return x * -3.0;
}
def code(x, y, z): return x * -3.0
function code(x, y, z) return Float64(x * -3.0) end
function tmp = code(x, y, z) tmp = x * -3.0; end
code[x_, y_, z_] := N[(x * -3.0), $MachinePrecision]
\begin{array}{l}
\\
x \cdot -3
\end{array}
Initial program 99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in x around inf 46.3%
metadata-eval46.3%
cancel-sign-sub-inv46.3%
*-commutative46.3%
cancel-sign-sub-inv46.3%
distribute-lft-neg-in46.3%
*-commutative46.3%
sub-neg46.3%
distribute-lft-in46.3%
metadata-eval46.3%
distribute-rgt-neg-out46.3%
distribute-lft-neg-in46.3%
metadata-eval46.3%
mul-1-neg46.3%
distribute-lft-in46.3%
metadata-eval46.3%
associate-+r+46.3%
metadata-eval46.3%
associate-*r*46.3%
metadata-eval46.3%
*-commutative46.3%
Simplified46.3%
Taylor expanded in z around 0 24.3%
*-commutative24.3%
Simplified24.3%
(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.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in z around inf 51.6%
Taylor expanded in z around 0 2.5%
herbie shell --seed 2024091
(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))))