
(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 7 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 (if (<= (* y z) -1e+269) (- (* z (* x y))) (if (<= (* y z) 1.5e+76) (* x (- 1.0 (* y z))) (* y (* x (- z))))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -1e+269) {
tmp = -(z * (x * y));
} else if ((y * z) <= 1.5e+76) {
tmp = x * (1.0 - (y * z));
} 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) :: tmp
if ((y * z) <= (-1d+269)) then
tmp = -(z * (x * y))
else if ((y * z) <= 1.5d+76) then
tmp = x * (1.0d0 - (y * z))
else
tmp = y * (x * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -1e+269) {
tmp = -(z * (x * y));
} else if ((y * z) <= 1.5e+76) {
tmp = x * (1.0 - (y * z));
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -1e+269: tmp = -(z * (x * y)) elif (y * z) <= 1.5e+76: tmp = x * (1.0 - (y * z)) else: tmp = y * (x * -z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -1e+269) tmp = Float64(-Float64(z * Float64(x * y))); elseif (Float64(y * z) <= 1.5e+76) tmp = Float64(x * Float64(1.0 - Float64(y * z))); else tmp = Float64(y * Float64(x * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -1e+269) tmp = -(z * (x * y)); elseif ((y * z) <= 1.5e+76) tmp = x * (1.0 - (y * z)); else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -1e+269], (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], 1.5e+76], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+269}:\\
\;\;\;\;-z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \cdot z \leq 1.5 \cdot 10^{+76}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1e269Initial program 69.9%
Taylor expanded in y around inf 69.9%
mul-1-neg69.9%
associate-*r*99.9%
Simplified99.9%
if -1e269 < (*.f64 y z) < 1.4999999999999999e76Initial program 99.9%
if 1.4999999999999999e76 < (*.f64 y z) Initial program 85.5%
Taylor expanded in y around inf 85.5%
mul-1-neg85.5%
associate-*r*97.7%
distribute-rgt-neg-in97.7%
*-commutative97.7%
associate-*l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* y (- z)))) (t_1 (- (* z (* x y)))))
(if (<= (* y z) -1e+269)
t_1
(if (<= (* y z) -1000000.0)
t_0
(if (<= (* y z) 1.0) x (if (<= (* y z) 5e+292) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = x * (y * -z);
double t_1 = -(z * (x * y));
double tmp;
if ((y * z) <= -1e+269) {
tmp = t_1;
} else if ((y * z) <= -1000000.0) {
tmp = t_0;
} else if ((y * z) <= 1.0) {
tmp = x;
} else if ((y * z) <= 5e+292) {
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 = x * (y * -z)
t_1 = -(z * (x * y))
if ((y * z) <= (-1d+269)) then
tmp = t_1
else if ((y * z) <= (-1000000.0d0)) then
tmp = t_0
else if ((y * z) <= 1.0d0) then
tmp = x
else if ((y * z) <= 5d+292) 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 = x * (y * -z);
double t_1 = -(z * (x * y));
double tmp;
if ((y * z) <= -1e+269) {
tmp = t_1;
} else if ((y * z) <= -1000000.0) {
tmp = t_0;
} else if ((y * z) <= 1.0) {
tmp = x;
} else if ((y * z) <= 5e+292) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * -z) t_1 = -(z * (x * y)) tmp = 0 if (y * z) <= -1e+269: tmp = t_1 elif (y * z) <= -1000000.0: tmp = t_0 elif (y * z) <= 1.0: tmp = x elif (y * z) <= 5e+292: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * Float64(-z))) t_1 = Float64(-Float64(z * Float64(x * y))) tmp = 0.0 if (Float64(y * z) <= -1e+269) tmp = t_1; elseif (Float64(y * z) <= -1000000.0) tmp = t_0; elseif (Float64(y * z) <= 1.0) tmp = x; elseif (Float64(y * z) <= 5e+292) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * -z); t_1 = -(z * (x * y)); tmp = 0.0; if ((y * z) <= -1e+269) tmp = t_1; elseif ((y * z) <= -1000000.0) tmp = t_0; elseif ((y * z) <= 1.0) tmp = x; elseif ((y * z) <= 5e+292) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[N[(y * z), $MachinePrecision], -1e+269], t$95$1, If[LessEqual[N[(y * z), $MachinePrecision], -1000000.0], t$95$0, If[LessEqual[N[(y * z), $MachinePrecision], 1.0], x, If[LessEqual[N[(y * z), $MachinePrecision], 5e+292], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot \left(-z\right)\right)\\
t_1 := -z \cdot \left(x \cdot y\right)\\
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+269}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \cdot z \leq -1000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \cdot z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;y \cdot z \leq 5 \cdot 10^{+292}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 y z) < -1e269 or 4.9999999999999996e292 < (*.f64 y z) Initial program 69.2%
Taylor expanded in y around inf 69.2%
mul-1-neg69.2%
associate-*r*99.8%
Simplified99.8%
if -1e269 < (*.f64 y z) < -1e6 or 1 < (*.f64 y z) < 4.9999999999999996e292Initial program 99.7%
Taylor expanded in y around inf 97.4%
mul-1-neg97.4%
associate-*r*88.7%
Simplified88.7%
Taylor expanded in x around 0 97.4%
if -1e6 < (*.f64 y z) < 1Initial program 100.0%
Taylor expanded in y around 0 97.3%
Final simplification97.8%
(FPCore (x y z)
:precision binary64
(if (<= (* y z) -1e+269)
(- (* z (* x y)))
(if (<= (* y z) -1000000.0)
(* x (* y (- z)))
(if (<= (* y z) 1.0) x (* y (* x (- z)))))))
double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -1e+269) {
tmp = -(z * (x * y));
} else if ((y * z) <= -1000000.0) {
tmp = x * (y * -z);
} else if ((y * z) <= 1.0) {
tmp = x;
} 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) :: tmp
if ((y * z) <= (-1d+269)) then
tmp = -(z * (x * y))
else if ((y * z) <= (-1000000.0d0)) then
tmp = x * (y * -z)
else if ((y * z) <= 1.0d0) then
tmp = x
else
tmp = y * (x * -z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y * z) <= -1e+269) {
tmp = -(z * (x * y));
} else if ((y * z) <= -1000000.0) {
tmp = x * (y * -z);
} else if ((y * z) <= 1.0) {
tmp = x;
} else {
tmp = y * (x * -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y * z) <= -1e+269: tmp = -(z * (x * y)) elif (y * z) <= -1000000.0: tmp = x * (y * -z) elif (y * z) <= 1.0: tmp = x else: tmp = y * (x * -z) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(y * z) <= -1e+269) tmp = Float64(-Float64(z * Float64(x * y))); elseif (Float64(y * z) <= -1000000.0) tmp = Float64(x * Float64(y * Float64(-z))); elseif (Float64(y * z) <= 1.0) tmp = x; else tmp = Float64(y * Float64(x * Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * z) <= -1e+269) tmp = -(z * (x * y)); elseif ((y * z) <= -1000000.0) tmp = x * (y * -z); elseif ((y * z) <= 1.0) tmp = x; else tmp = y * (x * -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(y * z), $MachinePrecision], -1e+269], (-N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[N[(y * z), $MachinePrecision], -1000000.0], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y * z), $MachinePrecision], 1.0], x, N[(y * N[(x * (-z)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1 \cdot 10^{+269}:\\
\;\;\;\;-z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \cdot z \leq -1000000:\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{elif}\;y \cdot z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot \left(-z\right)\right)\\
\end{array}
\end{array}
if (*.f64 y z) < -1e269Initial program 69.9%
Taylor expanded in y around inf 69.9%
mul-1-neg69.9%
associate-*r*99.9%
Simplified99.9%
if -1e269 < (*.f64 y z) < -1e6Initial program 99.7%
Taylor expanded in y around inf 97.5%
mul-1-neg97.5%
associate-*r*88.4%
Simplified88.4%
Taylor expanded in x around 0 97.5%
if -1e6 < (*.f64 y z) < 1Initial program 100.0%
Taylor expanded in y around 0 97.3%
if 1 < (*.f64 y z) Initial program 88.2%
Taylor expanded in y around inf 86.6%
mul-1-neg86.6%
associate-*r*93.1%
distribute-rgt-neg-in93.1%
*-commutative93.1%
associate-*l*91.4%
Simplified91.4%
Final simplification96.3%
(FPCore (x y z) :precision binary64 (if (or (<= (* y z) -1000000.0) (not (<= (* y z) 1.0))) (* x (* y (- z))) x))
double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -1000000.0) || !((y * z) <= 1.0)) {
tmp = x * (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 (((y * z) <= (-1000000.0d0)) .or. (.not. ((y * z) <= 1.0d0))) then
tmp = x * (y * -z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((y * z) <= -1000000.0) || !((y * z) <= 1.0)) {
tmp = x * (y * -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((y * z) <= -1000000.0) or not ((y * z) <= 1.0): tmp = x * (y * -z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(y * z) <= -1000000.0) || !(Float64(y * z) <= 1.0)) tmp = Float64(x * Float64(y * Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((y * z) <= -1000000.0) || ~(((y * z) <= 1.0))) tmp = x * (y * -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(y * z), $MachinePrecision], -1000000.0], N[Not[LessEqual[N[(y * z), $MachinePrecision], 1.0]], $MachinePrecision]], N[(x * N[(y * (-z)), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot z \leq -1000000 \lor \neg \left(y \cdot z \leq 1\right):\\
\;\;\;\;x \cdot \left(y \cdot \left(-z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if (*.f64 y z) < -1e6 or 1 < (*.f64 y z) Initial program 89.0%
Taylor expanded in y around inf 87.4%
mul-1-neg87.4%
associate-*r*92.6%
Simplified92.6%
Taylor expanded in x around 0 87.4%
if -1e6 < (*.f64 y z) < 1Initial program 100.0%
Taylor expanded in y around 0 97.3%
Final simplification92.6%
(FPCore (x y z) :precision binary64 (if (<= x 1500.0) (- x (* y (* x z))) (* x (- 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1500.0) {
tmp = x - (y * (x * z));
} else {
tmp = x * (1.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 (x <= 1500.0d0) then
tmp = x - (y * (x * z))
else
tmp = x * (1.0d0 - (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1500.0) {
tmp = x - (y * (x * z));
} else {
tmp = x * (1.0 - (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1500.0: tmp = x - (y * (x * z)) else: tmp = x * (1.0 - (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1500.0) tmp = Float64(x - Float64(y * Float64(x * z))); else tmp = Float64(x * Float64(1.0 - Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1500.0) tmp = x - (y * (x * z)); else tmp = x * (1.0 - (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1500.0], N[(x - N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1500:\\
\;\;\;\;x - y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - y \cdot z\right)\\
\end{array}
\end{array}
if x < 1500Initial program 93.3%
sub-neg93.3%
distribute-rgt-in93.3%
*-un-lft-identity93.3%
distribute-rgt-neg-in93.3%
Applied egg-rr93.3%
add-sqr-sqrt52.1%
sqrt-unprod68.1%
distribute-rgt-neg-out68.1%
distribute-rgt-neg-out68.1%
sqr-neg68.1%
sqrt-prod32.8%
add-sqr-sqrt52.0%
cancel-sign-sub52.0%
distribute-rgt-neg-out52.0%
associate-*l*46.9%
add-sqr-sqrt21.0%
sqrt-unprod57.5%
sqr-neg57.5%
sqrt-unprod45.6%
add-sqr-sqrt90.2%
Applied egg-rr90.2%
if 1500 < x Initial program 99.9%
Final simplification92.3%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+191) (/ (* x y) y) x))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+191) {
tmp = (x * y) / 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 (y <= (-8.2d+191)) then
tmp = (x * y) / y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+191) {
tmp = (x * y) / y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+191: tmp = (x * y) / y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+191) tmp = Float64(Float64(x * y) / y); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+191) tmp = (x * y) / y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+191], N[(N[(x * y), $MachinePrecision] / y), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+191}:\\
\;\;\;\;\frac{x \cdot y}{y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -8.1999999999999998e191Initial program 85.2%
sub-neg85.2%
distribute-rgt-in85.2%
*-un-lft-identity85.2%
distribute-rgt-neg-in85.2%
Applied egg-rr85.2%
Taylor expanded in y around inf 92.6%
associate-*r*92.6%
fma-define92.6%
neg-mul-192.6%
Simplified92.6%
Taylor expanded in z around 0 2.6%
associate-*r/20.7%
Applied egg-rr20.7%
if -8.1999999999999998e191 < y Initial program 95.8%
Taylor expanded in y around 0 57.8%
Final simplification54.0%
(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 94.7%
Taylor expanded in y around 0 52.5%
Final simplification52.5%
herbie shell --seed 2024083
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, I"
:precision binary64
(* x (- 1.0 (* y z))))