
(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 10 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 (<= z 1.5e+103) (* x (+ 1.0 (* z (+ y -1.0)))) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.5e+103) {
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 (z <= 1.5d+103) 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 (z <= 1.5e+103) {
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 z <= 1.5e+103: 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 (z <= 1.5e+103) 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 (z <= 1.5e+103) 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[z, 1.5e+103], 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}\;z \leq 1.5 \cdot 10^{+103}:\\
\;\;\;\;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 z < 1.5e103Initial program 98.6%
if 1.5e103 < z Initial program 87.0%
Taylor expanded in z around inf 87.0%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* y (* z x))))
(if (<= z -2.95e+184)
t_0
(if (<= z -2.4e+97)
t_1
(if (<= z -1.65e+38)
t_0
(if (<= z -2.4e-30)
(* x (* z y))
(if (<= z 2900000.0)
x
(if (or (<= z 7e+143) (not (<= z 9e+200))) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = y * (z * x);
double tmp;
if (z <= -2.95e+184) {
tmp = t_0;
} else if (z <= -2.4e+97) {
tmp = t_1;
} else if (z <= -1.65e+38) {
tmp = t_0;
} else if (z <= -2.4e-30) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
tmp = x;
} else if ((z <= 7e+143) || !(z <= 9e+200)) {
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 = z * -x
t_1 = y * (z * x)
if (z <= (-2.95d+184)) then
tmp = t_0
else if (z <= (-2.4d+97)) then
tmp = t_1
else if (z <= (-1.65d+38)) then
tmp = t_0
else if (z <= (-2.4d-30)) then
tmp = x * (z * y)
else if (z <= 2900000.0d0) then
tmp = x
else if ((z <= 7d+143) .or. (.not. (z <= 9d+200))) 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 = z * -x;
double t_1 = y * (z * x);
double tmp;
if (z <= -2.95e+184) {
tmp = t_0;
} else if (z <= -2.4e+97) {
tmp = t_1;
} else if (z <= -1.65e+38) {
tmp = t_0;
} else if (z <= -2.4e-30) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
tmp = x;
} else if ((z <= 7e+143) || !(z <= 9e+200)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = y * (z * x) tmp = 0 if z <= -2.95e+184: tmp = t_0 elif z <= -2.4e+97: tmp = t_1 elif z <= -1.65e+38: tmp = t_0 elif z <= -2.4e-30: tmp = x * (z * y) elif z <= 2900000.0: tmp = x elif (z <= 7e+143) or not (z <= 9e+200): tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(y * Float64(z * x)) tmp = 0.0 if (z <= -2.95e+184) tmp = t_0; elseif (z <= -2.4e+97) tmp = t_1; elseif (z <= -1.65e+38) tmp = t_0; elseif (z <= -2.4e-30) tmp = Float64(x * Float64(z * y)); elseif (z <= 2900000.0) tmp = x; elseif ((z <= 7e+143) || !(z <= 9e+200)) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = y * (z * x); tmp = 0.0; if (z <= -2.95e+184) tmp = t_0; elseif (z <= -2.4e+97) tmp = t_1; elseif (z <= -1.65e+38) tmp = t_0; elseif (z <= -2.4e-30) tmp = x * (z * y); elseif (z <= 2900000.0) tmp = x; elseif ((z <= 7e+143) || ~((z <= 9e+200))) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.95e+184], t$95$0, If[LessEqual[z, -2.4e+97], t$95$1, If[LessEqual[z, -1.65e+38], t$95$0, If[LessEqual[z, -2.4e-30], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2900000.0], x, If[Or[LessEqual[z, 7e+143], N[Not[LessEqual[z, 9e+200]], $MachinePrecision]], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;z \leq -2.95 \cdot 10^{+184}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{+97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.65 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{-30}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq 2900000:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7 \cdot 10^{+143} \lor \neg \left(z \leq 9 \cdot 10^{+200}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -2.9500000000000001e184 or -2.4e97 < z < -1.65e38 or 2.9e6 < z < 7.00000000000000017e143 or 8.99999999999999939e200 < z Initial program 95.5%
Taylor expanded in z around inf 94.0%
Taylor expanded in y around 0 75.2%
mul-1-neg75.2%
distribute-rgt-neg-in75.2%
Simplified75.2%
if -2.9500000000000001e184 < z < -2.4e97 or 7.00000000000000017e143 < z < 8.99999999999999939e200Initial program 82.3%
add-cube-cbrt81.8%
pow381.9%
Applied egg-rr81.9%
Taylor expanded in y around inf 57.6%
*-commutative57.9%
Simplified57.6%
rem-cube-cbrt57.9%
*-commutative57.9%
associate-*r*75.3%
*-commutative75.3%
associate-*r*82.4%
Applied egg-rr82.4%
if -1.65e38 < z < -2.39999999999999985e-30Initial program 99.5%
Taylor expanded in y around inf 89.9%
*-commutative89.9%
Simplified89.9%
if -2.39999999999999985e-30 < z < 2.9e6Initial program 100.0%
Taylor expanded in z around 0 78.6%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -7.8e+38)
t_0
(if (<= z -3.4e-15)
(* x (* z y))
(if (<= z 2900000.0)
x
(if (or (<= z 8.8e+157) (not (<= z 9e+200))) t_0 (* z (* x y))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -7.8e+38) {
tmp = t_0;
} else if (z <= -3.4e-15) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
tmp = x;
} else if ((z <= 8.8e+157) || !(z <= 9e+200)) {
tmp = t_0;
} else {
tmp = z * (x * y);
}
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 = z * -x
if (z <= (-7.8d+38)) then
tmp = t_0
else if (z <= (-3.4d-15)) then
tmp = x * (z * y)
else if (z <= 2900000.0d0) then
tmp = x
else if ((z <= 8.8d+157) .or. (.not. (z <= 9d+200))) then
tmp = t_0
else
tmp = z * (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -7.8e+38) {
tmp = t_0;
} else if (z <= -3.4e-15) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
tmp = x;
} else if ((z <= 8.8e+157) || !(z <= 9e+200)) {
tmp = t_0;
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -7.8e+38: tmp = t_0 elif z <= -3.4e-15: tmp = x * (z * y) elif z <= 2900000.0: tmp = x elif (z <= 8.8e+157) or not (z <= 9e+200): tmp = t_0 else: tmp = z * (x * y) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -7.8e+38) tmp = t_0; elseif (z <= -3.4e-15) tmp = Float64(x * Float64(z * y)); elseif (z <= 2900000.0) tmp = x; elseif ((z <= 8.8e+157) || !(z <= 9e+200)) tmp = t_0; else tmp = Float64(z * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -7.8e+38) tmp = t_0; elseif (z <= -3.4e-15) tmp = x * (z * y); elseif (z <= 2900000.0) tmp = x; elseif ((z <= 8.8e+157) || ~((z <= 9e+200))) tmp = t_0; else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -7.8e+38], t$95$0, If[LessEqual[z, -3.4e-15], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2900000.0], x, If[Or[LessEqual[z, 8.8e+157], N[Not[LessEqual[z, 9e+200]], $MachinePrecision]], t$95$0, N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -7.8 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.4 \cdot 10^{-15}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq 2900000:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+157} \lor \neg \left(z \leq 9 \cdot 10^{+200}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if z < -7.80000000000000047e38 or 2.9e6 < z < 8.8000000000000005e157 or 8.99999999999999939e200 < z Initial program 94.5%
Taylor expanded in z around inf 93.2%
Taylor expanded in y around 0 70.1%
mul-1-neg70.1%
distribute-rgt-neg-in70.1%
Simplified70.1%
if -7.80000000000000047e38 < z < -3.4e-15Initial program 99.5%
Taylor expanded in y around inf 89.9%
*-commutative89.9%
Simplified89.9%
if -3.4e-15 < z < 2.9e6Initial program 100.0%
Taylor expanded in z around 0 78.6%
if 8.8000000000000005e157 < z < 8.99999999999999939e200Initial program 68.3%
Taylor expanded in z around inf 68.3%
*-commutative68.3%
associate-*l*99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
Final simplification76.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.2e+29) (not (<= y 2.85e-5))) (* x (+ 1.0 (* z y))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.2e+29) || !(y <= 2.85e-5)) {
tmp = x * (1.0 + (z * y));
} else {
tmp = x - (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.2d+29)) .or. (.not. (y <= 2.85d-5))) then
tmp = x * (1.0d0 + (z * y))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.2e+29) || !(y <= 2.85e-5)) {
tmp = x * (1.0 + (z * y));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.2e+29) or not (y <= 2.85e-5): tmp = x * (1.0 + (z * y)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.2e+29) || !(y <= 2.85e-5)) tmp = Float64(x * Float64(1.0 + Float64(z * y))); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.2e+29) || ~((y <= 2.85e-5))) tmp = x * (1.0 + (z * y)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.2e+29], N[Not[LessEqual[y, 2.85e-5]], $MachinePrecision]], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+29} \lor \neg \left(y \leq 2.85 \cdot 10^{-5}\right):\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -2.2000000000000001e29 or 2.8500000000000002e-5 < y Initial program 93.0%
*-commutative93.0%
flip--69.5%
associate-*r/66.0%
metadata-eval66.0%
Applied egg-rr66.0%
associate-*l/66.9%
Simplified66.9%
Taylor expanded in y around inf 66.6%
Taylor expanded in y around inf 92.7%
*-commutative92.7%
Simplified92.7%
if -2.2000000000000001e29 < y < 2.8500000000000002e-5Initial program 99.3%
Taylor expanded in y around 0 98.2%
sub-neg98.2%
distribute-rgt-in98.2%
*-lft-identity98.2%
distribute-lft-neg-out98.2%
*-commutative98.2%
unsub-neg98.2%
Simplified98.2%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
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.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x * (1.0d0 + (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x * Float64(1.0 + Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 92.9%
Taylor expanded in z around inf 91.4%
*-commutative91.4%
associate-*l*98.3%
sub-neg98.3%
metadata-eval98.3%
Simplified98.3%
if -1 < z < 1Initial program 99.9%
*-commutative99.9%
flip--81.5%
associate-*r/81.5%
metadata-eval81.5%
Applied egg-rr81.5%
associate-*l/79.4%
Simplified79.4%
Taylor expanded in y around inf 48.0%
Taylor expanded in y around inf 98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.05) (* z (* x (+ y -1.0))) (if (<= z 1.0) (* x (+ 1.0 (* z y))) (* (+ y -1.0) (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.05) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x * (1.0 + (z * y));
} 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 (z <= (-1.05d0)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (z * y))
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 (z <= -1.05) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.0) {
tmp = x * (1.0 + (z * y));
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.05: tmp = z * (x * (y + -1.0)) elif z <= 1.0: tmp = x * (1.0 + (z * y)) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.05) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(z * y))); 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 (z <= -1.05) tmp = z * (x * (y + -1.0)); elseif (z <= 1.0) tmp = x * (1.0 + (z * y)); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.05], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if z < -1.05000000000000004Initial program 94.8%
Taylor expanded in z around inf 93.9%
*-commutative93.9%
associate-*l*99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
if -1.05000000000000004 < z < 1Initial program 99.9%
*-commutative99.9%
flip--81.5%
associate-*r/81.5%
metadata-eval81.5%
Applied egg-rr81.5%
associate-*l/79.4%
Simplified79.4%
Taylor expanded in y around inf 48.0%
Taylor expanded in y around inf 98.8%
*-commutative98.8%
Simplified98.8%
if 1 < z Initial program 91.3%
Taylor expanded in z around inf 89.4%
associate-*r*97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
Final simplification98.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -1.6e+38)
t_0
(if (<= z -8e-24) (* x (* z y)) (if (<= z 2900000.0) x t_0)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.6e+38) {
tmp = t_0;
} else if (z <= -8e-24) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
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 = z * -x
if (z <= (-1.6d+38)) then
tmp = t_0
else if (z <= (-8d-24)) then
tmp = x * (z * y)
else if (z <= 2900000.0d0) 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 = z * -x;
double tmp;
if (z <= -1.6e+38) {
tmp = t_0;
} else if (z <= -8e-24) {
tmp = x * (z * y);
} else if (z <= 2900000.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -1.6e+38: tmp = t_0 elif z <= -8e-24: tmp = x * (z * y) elif z <= 2900000.0: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -1.6e+38) tmp = t_0; elseif (z <= -8e-24) tmp = Float64(x * Float64(z * y)); elseif (z <= 2900000.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -1.6e+38) tmp = t_0; elseif (z <= -8e-24) tmp = x * (z * y); elseif (z <= 2900000.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -1.6e+38], t$95$0, If[LessEqual[z, -8e-24], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2900000.0], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-24}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;z \leq 2900000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.59999999999999993e38 or 2.9e6 < z Initial program 92.4%
Taylor expanded in z around inf 91.2%
Taylor expanded in y around 0 66.4%
mul-1-neg66.4%
distribute-rgt-neg-in66.4%
Simplified66.4%
if -1.59999999999999993e38 < z < -7.99999999999999939e-24Initial program 99.5%
Taylor expanded in y around inf 89.9%
*-commutative89.9%
Simplified89.9%
if -7.99999999999999939e-24 < z < 2.9e6Initial program 100.0%
Taylor expanded in z around 0 78.6%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (<= y -6e+28) (* y (* z x)) (if (<= y 5.6e+50) (- x (* z x)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+28) {
tmp = y * (z * x);
} else if (y <= 5.6e+50) {
tmp = x - (z * x);
} else {
tmp = x * (z * y);
}
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 <= (-6d+28)) then
tmp = y * (z * x)
else if (y <= 5.6d+50) then
tmp = x - (z * x)
else
tmp = x * (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6e+28) {
tmp = y * (z * x);
} else if (y <= 5.6e+50) {
tmp = x - (z * x);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e+28: tmp = y * (z * x) elif y <= 5.6e+50: tmp = x - (z * x) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e+28) tmp = Float64(y * Float64(z * x)); elseif (y <= 5.6e+50) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e+28) tmp = y * (z * x); elseif (y <= 5.6e+50) tmp = x - (z * x); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e+28], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.6e+50], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+28}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+50}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -6.0000000000000002e28Initial program 89.0%
add-cube-cbrt87.7%
pow387.7%
Applied egg-rr87.7%
Taylor expanded in y around inf 63.2%
*-commutative63.8%
Simplified63.2%
rem-cube-cbrt63.8%
*-commutative63.8%
associate-*r*68.5%
*-commutative68.5%
associate-*r*69.2%
Applied egg-rr69.2%
if -6.0000000000000002e28 < y < 5.5999999999999996e50Initial program 100.0%
Taylor expanded in y around 0 97.0%
sub-neg97.0%
distribute-rgt-in97.0%
*-lft-identity97.0%
distribute-lft-neg-out97.0%
*-commutative97.0%
unsub-neg97.0%
Simplified97.0%
if 5.5999999999999996e50 < y Initial program 95.0%
Taylor expanded in y around inf 75.8%
*-commutative75.8%
Simplified75.8%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.4e-11) (not (<= z 2900000.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.4e-11) || !(z <= 2900000.0)) {
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 <= (-3.4d-11)) .or. (.not. (z <= 2900000.0d0))) 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 <= -3.4e-11) || !(z <= 2900000.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.4e-11) or not (z <= 2900000.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.4e-11) || !(z <= 2900000.0)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.4e-11) || ~((z <= 2900000.0))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.4e-11], N[Not[LessEqual[z, 2900000.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-11} \lor \neg \left(z \leq 2900000\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3.3999999999999999e-11 or 2.9e6 < z Initial program 92.9%
Taylor expanded in z around inf 91.4%
Taylor expanded in y around 0 62.1%
mul-1-neg62.1%
distribute-rgt-neg-in62.1%
Simplified62.1%
if -3.3999999999999999e-11 < z < 2.9e6Initial program 100.0%
Taylor expanded in z around 0 78.1%
Final simplification70.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 96.6%
Taylor expanded in z around 0 42.6%
Final simplification42.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 2023271
(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))))