
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((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 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) 2e+56) (+ x (* x (* z (+ y -1.0)))) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+56) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * 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 (((1.0d0 - y) * z) <= 2d+56) then
tmp = x + (x * (z * (y + (-1.0d0))))
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+56) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= 2e+56: tmp = x + (x * (z * (y + -1.0))) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= 2e+56) tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= 2e+56) tmp = x + (x * (z * (y + -1.0))); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], 2e+56], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq 2 \cdot 10^{+56}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < 2.00000000000000018e56Initial program 99.4%
Taylor expanded in z around 0 99.4%
if 2.00000000000000018e56 < (*.f64 (-.f64 1 y) z) Initial program 89.2%
Taylor expanded in z around inf 89.2%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* y z))))
(if (<= z -8.2e+169)
t_0
(if (<= z -3.9e+74)
t_1
(if (<= z -4.5e-6)
t_0
(if (<= z -1.6e-60)
t_1
(if (<= z -1.3e-168)
x
(if (<= z -3.8e-181)
t_1
(if (<= z 1.15e-49) x (if (<= z 15.0) t_1 t_0))))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -8.2e+169) {
tmp = t_0;
} else if (z <= -3.9e+74) {
tmp = t_1;
} else if (z <= -4.5e-6) {
tmp = t_0;
} else if (z <= -1.6e-60) {
tmp = t_1;
} else if (z <= -1.3e-168) {
tmp = x;
} else if (z <= -3.8e-181) {
tmp = t_1;
} else if (z <= 1.15e-49) {
tmp = x;
} else if (z <= 15.0) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = x * (y * z)
if (z <= (-8.2d+169)) then
tmp = t_0
else if (z <= (-3.9d+74)) then
tmp = t_1
else if (z <= (-4.5d-6)) then
tmp = t_0
else if (z <= (-1.6d-60)) then
tmp = t_1
else if (z <= (-1.3d-168)) then
tmp = x
else if (z <= (-3.8d-181)) then
tmp = t_1
else if (z <= 1.15d-49) then
tmp = x
else if (z <= 15.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (y * z);
double tmp;
if (z <= -8.2e+169) {
tmp = t_0;
} else if (z <= -3.9e+74) {
tmp = t_1;
} else if (z <= -4.5e-6) {
tmp = t_0;
} else if (z <= -1.6e-60) {
tmp = t_1;
} else if (z <= -1.3e-168) {
tmp = x;
} else if (z <= -3.8e-181) {
tmp = t_1;
} else if (z <= 1.15e-49) {
tmp = x;
} else if (z <= 15.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (y * z) tmp = 0 if z <= -8.2e+169: tmp = t_0 elif z <= -3.9e+74: tmp = t_1 elif z <= -4.5e-6: tmp = t_0 elif z <= -1.6e-60: tmp = t_1 elif z <= -1.3e-168: tmp = x elif z <= -3.8e-181: tmp = t_1 elif z <= 1.15e-49: tmp = x elif z <= 15.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -8.2e+169) tmp = t_0; elseif (z <= -3.9e+74) tmp = t_1; elseif (z <= -4.5e-6) tmp = t_0; elseif (z <= -1.6e-60) tmp = t_1; elseif (z <= -1.3e-168) tmp = x; elseif (z <= -3.8e-181) tmp = t_1; elseif (z <= 1.15e-49) tmp = x; elseif (z <= 15.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (y * z); tmp = 0.0; if (z <= -8.2e+169) tmp = t_0; elseif (z <= -3.9e+74) tmp = t_1; elseif (z <= -4.5e-6) tmp = t_0; elseif (z <= -1.6e-60) tmp = t_1; elseif (z <= -1.3e-168) tmp = x; elseif (z <= -3.8e-181) tmp = t_1; elseif (z <= 1.15e-49) tmp = x; elseif (z <= 15.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.2e+169], t$95$0, If[LessEqual[z, -3.9e+74], t$95$1, If[LessEqual[z, -4.5e-6], t$95$0, If[LessEqual[z, -1.6e-60], t$95$1, If[LessEqual[z, -1.3e-168], x, If[LessEqual[z, -3.8e-181], t$95$1, If[LessEqual[z, 1.15e-49], x, If[LessEqual[z, 15.0], t$95$1, t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -8.2 \cdot 10^{+169}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.9 \cdot 10^{+74}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-60}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-168}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -3.8 \cdot 10^{-181}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-49}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 15:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -8.2000000000000006e169 or -3.90000000000000008e74 < z < -4.50000000000000011e-6 or 15 < z Initial program 94.6%
Taylor expanded in z around inf 89.8%
*-commutative89.8%
associate-*l*95.0%
sub-neg95.0%
metadata-eval95.0%
Simplified95.0%
Taylor expanded in y around 0 62.2%
neg-mul-162.2%
Simplified62.2%
if -8.2000000000000006e169 < z < -3.90000000000000008e74 or -4.50000000000000011e-6 < z < -1.6000000000000001e-60 or -1.3e-168 < z < -3.7999999999999998e-181 or 1.15e-49 < z < 15Initial program 96.1%
Taylor expanded in y around inf 69.5%
*-commutative69.5%
Simplified69.5%
if -1.6000000000000001e-60 < z < -1.3e-168 or -3.7999999999999998e-181 < z < 1.15e-49Initial program 100.0%
Taylor expanded in z around 0 86.5%
Final simplification72.9%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) 2e+56) (* x (+ 1.0 (* z (+ y -1.0)))) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+56) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * 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 (((1.0d0 - y) * z) <= 2d+56) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 2e+56) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= 2e+56: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= 2e+56) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= 2e+56) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], 2e+56], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq 2 \cdot 10^{+56}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < 2.00000000000000018e56Initial program 99.4%
if 2.00000000000000018e56 < (*.f64 (-.f64 1 y) z) Initial program 89.2%
Taylor expanded in z around inf 89.2%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.0004))) (* x (+ 1.0 (* y z))) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.0004)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x * (1.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 <= (-1.0d0)) .or. (.not. (y <= 0.0004d0))) then
tmp = x * (1.0d0 + (y * z))
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.0004)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 0.0004): tmp = x * (1.0 + (y * z)) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.0004)) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.0004))) tmp = x * (1.0 + (y * z)); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.0004]], $MachinePrecision]], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.0004\right):\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1 or 4.00000000000000019e-4 < y Initial program 93.9%
Taylor expanded in y around inf 92.9%
mul-1-neg92.9%
distribute-lft-neg-out92.9%
*-commutative92.9%
Simplified92.9%
*-commutative92.9%
cancel-sign-sub92.9%
*-commutative92.9%
distribute-rgt-in92.9%
*-un-lft-identity92.9%
associate-*l*90.8%
Applied egg-rr90.8%
*-un-lft-identity90.8%
associate-*r*92.9%
distribute-rgt-out92.9%
Applied egg-rr92.9%
if -1 < y < 4.00000000000000019e-4Initial program 100.0%
Taylor expanded in y around 0 99.3%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.98) (not (<= z 1.6e-16))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.98) || !(z <= 1.6e-16)) {
tmp = z * (x * (y + -1.0));
} 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 ((z <= (-0.98d0)) .or. (.not. (z <= 1.6d-16))) then
tmp = z * (x * (y + (-1.0d0)))
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 ((z <= -0.98) || !(z <= 1.6e-16)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.98) or not (z <= 1.6e-16): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.98) || !(z <= 1.6e-16)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); 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 ((z <= -0.98) || ~((z <= 1.6e-16))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.98], N[Not[LessEqual[z, 1.6e-16]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.98 \lor \neg \left(z \leq 1.6 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.97999999999999998 or 1.60000000000000011e-16 < z Initial program 94.0%
Taylor expanded in z around inf 91.9%
*-commutative91.9%
associate-*l*97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
if -0.97999999999999998 < z < 1.60000000000000011e-16Initial program 99.9%
Taylor expanded in y around inf 97.8%
mul-1-neg97.8%
distribute-lft-neg-out97.8%
*-commutative97.8%
Simplified97.8%
*-commutative97.8%
cancel-sign-sub97.8%
*-commutative97.8%
distribute-rgt-in97.8%
*-un-lft-identity97.8%
associate-*l*89.8%
Applied egg-rr89.8%
*-un-lft-identity89.8%
associate-*r*97.8%
distribute-rgt-out97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.05) (* (+ y -1.0) (* z x)) (if (<= z 1.6e-16) (* x (+ 1.0 (* y z))) (* z (* x (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = (y + -1.0) * (z * x);
} else if (z <= 1.6e-16) {
tmp = x * (1.0 + (y * z));
} else {
tmp = z * (x * (y + -1.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 <= (-1.05d0)) then
tmp = (y + (-1.0d0)) * (z * x)
else if (z <= 1.6d-16) then
tmp = x * (1.0d0 + (y * z))
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = (y + -1.0) * (z * x);
} else if (z <= 1.6e-16) {
tmp = x * (1.0 + (y * z));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05: tmp = (y + -1.0) * (z * x) elif z <= 1.6e-16: tmp = x * (1.0 + (y * z)) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05) tmp = Float64(Float64(y + -1.0) * Float64(z * x)); elseif (z <= 1.6e-16) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.05) tmp = (y + -1.0) * (z * x); elseif (z <= 1.6e-16) tmp = x * (1.0 + (y * z)); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.6e-16], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;z \leq 1.6 \cdot 10^{-16}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004Initial program 93.8%
Taylor expanded in z around inf 90.8%
associate-*r*96.9%
*-commutative96.9%
sub-neg96.9%
metadata-eval96.9%
Simplified96.9%
if -1.05000000000000004 < z < 1.60000000000000011e-16Initial program 99.9%
Taylor expanded in y around inf 97.8%
mul-1-neg97.8%
distribute-lft-neg-out97.8%
*-commutative97.8%
Simplified97.8%
*-commutative97.8%
cancel-sign-sub97.8%
*-commutative97.8%
distribute-rgt-in97.8%
*-un-lft-identity97.8%
associate-*l*89.8%
Applied egg-rr89.8%
*-un-lft-identity89.8%
associate-*r*97.8%
distribute-rgt-out97.8%
Applied egg-rr97.8%
if 1.60000000000000011e-16 < z Initial program 94.2%
Taylor expanded in z around inf 92.9%
*-commutative92.9%
associate-*l*98.7%
sub-neg98.7%
metadata-eval98.7%
Simplified98.7%
Final simplification97.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+34) (not (<= y 5e+155))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+34) || !(y <= 5e+155)) {
tmp = x * (y * z);
} else {
tmp = x * (1.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 <= (-5.5d+34)) .or. (.not. (y <= 5d+155))) then
tmp = x * (y * z)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+34) || !(y <= 5e+155)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+34) or not (y <= 5e+155): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+34) || !(y <= 5e+155)) tmp = Float64(x * Float64(y * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.5e+34) || ~((y <= 5e+155))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+34], N[Not[LessEqual[y, 5e+155]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+34} \lor \neg \left(y \leq 5 \cdot 10^{+155}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -5.4999999999999996e34 or 4.9999999999999999e155 < y Initial program 92.4%
Taylor expanded in y around inf 79.6%
*-commutative79.6%
Simplified79.6%
if -5.4999999999999996e34 < y < 4.9999999999999999e155Initial program 99.4%
Taylor expanded in y around 0 91.4%
Final simplification87.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -9e+35) (not (<= y 5e+155))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+35) || !(y <= 5e+155)) {
tmp = z * (y * x);
} else {
tmp = x * (1.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 <= (-9d+35)) .or. (.not. (y <= 5d+155))) then
tmp = z * (y * x)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+35) || !(y <= 5e+155)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9e+35) or not (y <= 5e+155): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9e+35) || !(y <= 5e+155)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9e+35) || ~((y <= 5e+155))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9e+35], N[Not[LessEqual[y, 5e+155]], $MachinePrecision]], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+35} \lor \neg \left(y \leq 5 \cdot 10^{+155}\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -8.9999999999999993e35 or 4.9999999999999999e155 < y Initial program 92.4%
Taylor expanded in z around inf 79.6%
*-commutative79.6%
associate-*l*80.9%
sub-neg80.9%
metadata-eval80.9%
Simplified80.9%
Taylor expanded in y around inf 80.9%
if -8.9999999999999993e35 < y < 4.9999999999999999e155Initial program 99.4%
Taylor expanded in y around 0 91.4%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (<= y -2.4e+32) (* z (* y x)) (if (<= y 5e+155) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+32) {
tmp = z * (y * x);
} else if (y <= 5e+155) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * 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 <= (-2.4d+32)) then
tmp = z * (y * x)
else if (y <= 5d+155) then
tmp = x * (1.0d0 - z)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+32) {
tmp = z * (y * x);
} else if (y <= 5e+155) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.4e+32: tmp = z * (y * x) elif y <= 5e+155: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.4e+32) tmp = Float64(z * Float64(y * x)); elseif (y <= 5e+155) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.4e+32) tmp = z * (y * x); elseif (y <= 5e+155) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+32], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e+155], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+32}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+155}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -2.39999999999999991e32Initial program 94.8%
Taylor expanded in z around inf 78.4%
*-commutative78.4%
associate-*l*80.3%
sub-neg80.3%
metadata-eval80.3%
Simplified80.3%
Taylor expanded in y around inf 80.3%
if -2.39999999999999991e32 < y < 4.9999999999999999e155Initial program 99.4%
Taylor expanded in y around 0 91.4%
if 4.9999999999999999e155 < y Initial program 88.1%
Taylor expanded in y around inf 81.8%
*-commutative81.8%
Simplified81.8%
add-sqr-sqrt34.3%
pow234.3%
*-commutative34.3%
associate-*l*31.6%
Applied egg-rr31.6%
unpow231.6%
add-sqr-sqrt82.0%
*-commutative82.0%
associate-*r*86.5%
Applied egg-rr86.5%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.6e-16))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.6e-16)) {
tmp = z * -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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.6d-16))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.6e-16)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.6e-16): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.6e-16)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.6e-16))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.6e-16]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1.6 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1.60000000000000011e-16 < z Initial program 94.0%
Taylor expanded in z around inf 91.9%
*-commutative91.9%
associate-*l*97.8%
sub-neg97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in y around 0 57.5%
neg-mul-157.5%
Simplified57.5%
if -1 < z < 1.60000000000000011e-16Initial program 99.9%
Taylor expanded in z around 0 73.6%
Final simplification65.5%
(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.0%
Taylor expanded in z around 0 38.6%
Final simplification38.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} 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 * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023275
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))