
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * 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 * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* y z))))
double code(double x, double y, double z) {
return x * (1.0 - (y * 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 * (1.0d0 - (y * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (y * z));
}
def code(x, y, z): return x * (1.0 - (y * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(y * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (y * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - y \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 (* y z))))) (if (<= t_0 1e+306) t_0 (* y (* x (- z))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= 1e+306) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - (y * z))
if (t_0 <= 1d+306) then
tmp = t_0
else
tmp = y * (x * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - (y * z));
double tmp;
if (t_0 <= 1e+306) {
tmp = t_0;
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - (y * z)) tmp = 0 if t_0 <= 1e+306: tmp = t_0 else: tmp = y * (x * -z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(y * z))) tmp = 0.0 if (t_0 <= 1e+306) tmp = t_0; else tmp = Float64(y * Float64(x * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - (y * z)); tmp = 0.0; if (t_0 <= 1e+306) tmp = t_0; else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+306], t$95$0, N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - y \cdot z\right)\\
\mathbf{if}\;t_0 \leq 10^{+306}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 y z))) < 1.00000000000000002e306Initial program 99.0%
if 1.00000000000000002e306 < (*.f64 x (-.f64 1 (*.f64 y z))) Initial program 84.8%
Taylor expanded in y around inf 84.8%
mul-1-neg84.8%
associate-*r*99.9%
distribute-rgt-neg-in99.9%
*-commutative99.9%
associate-*r*100.0%
distribute-rgt-neg-out100.0%
Simplified100.0%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(if (or (<= y -8e+56)
(and (not (<= y -1.65e-15))
(or (<= y -3.7e-28) (not (<= y 1.95e-62)))))
(* z (* y (- x)))
x))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+56) || (!(y <= -1.65e-15) && ((y <= -3.7e-28) || !(y <= 1.95e-62)))) {
tmp = z * (y * -x);
} 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 ((y <= (-8d+56)) .or. (.not. (y <= (-1.65d-15))) .and. (y <= (-3.7d-28)) .or. (.not. (y <= 1.95d-62))) then
tmp = z * (y * -x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8e+56) || (!(y <= -1.65e-15) && ((y <= -3.7e-28) || !(y <= 1.95e-62)))) {
tmp = z * (y * -x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8e+56) or (not (y <= -1.65e-15) and ((y <= -3.7e-28) or not (y <= 1.95e-62))): tmp = z * (y * -x) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8e+56) || (!(y <= -1.65e-15) && ((y <= -3.7e-28) || !(y <= 1.95e-62)))) tmp = Float64(z * Float64(y * Float64(-x))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8e+56) || (~((y <= -1.65e-15)) && ((y <= -3.7e-28) || ~((y <= 1.95e-62))))) tmp = z * (y * -x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8e+56], And[N[Not[LessEqual[y, -1.65e-15]], $MachinePrecision], Or[LessEqual[y, -3.7e-28], N[Not[LessEqual[y, 1.95e-62]], $MachinePrecision]]]], N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+56} \lor \neg \left(y \leq -1.65 \cdot 10^{-15}\right) \land \left(y \leq -3.7 \cdot 10^{-28} \lor \neg \left(y \leq 1.95 \cdot 10^{-62}\right)\right):\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -8.00000000000000074e56 or -1.65e-15 < y < -3.7000000000000002e-28 or 1.9500000000000002e-62 < y Initial program 94.9%
Taylor expanded in y around inf 71.2%
mul-1-neg71.2%
associate-*r*69.3%
Simplified69.3%
if -8.00000000000000074e56 < y < -1.65e-15 or -3.7000000000000002e-28 < y < 1.9500000000000002e-62Initial program 99.9%
Taylor expanded in y around 0 78.1%
Final simplification73.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* y (- z)))))
(if (<= y -4.6e+58)
t_0
(if (<= y -8.5e-15)
x
(if (<= y -1.45e-29) t_0 (if (<= y 3.4e-62) x (* z (* y (- x)))))))))
double code(double x, double y, double z) {
double t_0 = x * (y * -z);
double tmp;
if (y <= -4.6e+58) {
tmp = t_0;
} else if (y <= -8.5e-15) {
tmp = x;
} else if (y <= -1.45e-29) {
tmp = t_0;
} else if (y <= 3.4e-62) {
tmp = x;
} else {
tmp = z * (y * -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) :: t_0
real(8) :: tmp
t_0 = x * (y * -z)
if (y <= (-4.6d+58)) then
tmp = t_0
else if (y <= (-8.5d-15)) then
tmp = x
else if (y <= (-1.45d-29)) then
tmp = t_0
else if (y <= 3.4d-62) then
tmp = x
else
tmp = z * (y * -x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y * -z);
double tmp;
if (y <= -4.6e+58) {
tmp = t_0;
} else if (y <= -8.5e-15) {
tmp = x;
} else if (y <= -1.45e-29) {
tmp = t_0;
} else if (y <= 3.4e-62) {
tmp = x;
} else {
tmp = z * (y * -x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * -z) tmp = 0 if y <= -4.6e+58: tmp = t_0 elif y <= -8.5e-15: tmp = x elif y <= -1.45e-29: tmp = t_0 elif y <= 3.4e-62: tmp = x else: tmp = z * (y * -x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * Float64(-z))) tmp = 0.0 if (y <= -4.6e+58) tmp = t_0; elseif (y <= -8.5e-15) tmp = x; elseif (y <= -1.45e-29) tmp = t_0; elseif (y <= 3.4e-62) tmp = x; else tmp = Float64(z * Float64(y * Float64(-x))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * -z); tmp = 0.0; if (y <= -4.6e+58) tmp = t_0; elseif (y <= -8.5e-15) tmp = x; elseif (y <= -1.45e-29) tmp = t_0; elseif (y <= 3.4e-62) tmp = x; else tmp = z * (y * -x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.6e+58], t$95$0, If[LessEqual[y, -8.5e-15], x, If[LessEqual[y, -1.45e-29], t$95$0, If[LessEqual[y, 3.4e-62], x, N[(z * N[(y * (-x)), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{if}\;y \leq -4.6 \cdot 10^{+58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -8.5 \cdot 10^{-15}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-29}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-62}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot \left(-x\right)\right)\\
\end{array}
\end{array}
if y < -4.60000000000000005e58 or -8.50000000000000007e-15 < y < -1.45000000000000012e-29Initial program 96.1%
Taylor expanded in y around inf 82.5%
mul-1-neg82.5%
distribute-rgt-neg-in82.5%
distribute-rgt-neg-out82.5%
Simplified82.5%
if -4.60000000000000005e58 < y < -8.50000000000000007e-15 or -1.45000000000000012e-29 < y < 3.39999999999999988e-62Initial program 99.9%
Taylor expanded in y around 0 78.1%
if 3.39999999999999988e-62 < y Initial program 94.2%
Taylor expanded in y around inf 64.1%
mul-1-neg64.1%
associate-*r*64.3%
Simplified64.3%
Final simplification74.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* x (- z)))))
(if (<= y -4.4e+57)
t_0
(if (<= y -2.22e-13)
x
(if (<= y -6.2e-28) (* x (* y (- z))) (if (<= y 3.4e-62) x t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (x * -z);
double tmp;
if (y <= -4.4e+57) {
tmp = t_0;
} else if (y <= -2.22e-13) {
tmp = x;
} else if (y <= -6.2e-28) {
tmp = x * (y * -z);
} else if (y <= 3.4e-62) {
tmp = x;
} 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 = y * (x * -z)
if (y <= (-4.4d+57)) then
tmp = t_0
else if (y <= (-2.22d-13)) then
tmp = x
else if (y <= (-6.2d-28)) then
tmp = x * (y * -z)
else if (y <= 3.4d-62) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x * -z);
double tmp;
if (y <= -4.4e+57) {
tmp = t_0;
} else if (y <= -2.22e-13) {
tmp = x;
} else if (y <= -6.2e-28) {
tmp = x * (y * -z);
} else if (y <= 3.4e-62) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x * -z) tmp = 0 if y <= -4.4e+57: tmp = t_0 elif y <= -2.22e-13: tmp = x elif y <= -6.2e-28: tmp = x * (y * -z) elif y <= 3.4e-62: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x * Float64(-z))) tmp = 0.0 if (y <= -4.4e+57) tmp = t_0; elseif (y <= -2.22e-13) tmp = x; elseif (y <= -6.2e-28) tmp = Float64(x * Float64(y * Float64(-z))); elseif (y <= 3.4e-62) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x * -z); tmp = 0.0; if (y <= -4.4e+57) tmp = t_0; elseif (y <= -2.22e-13) tmp = x; elseif (y <= -6.2e-28) tmp = x * (y * -z); elseif (y <= 3.4e-62) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.4e+57], t$95$0, If[LessEqual[y, -2.22e-13], x, If[LessEqual[y, -6.2e-28], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e-62], x, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(x \cdot \left(-z\right)\right)\\
\mathbf{if}\;y \leq -4.4 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.22 \cdot 10^{-13}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-62}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.4000000000000001e57 or 3.39999999999999988e-62 < y Initial program 94.9%
Taylor expanded in y around inf 71.1%
mul-1-neg71.1%
associate-*r*69.2%
distribute-rgt-neg-in69.2%
*-commutative69.2%
associate-*r*72.0%
distribute-rgt-neg-out72.0%
Simplified72.0%
if -4.4000000000000001e57 < y < -2.21999999999999988e-13 or -6.19999999999999984e-28 < y < 3.39999999999999988e-62Initial program 99.9%
Taylor expanded in y around 0 78.7%
if -2.21999999999999988e-13 < y < -6.19999999999999984e-28Initial program 100.0%
Taylor expanded in y around inf 85.1%
mul-1-neg85.1%
distribute-rgt-neg-in85.1%
distribute-rgt-neg-out85.1%
Simplified85.1%
Final simplification75.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 97.3%
Taylor expanded in y around 0 50.5%
Final simplification50.5%
herbie shell --seed 2023311
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))