
(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 11 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 (fma (* (- y x) z) 6.0 x))
double code(double x, double y, double z) {
return fma(((y - x) * z), 6.0, x);
}
function code(x, y, z) return fma(Float64(Float64(y - x) * z), 6.0, x) end
code[x_, y_, z_] := N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * 6.0 + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)
\end{array}
Initial program 99.8%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.8%
fma-define99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (fma z (* (- x y) -6.0) x))
double code(double x, double y, double z) {
return fma(z, ((x - y) * -6.0), x);
}
function code(x, y, z) return fma(z, Float64(Float64(x - y) * -6.0), x) end
code[x_, y_, z_] := N[(z * N[(N[(x - y), $MachinePrecision] * -6.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, \left(x - y\right) \cdot -6, 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 (* y z))) (t_1 (* x (* z (- 6.0)))))
(if (<= z -5.9e+203)
(* y (* z 6.0))
(if (<= z -6.2e+153)
t_1
(if (<= z -3.9e+53)
t_0
(if (<= z -2.8e+17)
t_1
(if (<= z -12.5)
t_0
(if (<= z 9.5e-36) x (if (<= z 1.45e+251) t_0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -5.9e+203) {
tmp = y * (z * 6.0);
} else if (z <= -6.2e+153) {
tmp = t_1;
} else if (z <= -3.9e+53) {
tmp = t_0;
} else if (z <= -2.8e+17) {
tmp = t_1;
} else if (z <= -12.5) {
tmp = t_0;
} else if (z <= 9.5e-36) {
tmp = x;
} else if (z <= 1.45e+251) {
tmp = t_0;
} else {
tmp = t_1;
}
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 * (y * z)
t_1 = x * (z * -6.0d0)
if (z <= (-5.9d+203)) then
tmp = y * (z * 6.0d0)
else if (z <= (-6.2d+153)) then
tmp = t_1
else if (z <= (-3.9d+53)) then
tmp = t_0
else if (z <= (-2.8d+17)) then
tmp = t_1
else if (z <= (-12.5d0)) then
tmp = t_0
else if (z <= 9.5d-36) then
tmp = x
else if (z <= 1.45d+251) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -5.9e+203) {
tmp = y * (z * 6.0);
} else if (z <= -6.2e+153) {
tmp = t_1;
} else if (z <= -3.9e+53) {
tmp = t_0;
} else if (z <= -2.8e+17) {
tmp = t_1;
} else if (z <= -12.5) {
tmp = t_0;
} else if (z <= 9.5e-36) {
tmp = x;
} else if (z <= 1.45e+251) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (y * z) t_1 = x * (z * -6.0) tmp = 0 if z <= -5.9e+203: tmp = y * (z * 6.0) elif z <= -6.2e+153: tmp = t_1 elif z <= -3.9e+53: tmp = t_0 elif z <= -2.8e+17: tmp = t_1 elif z <= -12.5: tmp = t_0 elif z <= 9.5e-36: tmp = x elif z <= 1.45e+251: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(y * z)) t_1 = Float64(x * Float64(z * Float64(-6.0))) tmp = 0.0 if (z <= -5.9e+203) tmp = Float64(y * Float64(z * 6.0)); elseif (z <= -6.2e+153) tmp = t_1; elseif (z <= -3.9e+53) tmp = t_0; elseif (z <= -2.8e+17) tmp = t_1; elseif (z <= -12.5) tmp = t_0; elseif (z <= 9.5e-36) tmp = x; elseif (z <= 1.45e+251) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (y * z); t_1 = x * (z * -6.0); tmp = 0.0; if (z <= -5.9e+203) tmp = y * (z * 6.0); elseif (z <= -6.2e+153) tmp = t_1; elseif (z <= -3.9e+53) tmp = t_0; elseif (z <= -2.8e+17) tmp = t_1; elseif (z <= -12.5) tmp = t_0; elseif (z <= 9.5e-36) tmp = x; elseif (z <= 1.45e+251) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * (-6.0)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+203], N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6.2e+153], t$95$1, If[LessEqual[z, -3.9e+53], t$95$0, If[LessEqual[z, -2.8e+17], t$95$1, If[LessEqual[z, -12.5], t$95$0, If[LessEqual[z, 9.5e-36], x, If[LessEqual[z, 1.45e+251], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
t_1 := x \cdot \left(z \cdot \left(-6\right)\right)\\
\mathbf{if}\;z \leq -5.9 \cdot 10^{+203}:\\
\;\;\;\;y \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{+153}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.9 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{+17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -12.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{-36}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+251}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.89999999999999972e203Initial program 99.8%
associate-*r*99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 73.5%
*-commutative73.5%
associate-*r*73.5%
Simplified73.5%
if -5.89999999999999972e203 < z < -6.2e153 or -3.89999999999999976e53 < z < -2.8e17 or 1.45e251 < z Initial program 99.8%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.6%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 99.6%
Taylor expanded in y around 0 83.0%
mul-1-neg83.0%
distribute-lft-neg-out83.0%
*-commutative83.0%
Simplified83.0%
*-commutative83.0%
distribute-rgt-neg-out83.0%
distribute-lft-neg-out83.0%
*-commutative83.0%
add-sqr-sqrt30.2%
sqrt-unprod24.7%
sqr-neg24.7%
sqrt-unprod0.6%
add-sqr-sqrt4.0%
associate-*l*4.0%
add-sqr-sqrt0.6%
sqrt-unprod24.7%
sqr-neg24.7%
sqrt-unprod30.2%
add-sqr-sqrt83.1%
*-commutative83.1%
Applied egg-rr83.1%
if -6.2e153 < z < -3.89999999999999976e53 or -2.8e17 < z < -12.5 or 9.5000000000000003e-36 < z < 1.45e251Initial program 99.5%
associate-*r*99.6%
+-commutative99.6%
*-commutative99.6%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 61.0%
*-commutative61.0%
Simplified61.0%
if -12.5 < z < 9.5000000000000003e-36Initial program 99.9%
Taylor expanded in z around 0 76.7%
Final simplification72.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 6.0 (* y z))) (t_1 (* x (* z (- 6.0)))))
(if (<= z -1.1e+206)
(* y (* z 6.0))
(if (<= z -1.45e+154)
(* 6.0 (* x (- z)))
(if (<= z -1.4e+53)
t_0
(if (<= z -3.4e+20)
t_1
(if (<= z -12.5)
t_0
(if (<= z 1.05e-35) x (if (<= z 2.7e+249) t_0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -1.1e+206) {
tmp = y * (z * 6.0);
} else if (z <= -1.45e+154) {
tmp = 6.0 * (x * -z);
} else if (z <= -1.4e+53) {
tmp = t_0;
} else if (z <= -3.4e+20) {
tmp = t_1;
} else if (z <= -12.5) {
tmp = t_0;
} else if (z <= 1.05e-35) {
tmp = x;
} else if (z <= 2.7e+249) {
tmp = t_0;
} else {
tmp = t_1;
}
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 * (y * z)
t_1 = x * (z * -6.0d0)
if (z <= (-1.1d+206)) then
tmp = y * (z * 6.0d0)
else if (z <= (-1.45d+154)) then
tmp = 6.0d0 * (x * -z)
else if (z <= (-1.4d+53)) then
tmp = t_0
else if (z <= (-3.4d+20)) then
tmp = t_1
else if (z <= (-12.5d0)) then
tmp = t_0
else if (z <= 1.05d-35) then
tmp = x
else if (z <= 2.7d+249) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 6.0 * (y * z);
double t_1 = x * (z * -6.0);
double tmp;
if (z <= -1.1e+206) {
tmp = y * (z * 6.0);
} else if (z <= -1.45e+154) {
tmp = 6.0 * (x * -z);
} else if (z <= -1.4e+53) {
tmp = t_0;
} else if (z <= -3.4e+20) {
tmp = t_1;
} else if (z <= -12.5) {
tmp = t_0;
} else if (z <= 1.05e-35) {
tmp = x;
} else if (z <= 2.7e+249) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 6.0 * (y * z) t_1 = x * (z * -6.0) tmp = 0 if z <= -1.1e+206: tmp = y * (z * 6.0) elif z <= -1.45e+154: tmp = 6.0 * (x * -z) elif z <= -1.4e+53: tmp = t_0 elif z <= -3.4e+20: tmp = t_1 elif z <= -12.5: tmp = t_0 elif z <= 1.05e-35: tmp = x elif z <= 2.7e+249: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(6.0 * Float64(y * z)) t_1 = Float64(x * Float64(z * Float64(-6.0))) tmp = 0.0 if (z <= -1.1e+206) tmp = Float64(y * Float64(z * 6.0)); elseif (z <= -1.45e+154) tmp = Float64(6.0 * Float64(x * Float64(-z))); elseif (z <= -1.4e+53) tmp = t_0; elseif (z <= -3.4e+20) tmp = t_1; elseif (z <= -12.5) tmp = t_0; elseif (z <= 1.05e-35) tmp = x; elseif (z <= 2.7e+249) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 6.0 * (y * z); t_1 = x * (z * -6.0); tmp = 0.0; if (z <= -1.1e+206) tmp = y * (z * 6.0); elseif (z <= -1.45e+154) tmp = 6.0 * (x * -z); elseif (z <= -1.4e+53) tmp = t_0; elseif (z <= -3.4e+20) tmp = t_1; elseif (z <= -12.5) tmp = t_0; elseif (z <= 1.05e-35) tmp = x; elseif (z <= 2.7e+249) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * (-6.0)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.1e+206], N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.45e+154], N[(6.0 * N[(x * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -1.4e+53], t$95$0, If[LessEqual[z, -3.4e+20], t$95$1, If[LessEqual[z, -12.5], t$95$0, If[LessEqual[z, 1.05e-35], x, If[LessEqual[z, 2.7e+249], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
t_1 := x \cdot \left(z \cdot \left(-6\right)\right)\\
\mathbf{if}\;z \leq -1.1 \cdot 10^{+206}:\\
\;\;\;\;y \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq -1.45 \cdot 10^{+154}:\\
\;\;\;\;6 \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{+20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -12.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{-35}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{+249}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.10000000000000001e206Initial program 99.8%
associate-*r*99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r*99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 73.5%
*-commutative73.5%
associate-*r*73.5%
Simplified73.5%
if -1.10000000000000001e206 < z < -1.4499999999999999e154Initial program 99.8%
associate-*r*99.6%
+-commutative99.6%
*-commutative99.6%
associate-*r*99.6%
fma-define99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 99.6%
Taylor expanded in y around 0 85.6%
mul-1-neg85.6%
distribute-lft-neg-out85.6%
*-commutative85.6%
Simplified85.6%
if -1.4499999999999999e154 < z < -1.4e53 or -3.4e20 < z < -12.5 or 1.05e-35 < z < 2.70000000000000018e249Initial program 99.5%
associate-*r*99.6%
+-commutative99.6%
*-commutative99.6%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 61.0%
*-commutative61.0%
Simplified61.0%
if -1.4e53 < z < -3.4e20 or 2.70000000000000018e249 < z Initial program 99.8%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.6%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 99.6%
Taylor expanded in y around 0 82.3%
mul-1-neg82.3%
distribute-lft-neg-out82.3%
*-commutative82.3%
Simplified82.3%
*-commutative82.3%
distribute-rgt-neg-out82.3%
distribute-lft-neg-out82.3%
*-commutative82.3%
add-sqr-sqrt30.6%
sqrt-unprod23.5%
sqr-neg23.5%
sqrt-unprod0.6%
add-sqr-sqrt4.8%
associate-*l*4.8%
add-sqr-sqrt0.6%
sqrt-unprod23.6%
sqr-neg23.6%
sqrt-unprod30.6%
add-sqr-sqrt82.5%
*-commutative82.5%
Applied egg-rr82.5%
if -12.5 < z < 1.05e-35Initial program 99.9%
Taylor expanded in z around 0 76.7%
Final simplification72.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -6e-27) (not (<= z 1.05e-35))) (* -6.0 (* z (- x y))) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6e-27) || !(z <= 1.05e-35)) {
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 <= (-6d-27)) .or. (.not. (z <= 1.05d-35))) 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 <= -6e-27) || !(z <= 1.05e-35)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6e-27) or not (z <= 1.05e-35): tmp = -6.0 * (z * (x - y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6e-27) || !(z <= 1.05e-35)) 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 <= -6e-27) || ~((z <= 1.05e-35))) tmp = -6.0 * (z * (x - y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6e-27], N[Not[LessEqual[z, 1.05e-35]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{-27} \lor \neg \left(z \leq 1.05 \cdot 10^{-35}\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.0000000000000002e-27 or 1.05e-35 < z Initial program 99.6%
+-commutative99.6%
*-commutative99.6%
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 95.3%
if -6.0000000000000002e-27 < z < 1.05e-35Initial program 99.9%
Taylor expanded in z around 0 77.7%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.165) (not (<= z 0.17))) (* -6.0 (* z (- x y))) (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.17)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-0.165d0)) .or. (.not. (z <= 0.17d0))) then
tmp = (-6.0d0) * (z * (x - y))
else
tmp = x + (6.0d0 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.165) || !(z <= 0.17)) {
tmp = -6.0 * (z * (x - y));
} else {
tmp = x + (6.0 * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.165) or not (z <= 0.17): tmp = -6.0 * (z * (x - y)) else: tmp = x + (6.0 * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.165) || !(z <= 0.17)) tmp = Float64(-6.0 * Float64(z * Float64(x - y))); else tmp = Float64(x + Float64(6.0 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.165) || ~((z <= 0.17))) tmp = -6.0 * (z * (x - y)); else tmp = x + (6.0 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.165], N[Not[LessEqual[z, 0.17]], $MachinePrecision]], N[(-6.0 * N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.165 \lor \neg \left(z \leq 0.17\right):\\
\;\;\;\;-6 \cdot \left(z \cdot \left(x - y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.165000000000000008 or 0.170000000000000012 < 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 97.9%
if -0.165000000000000008 < z < 0.170000000000000012Initial program 99.9%
Taylor expanded in y around inf 99.2%
*-commutative99.2%
Simplified99.2%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -12.5) (not (<= z 2.15e-39))) (* 6.0 (* y z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -12.5) || !(z <= 2.15e-39)) {
tmp = 6.0 * (y * 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 <= (-12.5d0)) .or. (.not. (z <= 2.15d-39))) then
tmp = 6.0d0 * (y * z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -12.5) || !(z <= 2.15e-39)) {
tmp = 6.0 * (y * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -12.5) or not (z <= 2.15e-39): tmp = 6.0 * (y * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -12.5) || !(z <= 2.15e-39)) tmp = Float64(6.0 * Float64(y * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -12.5) || ~((z <= 2.15e-39))) tmp = 6.0 * (y * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -12.5], N[Not[LessEqual[z, 2.15e-39]], $MachinePrecision]], N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -12.5 \lor \neg \left(z \leq 2.15 \cdot 10^{-39}\right):\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -12.5 or 2.15e-39 < z Initial program 99.6%
associate-*r*99.7%
+-commutative99.7%
*-commutative99.7%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 56.3%
*-commutative56.3%
Simplified56.3%
if -12.5 < z < 2.15e-39Initial program 99.9%
Taylor expanded in z around 0 76.7%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (if (<= z -12.5) (* y (* z 6.0)) (if (<= z 3.7e-37) x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -12.5) {
tmp = y * (z * 6.0);
} else if (z <= 3.7e-37) {
tmp = x;
} else {
tmp = 6.0 * (y * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-12.5d0)) then
tmp = y * (z * 6.0d0)
else if (z <= 3.7d-37) then
tmp = x
else
tmp = 6.0d0 * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -12.5) {
tmp = y * (z * 6.0);
} else if (z <= 3.7e-37) {
tmp = x;
} else {
tmp = 6.0 * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -12.5: tmp = y * (z * 6.0) elif z <= 3.7e-37: tmp = x else: tmp = 6.0 * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -12.5) tmp = Float64(y * Float64(z * 6.0)); elseif (z <= 3.7e-37) tmp = x; else tmp = Float64(6.0 * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -12.5) tmp = y * (z * 6.0); elseif (z <= 3.7e-37) tmp = x; else tmp = 6.0 * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -12.5], N[(y * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.7e-37], x, N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -12.5:\\
\;\;\;\;y \cdot \left(z \cdot 6\right)\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{-37}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -12.5Initial program 99.7%
associate-*r*99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r*99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 58.4%
*-commutative58.4%
associate-*r*58.4%
Simplified58.4%
if -12.5 < z < 3.7e-37Initial program 99.9%
Taylor expanded in z around 0 76.7%
if 3.7e-37 < z Initial program 99.6%
associate-*r*99.5%
+-commutative99.5%
*-commutative99.5%
associate-*r*99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 54.2%
*-commutative54.2%
Simplified54.2%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (+ x (* z (* (- y x) 6.0))))
double code(double x, double y, double z) {
return x + (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 + (z * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + (z * ((y - x) * 6.0));
}
def code(x, y, z): return x + (z * ((y - x) * 6.0))
function code(x, y, z) return Float64(x + Float64(z * Float64(Float64(y - x) * 6.0))) end
function tmp = code(x, y, z) tmp = x + (z * ((y - x) * 6.0)); end
code[x_, y_, z_] := N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + z \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* z 6.0))))
double code(double x, double y, double z) {
return x + ((y - x) * (z * 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 + ((y - x) * (z * 6.0d0))
end function
public static double code(double x, double y, double z) {
return x + ((y - x) * (z * 6.0));
}
def code(x, y, z): return x + ((y - x) * (z * 6.0))
function code(x, y, z) return Float64(x + Float64(Float64(y - x) * Float64(z * 6.0))) end
function tmp = code(x, y, z) tmp = x + ((y - x) * (z * 6.0)); end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y - x\right) \cdot \left(z \cdot 6\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.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 38.0%
Final simplification38.0%
(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 2024079
(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)))