
(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 9 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 8.2e-101) (* x (+ 1.0 (* z (+ y -1.0)))) (fma (+ y -1.0) (* z x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.2e-101) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = fma((y + -1.0), (z * x), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 8.2e-101) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = fma(Float64(y + -1.0), Float64(z * x), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 8.2e-101], 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] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.2 \cdot 10^{-101}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y + -1, z \cdot x, x\right)\\
\end{array}
\end{array}
if z < 8.20000000000000052e-101Initial program 99.3%
if 8.20000000000000052e-101 < z Initial program 94.2%
distribute-rgt-out--94.2%
*-lft-identity94.2%
cancel-sign-sub-inv94.2%
+-commutative94.2%
distribute-lft-neg-in94.2%
associate-*l*99.9%
fma-def99.9%
neg-sub099.9%
associate--r-99.9%
metadata-eval99.9%
+-commutative99.9%
*-commutative99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
(if (<= y -1.85e+121)
t_1
(if (<= y -2.9e-110)
x
(if (<= y -2.5e-189)
t_0
(if (<= y -9e-250)
x
(if (<= y 1.55e-6) t_0 (if (<= y 7.8e+34) x t_1))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (y <= -1.85e+121) {
tmp = t_1;
} else if (y <= -2.9e-110) {
tmp = x;
} else if (y <= -2.5e-189) {
tmp = t_0;
} else if (y <= -9e-250) {
tmp = x;
} else if (y <= 1.55e-6) {
tmp = t_0;
} else if (y <= 7.8e+34) {
tmp = 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 = z * -x
t_1 = x * (z * y)
if (y <= (-1.85d+121)) then
tmp = t_1
else if (y <= (-2.9d-110)) then
tmp = x
else if (y <= (-2.5d-189)) then
tmp = t_0
else if (y <= (-9d-250)) then
tmp = x
else if (y <= 1.55d-6) then
tmp = t_0
else if (y <= 7.8d+34) then
tmp = x
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 = x * (z * y);
double tmp;
if (y <= -1.85e+121) {
tmp = t_1;
} else if (y <= -2.9e-110) {
tmp = x;
} else if (y <= -2.5e-189) {
tmp = t_0;
} else if (y <= -9e-250) {
tmp = x;
} else if (y <= 1.55e-6) {
tmp = t_0;
} else if (y <= 7.8e+34) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (z * y) tmp = 0 if y <= -1.85e+121: tmp = t_1 elif y <= -2.9e-110: tmp = x elif y <= -2.5e-189: tmp = t_0 elif y <= -9e-250: tmp = x elif y <= 1.55e-6: tmp = t_0 elif y <= 7.8e+34: tmp = x else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(z * y)) tmp = 0.0 if (y <= -1.85e+121) tmp = t_1; elseif (y <= -2.9e-110) tmp = x; elseif (y <= -2.5e-189) tmp = t_0; elseif (y <= -9e-250) tmp = x; elseif (y <= 1.55e-6) tmp = t_0; elseif (y <= 7.8e+34) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (z * y); tmp = 0.0; if (y <= -1.85e+121) tmp = t_1; elseif (y <= -2.9e-110) tmp = x; elseif (y <= -2.5e-189) tmp = t_0; elseif (y <= -9e-250) tmp = x; elseif (y <= 1.55e-6) tmp = t_0; elseif (y <= 7.8e+34) tmp = x; 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[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.85e+121], t$95$1, If[LessEqual[y, -2.9e-110], x, If[LessEqual[y, -2.5e-189], t$95$0, If[LessEqual[y, -9e-250], x, If[LessEqual[y, 1.55e-6], t$95$0, If[LessEqual[y, 7.8e+34], x, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{+121}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -9 \cdot 10^{-250}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -1.85000000000000006e121 or 7.80000000000000038e34 < y Initial program 93.8%
Taylor expanded in y around inf 79.6%
*-commutative79.6%
Simplified79.6%
if -1.85000000000000006e121 < y < -2.9000000000000002e-110 or -2.4999999999999999e-189 < y < -8.99999999999999987e-250 or 1.55e-6 < y < 7.80000000000000038e34Initial program 100.0%
Taylor expanded in z around 0 72.3%
if -2.9000000000000002e-110 < y < -2.4999999999999999e-189 or -8.99999999999999987e-250 < y < 1.55e-6Initial program 100.0%
Taylor expanded in y around 0 99.3%
sub-neg99.3%
+-commutative99.3%
distribute-rgt1-in99.3%
cancel-sign-sub-inv99.3%
Simplified99.3%
Taylor expanded in z around inf 66.7%
mul-1-neg66.7%
distribute-rgt-neg-out66.7%
Simplified66.7%
Final simplification73.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= y -8.2e+121)
(* x (* z y))
(if (<= y -6.5e-110)
x
(if (<= y -5.8e-191)
t_0
(if (<= y -1.15e-247)
x
(if (<= y 1.3e-7) t_0 (if (<= y 9.8e+33) x (* y (* z x))))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (y <= -8.2e+121) {
tmp = x * (z * y);
} else if (y <= -6.5e-110) {
tmp = x;
} else if (y <= -5.8e-191) {
tmp = t_0;
} else if (y <= -1.15e-247) {
tmp = x;
} else if (y <= 1.3e-7) {
tmp = t_0;
} else if (y <= 9.8e+33) {
tmp = x;
} 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) :: t_0
real(8) :: tmp
t_0 = z * -x
if (y <= (-8.2d+121)) then
tmp = x * (z * y)
else if (y <= (-6.5d-110)) then
tmp = x
else if (y <= (-5.8d-191)) then
tmp = t_0
else if (y <= (-1.15d-247)) then
tmp = x
else if (y <= 1.3d-7) then
tmp = t_0
else if (y <= 9.8d+33) then
tmp = x
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (y <= -8.2e+121) {
tmp = x * (z * y);
} else if (y <= -6.5e-110) {
tmp = x;
} else if (y <= -5.8e-191) {
tmp = t_0;
} else if (y <= -1.15e-247) {
tmp = x;
} else if (y <= 1.3e-7) {
tmp = t_0;
} else if (y <= 9.8e+33) {
tmp = x;
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if y <= -8.2e+121: tmp = x * (z * y) elif y <= -6.5e-110: tmp = x elif y <= -5.8e-191: tmp = t_0 elif y <= -1.15e-247: tmp = x elif y <= 1.3e-7: tmp = t_0 elif y <= 9.8e+33: tmp = x else: tmp = y * (z * x) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (y <= -8.2e+121) tmp = Float64(x * Float64(z * y)); elseif (y <= -6.5e-110) tmp = x; elseif (y <= -5.8e-191) tmp = t_0; elseif (y <= -1.15e-247) tmp = x; elseif (y <= 1.3e-7) tmp = t_0; elseif (y <= 9.8e+33) tmp = x; else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (y <= -8.2e+121) tmp = x * (z * y); elseif (y <= -6.5e-110) tmp = x; elseif (y <= -5.8e-191) tmp = t_0; elseif (y <= -1.15e-247) tmp = x; elseif (y <= 1.3e-7) tmp = t_0; elseif (y <= 9.8e+33) tmp = x; else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[y, -8.2e+121], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -6.5e-110], x, If[LessEqual[y, -5.8e-191], t$95$0, If[LessEqual[y, -1.15e-247], x, If[LessEqual[y, 1.3e-7], t$95$0, If[LessEqual[y, 9.8e+33], x, N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-191}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{-247}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-7}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -8.2e121Initial program 97.2%
Taylor expanded in y around inf 89.8%
*-commutative89.8%
Simplified89.8%
if -8.2e121 < y < -6.4999999999999996e-110 or -5.7999999999999999e-191 < y < -1.15e-247 or 1.29999999999999999e-7 < y < 9.80000000000000027e33Initial program 100.0%
Taylor expanded in z around 0 72.3%
if -6.4999999999999996e-110 < y < -5.7999999999999999e-191 or -1.15e-247 < y < 1.29999999999999999e-7Initial program 100.0%
Taylor expanded in y around 0 99.3%
sub-neg99.3%
+-commutative99.3%
distribute-rgt1-in99.3%
cancel-sign-sub-inv99.3%
Simplified99.3%
Taylor expanded in z around inf 66.7%
mul-1-neg66.7%
distribute-rgt-neg-out66.7%
Simplified66.7%
if 9.80000000000000027e33 < y Initial program 91.6%
Taylor expanded in y around inf 77.6%
Final simplification74.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= y -1.7e+121)
(* x (* z y))
(if (<= y -2.9e-110)
x
(if (<= y -2.8e-192)
t_0
(if (<= y -1.02e-250)
x
(if (<= y 1.8e-8) t_0 (if (<= y 8.8e+33) x (* z (* x y))))))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (y <= -1.7e+121) {
tmp = x * (z * y);
} else if (y <= -2.9e-110) {
tmp = x;
} else if (y <= -2.8e-192) {
tmp = t_0;
} else if (y <= -1.02e-250) {
tmp = x;
} else if (y <= 1.8e-8) {
tmp = t_0;
} else if (y <= 8.8e+33) {
tmp = x;
} 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 (y <= (-1.7d+121)) then
tmp = x * (z * y)
else if (y <= (-2.9d-110)) then
tmp = x
else if (y <= (-2.8d-192)) then
tmp = t_0
else if (y <= (-1.02d-250)) then
tmp = x
else if (y <= 1.8d-8) then
tmp = t_0
else if (y <= 8.8d+33) then
tmp = x
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 (y <= -1.7e+121) {
tmp = x * (z * y);
} else if (y <= -2.9e-110) {
tmp = x;
} else if (y <= -2.8e-192) {
tmp = t_0;
} else if (y <= -1.02e-250) {
tmp = x;
} else if (y <= 1.8e-8) {
tmp = t_0;
} else if (y <= 8.8e+33) {
tmp = x;
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if y <= -1.7e+121: tmp = x * (z * y) elif y <= -2.9e-110: tmp = x elif y <= -2.8e-192: tmp = t_0 elif y <= -1.02e-250: tmp = x elif y <= 1.8e-8: tmp = t_0 elif y <= 8.8e+33: tmp = x else: tmp = z * (x * y) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (y <= -1.7e+121) tmp = Float64(x * Float64(z * y)); elseif (y <= -2.9e-110) tmp = x; elseif (y <= -2.8e-192) tmp = t_0; elseif (y <= -1.02e-250) tmp = x; elseif (y <= 1.8e-8) tmp = t_0; elseif (y <= 8.8e+33) tmp = x; 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 (y <= -1.7e+121) tmp = x * (z * y); elseif (y <= -2.9e-110) tmp = x; elseif (y <= -2.8e-192) tmp = t_0; elseif (y <= -1.02e-250) tmp = x; elseif (y <= 1.8e-8) tmp = t_0; elseif (y <= 8.8e+33) tmp = x; else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[y, -1.7e+121], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.9e-110], x, If[LessEqual[y, -2.8e-192], t$95$0, If[LessEqual[y, -1.02e-250], x, If[LessEqual[y, 1.8e-8], t$95$0, If[LessEqual[y, 8.8e+33], x, N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq -2.9 \cdot 10^{-110}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-250}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8.8 \cdot 10^{+33}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -1.70000000000000005e121Initial program 97.2%
Taylor expanded in y around inf 89.8%
*-commutative89.8%
Simplified89.8%
if -1.70000000000000005e121 < y < -2.9000000000000002e-110 or -2.80000000000000004e-192 < y < -1.02000000000000001e-250 or 1.79999999999999991e-8 < y < 8.79999999999999975e33Initial program 100.0%
Taylor expanded in z around 0 72.3%
if -2.9000000000000002e-110 < y < -2.80000000000000004e-192 or -1.02000000000000001e-250 < y < 1.79999999999999991e-8Initial program 100.0%
Taylor expanded in y around 0 99.3%
sub-neg99.3%
+-commutative99.3%
distribute-rgt1-in99.3%
cancel-sign-sub-inv99.3%
Simplified99.3%
Taylor expanded in z around inf 66.7%
mul-1-neg66.7%
distribute-rgt-neg-out66.7%
Simplified66.7%
if 8.79999999999999975e33 < y Initial program 91.6%
Taylor expanded in y around inf 77.6%
associate-*r*72.6%
*-commutative72.6%
associate-*l*79.2%
Simplified79.2%
Final simplification74.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -380.0) (not (<= z 2.9e-16))) (* z (- (* x y) x)) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -380.0) || !(z <= 2.9e-16)) {
tmp = z * ((x * y) - x);
} else {
tmp = x + (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 ((z <= (-380.0d0)) .or. (.not. (z <= 2.9d-16))) then
tmp = z * ((x * y) - x)
else
tmp = x + (x * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -380.0) || !(z <= 2.9e-16)) {
tmp = z * ((x * y) - x);
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -380.0) or not (z <= 2.9e-16): tmp = z * ((x * y) - x) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -380.0) || !(z <= 2.9e-16)) tmp = Float64(z * Float64(Float64(x * y) - x)); else tmp = Float64(x + Float64(x * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -380.0) || ~((z <= 2.9e-16))) tmp = z * ((x * y) - x); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -380.0], N[Not[LessEqual[z, 2.9e-16]], $MachinePrecision]], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -380 \lor \neg \left(z \leq 2.9 \cdot 10^{-16}\right):\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -380 or 2.8999999999999998e-16 < z Initial program 95.7%
Taylor expanded in z around inf 98.9%
*-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-rgt-in98.9%
neg-mul-198.9%
unsub-neg98.9%
Simplified98.9%
if -380 < z < 2.8999999999999998e-16Initial program 99.8%
Taylor expanded in y around inf 99.3%
mul-1-neg99.3%
distribute-lft-neg-out99.3%
*-commutative99.3%
Simplified99.3%
*-commutative99.3%
cancel-sign-sub99.3%
*-commutative99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= z 5e+14) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (- (* x y) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5e+14) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * ((x * 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) :: tmp
if (z <= 5d+14) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = z * ((x * y) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 5e+14) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 5e+14: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * ((x * y) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 5e+14) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 5e+14) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * ((x * y) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 5e+14], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{+14}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if z < 5e14Initial program 99.4%
if 5e14 < z Initial program 92.2%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.6e+120) (* x (* z y)) (if (<= y 4.6e+34) (- x (* z x)) (* z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e+120) {
tmp = x * (z * y);
} else if (y <= 4.6e+34) {
tmp = x - (z * x);
} 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) :: tmp
if (y <= (-3.6d+120)) then
tmp = x * (z * y)
else if (y <= 4.6d+34) then
tmp = x - (z * x)
else
tmp = z * (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e+120) {
tmp = x * (z * y);
} else if (y <= 4.6e+34) {
tmp = x - (z * x);
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.6e+120: tmp = x * (z * y) elif y <= 4.6e+34: tmp = x - (z * x) else: tmp = z * (x * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.6e+120) tmp = Float64(x * Float64(z * y)); elseif (y <= 4.6e+34) tmp = Float64(x - Float64(z * x)); else tmp = Float64(z * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.6e+120) tmp = x * (z * y); elseif (y <= 4.6e+34) tmp = x - (z * x); else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.6e+120], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.6e+34], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+120}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+34}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -3.60000000000000016e120Initial program 97.2%
Taylor expanded in y around inf 89.8%
*-commutative89.8%
Simplified89.8%
if -3.60000000000000016e120 < y < 4.5999999999999996e34Initial program 100.0%
Taylor expanded in y around 0 95.2%
sub-neg95.2%
+-commutative95.2%
distribute-rgt1-in95.2%
cancel-sign-sub-inv95.2%
Simplified95.2%
if 4.5999999999999996e34 < y Initial program 91.6%
Taylor expanded in y around inf 77.6%
associate-*r*72.6%
*-commutative72.6%
associate-*l*79.2%
Simplified79.2%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.12e-26))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.12e-26)) {
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.12d-26))) 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.12e-26)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.12e-26): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.12e-26)) 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.12e-26))) 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.12e-26]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1.12 \cdot 10^{-26}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1.12e-26 < z Initial program 95.8%
Taylor expanded in y around 0 58.7%
sub-neg58.7%
+-commutative58.7%
distribute-rgt1-in58.7%
cancel-sign-sub-inv58.7%
Simplified58.7%
Taylor expanded in z around inf 57.8%
mul-1-neg57.8%
distribute-rgt-neg-out57.8%
Simplified57.8%
if -1 < z < 1.12e-26Initial program 99.8%
Taylor expanded in z around 0 76.3%
Final simplification66.6%
(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.7%
Taylor expanded in z around 0 37.8%
Final simplification37.8%
(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 2023252
(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))))