
(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 12 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 (let* ((t_0 (* z (- 1.0 y)))) (if (<= (- 1.0 t_0) 1e+307) (- x (* x t_0)) (+ x (* (* x z) y)))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if ((1.0 - t_0) <= 1e+307) {
tmp = x - (x * t_0);
} 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) :: t_0
real(8) :: tmp
t_0 = z * (1.0d0 - y)
if ((1.0d0 - t_0) <= 1d+307) then
tmp = x - (x * t_0)
else
tmp = x + ((x * z) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if ((1.0 - t_0) <= 1e+307) {
tmp = x - (x * t_0);
} else {
tmp = x + ((x * z) * y);
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if (1.0 - t_0) <= 1e+307: tmp = x - (x * t_0) else: tmp = x + ((x * z) * y) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if (Float64(1.0 - t_0) <= 1e+307) tmp = Float64(x - Float64(x * t_0)); else tmp = Float64(x + Float64(Float64(x * z) * y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if ((1.0 - t_0) <= 1e+307) tmp = x - (x * t_0); else tmp = x + ((x * z) * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 - t$95$0), $MachinePrecision], 1e+307], N[(x - N[(x * t$95$0), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;1 - t\_0 \leq 10^{+307}:\\
\;\;\;\;x - x \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 9.99999999999999986e306Initial program 98.4%
Taylor expanded in z around 0 98.4%
if 9.99999999999999986e306 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 62.0%
Taylor expanded in z around 0 62.0%
Taylor expanded in y around 0 55.4%
*-commutative55.4%
associate-*r*93.3%
*-commutative93.3%
distribute-rgt-in100.0%
Simplified100.0%
Taylor expanded in y around inf 62.0%
*-commutative62.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* z y))))
(if (<= z -2700000000000.0)
t_0
(if (<= z -8.2e-94)
t_1
(if (<= z 4.6e-113) x (if (<= z 1.08e+27) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (z * y);
double tmp;
if (z <= -2700000000000.0) {
tmp = t_0;
} else if (z <= -8.2e-94) {
tmp = t_1;
} else if (z <= 4.6e-113) {
tmp = x;
} else if (z <= 1.08e+27) {
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 = x * -z
t_1 = x * (z * y)
if (z <= (-2700000000000.0d0)) then
tmp = t_0
else if (z <= (-8.2d-94)) then
tmp = t_1
else if (z <= 4.6d-113) then
tmp = x
else if (z <= 1.08d+27) 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 = x * -z;
double t_1 = x * (z * y);
double tmp;
if (z <= -2700000000000.0) {
tmp = t_0;
} else if (z <= -8.2e-94) {
tmp = t_1;
} else if (z <= 4.6e-113) {
tmp = x;
} else if (z <= 1.08e+27) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (z * y) tmp = 0 if z <= -2700000000000.0: tmp = t_0 elif z <= -8.2e-94: tmp = t_1 elif z <= 4.6e-113: tmp = x elif z <= 1.08e+27: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(x * Float64(z * y)) tmp = 0.0 if (z <= -2700000000000.0) tmp = t_0; elseif (z <= -8.2e-94) tmp = t_1; elseif (z <= 4.6e-113) tmp = x; elseif (z <= 1.08e+27) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = x * (z * y); tmp = 0.0; if (z <= -2700000000000.0) tmp = t_0; elseif (z <= -8.2e-94) tmp = t_1; elseif (z <= 4.6e-113) tmp = x; elseif (z <= 1.08e+27) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2700000000000.0], t$95$0, If[LessEqual[z, -8.2e-94], t$95$1, If[LessEqual[z, 4.6e-113], x, If[LessEqual[z, 1.08e+27], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -2700000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -8.2 \cdot 10^{-94}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-113}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.08 \cdot 10^{+27}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.7e12 or 1.08e27 < z Initial program 92.0%
Taylor expanded in z around inf 92.0%
*-commutative92.0%
associate-*r*99.8%
*-commutative99.8%
sub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 65.5%
neg-mul-165.5%
Simplified65.5%
if -2.7e12 < z < -8.20000000000000001e-94 or 4.60000000000000016e-113 < z < 1.08e27Initial program 99.8%
Taylor expanded in y around inf 57.6%
*-commutative57.6%
Simplified57.6%
if -8.20000000000000001e-94 < z < 4.60000000000000016e-113Initial program 99.9%
Taylor expanded in z around 0 83.8%
Final simplification70.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 1.0 (* z (- 1.0 y))))) (if (<= t_0 1e+307) (* x t_0) (+ x (* (* x z) y)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (z * (1.0 - y));
double tmp;
if (t_0 <= 1e+307) {
tmp = x * t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (z * (1.0d0 - y))
if (t_0 <= 1d+307) then
tmp = x * t_0
else
tmp = x + ((x * z) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (z * (1.0 - y));
double tmp;
if (t_0 <= 1e+307) {
tmp = x * t_0;
} else {
tmp = x + ((x * z) * y);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (z * (1.0 - y)) tmp = 0 if t_0 <= 1e+307: tmp = x * t_0 else: tmp = x + ((x * z) * y) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(z * Float64(1.0 - y))) tmp = 0.0 if (t_0 <= 1e+307) tmp = Float64(x * t_0); else tmp = Float64(x + Float64(Float64(x * z) * y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (z * (1.0 - y)); tmp = 0.0; if (t_0 <= 1e+307) tmp = x * t_0; else tmp = x + ((x * z) * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+307], N[(x * t$95$0), $MachinePrecision], N[(x + N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - z \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq 10^{+307}:\\
\;\;\;\;x \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) < 9.99999999999999986e306Initial program 98.4%
if 9.99999999999999986e306 < (-.f64 #s(literal 1 binary64) (*.f64 (-.f64 #s(literal 1 binary64) y) z)) Initial program 62.0%
Taylor expanded in z around 0 62.0%
Taylor expanded in y around 0 55.4%
*-commutative55.4%
associate-*r*93.3%
*-commutative93.3%
distribute-rgt-in100.0%
Simplified100.0%
Taylor expanded in y around inf 62.0%
*-commutative62.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -13.2) (not (<= z 1.0))) (* z (* x (+ -1.0 y))) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -13.2) || !(z <= 1.0)) {
tmp = z * (x * (-1.0 + y));
} 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 <= (-13.2d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * ((-1.0d0) + y))
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 <= -13.2) || !(z <= 1.0)) {
tmp = z * (x * (-1.0 + y));
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -13.2) or not (z <= 1.0): tmp = z * (x * (-1.0 + y)) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -13.2) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(-1.0 + y))); 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 <= -13.2) || ~((z <= 1.0))) tmp = z * (x * (-1.0 + y)); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -13.2], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -13.2 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -13.199999999999999 or 1 < z Initial program 92.7%
Taylor expanded in z around inf 90.7%
*-commutative90.7%
associate-*r*97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
Simplified97.9%
if -13.199999999999999 < z < 1Initial program 99.9%
Taylor expanded in y around inf 98.9%
mul-1-neg98.9%
distribute-lft-neg-out98.9%
*-commutative98.9%
Simplified98.9%
sub-neg98.9%
distribute-rgt-neg-out98.9%
remove-double-neg98.9%
distribute-rgt-in98.9%
*-un-lft-identity98.9%
Applied egg-rr98.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e-7) (not (<= y 1.0))) (+ x (* (* x z) y)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-7) || !(y <= 1.0)) {
tmp = x + ((x * z) * y);
} else {
tmp = x - (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 <= (-3.4d-7)) .or. (.not. (y <= 1.0d0))) then
tmp = x + ((x * z) * y)
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-7) || !(y <= 1.0)) {
tmp = x + ((x * z) * y);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e-7) or not (y <= 1.0): tmp = x + ((x * z) * y) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e-7) || !(y <= 1.0)) tmp = Float64(x + Float64(Float64(x * z) * y)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e-7) || ~((y <= 1.0))) tmp = x + ((x * z) * y); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e-7], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x + N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-7} \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + \left(x \cdot z\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -3.39999999999999974e-7 or 1 < y Initial program 92.8%
Taylor expanded in z around 0 92.8%
Taylor expanded in y around 0 89.1%
*-commutative89.1%
associate-*r*91.4%
*-commutative91.4%
distribute-rgt-in95.1%
Simplified95.1%
Taylor expanded in y around inf 92.4%
*-commutative92.4%
associate-*r*94.7%
*-commutative94.7%
Simplified94.7%
if -3.39999999999999974e-7 < y < 1Initial program 100.0%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.3e+72) (not (<= y 3.8e+69))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.3e+72) || !(y <= 3.8e+69)) {
tmp = x * (z * y);
} 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 <= (-3.3d+72)) .or. (.not. (y <= 3.8d+69))) then
tmp = x * (z * y)
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 <= -3.3e+72) || !(y <= 3.8e+69)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.3e+72) or not (y <= 3.8e+69): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.3e+72) || !(y <= 3.8e+69)) tmp = Float64(x * Float64(z * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.3e+72) || ~((y <= 3.8e+69))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.3e+72], N[Not[LessEqual[y, 3.8e+69]], $MachinePrecision]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+72} \lor \neg \left(y \leq 3.8 \cdot 10^{+69}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.3e72 or 3.80000000000000028e69 < y Initial program 90.0%
Taylor expanded in y around inf 77.0%
*-commutative77.0%
Simplified77.0%
if -3.3e72 < y < 3.80000000000000028e69Initial program 99.9%
Taylor expanded in y around 0 94.0%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (<= y -7e+71) (* z (* x y)) (if (<= y 1e+69) (- x (* x z)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7e+71) {
tmp = z * (x * y);
} else if (y <= 1e+69) {
tmp = x - (x * z);
} 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 <= (-7d+71)) then
tmp = z * (x * y)
else if (y <= 1d+69) then
tmp = x - (x * z)
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 <= -7e+71) {
tmp = z * (x * y);
} else if (y <= 1e+69) {
tmp = x - (x * z);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e+71: tmp = z * (x * y) elif y <= 1e+69: tmp = x - (x * z) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e+71) tmp = Float64(z * Float64(x * y)); elseif (y <= 1e+69) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7e+71) tmp = z * (x * y); elseif (y <= 1e+69) tmp = x - (x * z); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e+71], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+69], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{+71}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 10^{+69}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -6.9999999999999998e71Initial program 87.2%
Taylor expanded in z around inf 76.5%
*-commutative76.5%
associate-*r*81.8%
*-commutative81.8%
sub-neg81.8%
metadata-eval81.8%
Simplified81.8%
Taylor expanded in y around inf 81.8%
if -6.9999999999999998e71 < y < 1.0000000000000001e69Initial program 99.9%
Taylor expanded in y around 0 94.0%
sub-neg94.0%
distribute-rgt-in94.0%
*-un-lft-identity94.0%
Applied egg-rr94.0%
if 1.0000000000000001e69 < y Initial program 93.3%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
Simplified77.7%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e+71) (* z (* x y)) (if (<= y 2.1e+70) (- x (* x z)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+71) {
tmp = z * (x * y);
} else if (y <= 2.1e+70) {
tmp = x - (x * z);
} 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 <= (-4.2d+71)) then
tmp = z * (x * y)
else if (y <= 2.1d+70) then
tmp = x - (x * z)
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 <= -4.2e+71) {
tmp = z * (x * y);
} else if (y <= 2.1e+70) {
tmp = x - (x * z);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+71: tmp = z * (x * y) elif y <= 2.1e+70: tmp = x - (x * z) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+71) tmp = Float64(z * Float64(x * y)); elseif (y <= 2.1e+70) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e+71) tmp = z * (x * y); elseif (y <= 2.1e+70) tmp = x - (x * z); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+71], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.1e+70], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+71}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+70}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -4.19999999999999978e71Initial program 87.2%
Taylor expanded in z around inf 76.5%
*-commutative76.5%
associate-*r*81.8%
*-commutative81.8%
sub-neg81.8%
metadata-eval81.8%
Simplified81.8%
Taylor expanded in y around inf 81.8%
if -4.19999999999999978e71 < y < 2.10000000000000008e70Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 96.8%
*-commutative96.8%
associate-*r*95.0%
*-commutative95.0%
distribute-rgt-in100.0%
Simplified100.0%
Taylor expanded in y around 0 94.0%
neg-mul-194.0%
sub-neg94.0%
Simplified94.0%
if 2.10000000000000008e70 < y Initial program 93.3%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
Simplified77.7%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+71) (* z (* x y)) (if (<= y 3.1e+68) (* x (- 1.0 z)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+71) {
tmp = z * (x * y);
} else if (y <= 3.1e+68) {
tmp = x * (1.0 - z);
} 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 <= (-5.5d+71)) then
tmp = z * (x * y)
else if (y <= 3.1d+68) then
tmp = x * (1.0d0 - z)
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 <= -5.5e+71) {
tmp = z * (x * y);
} else if (y <= 3.1e+68) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+71: tmp = z * (x * y) elif y <= 3.1e+68: tmp = x * (1.0 - z) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+71) tmp = Float64(z * Float64(x * y)); elseif (y <= 3.1e+68) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e+71) tmp = z * (x * y); elseif (y <= 3.1e+68) tmp = x * (1.0 - z); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+71], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+68], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+71}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+68}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -5.5e71Initial program 87.2%
Taylor expanded in z around inf 76.5%
*-commutative76.5%
associate-*r*81.8%
*-commutative81.8%
sub-neg81.8%
metadata-eval81.8%
Simplified81.8%
Taylor expanded in y around inf 81.8%
if -5.5e71 < y < 3.0999999999999998e68Initial program 99.9%
Taylor expanded in y around 0 94.0%
if 3.0999999999999998e68 < y Initial program 93.3%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
Simplified77.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.0078))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0078)) {
tmp = x * -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 ((z <= (-1.0d0)) .or. (.not. (z <= 0.0078d0))) then
tmp = x * -z
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 <= 0.0078)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.0078): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.0078)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 0.0078))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 0.0078]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0078\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 0.0077999999999999996 < z Initial program 92.8%
Taylor expanded in z around inf 90.9%
*-commutative90.9%
associate-*r*98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
Simplified98.0%
Taylor expanded in y around 0 61.7%
neg-mul-161.7%
Simplified61.7%
if -1 < z < 0.0077999999999999996Initial program 99.9%
Taylor expanded in z around 0 71.0%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (+ x (* (* x z) (+ -1.0 y))))
double code(double x, double y, double z) {
return x + ((x * z) * (-1.0 + y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((x * z) * ((-1.0d0) + y))
end function
public static double code(double x, double y, double z) {
return x + ((x * z) * (-1.0 + y));
}
def code(x, y, z): return x + ((x * z) * (-1.0 + y))
function code(x, y, z) return Float64(x + Float64(Float64(x * z) * Float64(-1.0 + y))) end
function tmp = code(x, y, z) tmp = x + ((x * z) * (-1.0 + y)); end
code[x_, y_, z_] := N[(x + N[(N[(x * z), $MachinePrecision] * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(x \cdot z\right) \cdot \left(-1 + y\right)
\end{array}
Initial program 96.2%
Taylor expanded in z around 0 96.2%
Taylor expanded in y around 0 92.7%
*-commutative92.7%
associate-*r*92.8%
*-commutative92.8%
distribute-rgt-in97.5%
Simplified97.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.2%
Taylor expanded in z around 0 36.4%
(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 2024103
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(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))))