
(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) 500000000.0) (* x (+ 1.0 (* z (+ y -1.0)))) (+ x (* y (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= 500000000.0) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = x + (y * (x * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((1.0d0 - y) <= 500000000.0d0) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = x + (y * (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((1.0 - y) <= 500000000.0) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = x + (y * (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (1.0 - y) <= 500000000.0: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = x + (y * (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(1.0 - y) <= 500000000.0) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(x + Float64(y * Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((1.0 - y) <= 500000000.0) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = x + (y * (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(1.0 - y), $MachinePrecision], 500000000.0], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;1 - y \leq 500000000:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if (-.f64 1 y) < 5e8Initial program 99.0%
if 5e8 < (-.f64 1 y) Initial program 84.0%
flip--65.1%
associate-*l/63.5%
metadata-eval63.5%
Applied egg-rr63.5%
Taylor expanded in y around inf 84.0%
associate-*r*84.0%
neg-mul-184.0%
Simplified84.0%
Taylor expanded in y around 0 98.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (fma (+ y -1.0) (* x z) x))
double code(double x, double y, double z) {
return fma((y + -1.0), (x * z), x);
}
function code(x, y, z) return fma(Float64(y + -1.0), Float64(x * z), x) end
code[x_, y_, z_] := N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y + -1, x \cdot z, x\right)
\end{array}
Initial program 95.5%
distribute-rgt-out--95.5%
*-lft-identity95.5%
cancel-sign-sub-inv95.5%
+-commutative95.5%
distribute-lft-neg-in95.5%
associate-*l*98.3%
fma-def98.3%
neg-sub098.3%
associate--r-98.3%
metadata-eval98.3%
+-commutative98.3%
*-commutative98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z)
:precision binary64
(if (<= y -2.7e+69)
(* y (* x z))
(if (<= y -9.2e+49)
x
(if (<= y -105000000.0)
(* x (* y z))
(if (<= y 1.35e+79) (- x (* x z)) (* z (* y x)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+69) {
tmp = y * (x * z);
} else if (y <= -9.2e+49) {
tmp = x;
} else if (y <= -105000000.0) {
tmp = x * (y * z);
} else if (y <= 1.35e+79) {
tmp = x - (x * z);
} else {
tmp = z * (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 (y <= (-2.7d+69)) then
tmp = y * (x * z)
else if (y <= (-9.2d+49)) then
tmp = x
else if (y <= (-105000000.0d0)) then
tmp = x * (y * z)
else if (y <= 1.35d+79) then
tmp = x - (x * z)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+69) {
tmp = y * (x * z);
} else if (y <= -9.2e+49) {
tmp = x;
} else if (y <= -105000000.0) {
tmp = x * (y * z);
} else if (y <= 1.35e+79) {
tmp = x - (x * z);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+69: tmp = y * (x * z) elif y <= -9.2e+49: tmp = x elif y <= -105000000.0: tmp = x * (y * z) elif y <= 1.35e+79: tmp = x - (x * z) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+69) tmp = Float64(y * Float64(x * z)); elseif (y <= -9.2e+49) tmp = x; elseif (y <= -105000000.0) tmp = Float64(x * Float64(y * z)); elseif (y <= 1.35e+79) tmp = Float64(x - Float64(x * z)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+69) tmp = y * (x * z); elseif (y <= -9.2e+49) tmp = x; elseif (y <= -105000000.0) tmp = x * (y * z); elseif (y <= 1.35e+79) tmp = x - (x * z); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+69], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -9.2e+49], x, If[LessEqual[y, -105000000.0], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+79], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+69}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq -9.2 \cdot 10^{+49}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -105000000:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+79}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -2.6999999999999998e69Initial program 77.8%
Taylor expanded in y around inf 85.8%
if -2.6999999999999998e69 < y < -9.20000000000000008e49Initial program 100.0%
Taylor expanded in z around 0 100.0%
if -9.20000000000000008e49 < y < -1.05e8Initial program 99.6%
Taylor expanded in y around inf 76.5%
*-commutative76.5%
Simplified76.5%
if -1.05e8 < y < 1.35e79Initial program 100.0%
Taylor expanded in y around 0 94.1%
sub-neg94.1%
+-commutative94.1%
distribute-rgt1-in94.1%
cancel-sign-sub-inv94.1%
Simplified94.1%
if 1.35e79 < y Initial program 95.4%
Taylor expanded in y around inf 71.3%
associate-*r*73.5%
*-commutative73.5%
associate-*l*75.7%
Simplified75.7%
Final simplification89.0%
(FPCore (x y z)
:precision binary64
(if (<= y -3.5e+69)
(* y (* x z))
(if (<= y -5.8e+48)
x
(if (<= y -4000000.0)
(* x (* z (+ y -1.0)))
(if (<= y 1.45e+79) (- x (* x z)) (* z (* y x)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+69) {
tmp = y * (x * z);
} else if (y <= -5.8e+48) {
tmp = x;
} else if (y <= -4000000.0) {
tmp = x * (z * (y + -1.0));
} else if (y <= 1.45e+79) {
tmp = x - (x * z);
} else {
tmp = z * (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 (y <= (-3.5d+69)) then
tmp = y * (x * z)
else if (y <= (-5.8d+48)) then
tmp = x
else if (y <= (-4000000.0d0)) then
tmp = x * (z * (y + (-1.0d0)))
else if (y <= 1.45d+79) then
tmp = x - (x * z)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+69) {
tmp = y * (x * z);
} else if (y <= -5.8e+48) {
tmp = x;
} else if (y <= -4000000.0) {
tmp = x * (z * (y + -1.0));
} else if (y <= 1.45e+79) {
tmp = x - (x * z);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+69: tmp = y * (x * z) elif y <= -5.8e+48: tmp = x elif y <= -4000000.0: tmp = x * (z * (y + -1.0)) elif y <= 1.45e+79: tmp = x - (x * z) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+69) tmp = Float64(y * Float64(x * z)); elseif (y <= -5.8e+48) tmp = x; elseif (y <= -4000000.0) tmp = Float64(x * Float64(z * Float64(y + -1.0))); elseif (y <= 1.45e+79) tmp = Float64(x - Float64(x * z)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.5e+69) tmp = y * (x * z); elseif (y <= -5.8e+48) tmp = x; elseif (y <= -4000000.0) tmp = x * (z * (y + -1.0)); elseif (y <= 1.45e+79) tmp = x - (x * z); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+69], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.8e+48], x, If[LessEqual[y, -4000000.0], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.45e+79], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+69}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -4000000:\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+79}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -3.49999999999999987e69Initial program 77.8%
Taylor expanded in y around inf 85.8%
if -3.49999999999999987e69 < y < -5.7999999999999998e48Initial program 100.0%
Taylor expanded in z around 0 100.0%
if -5.7999999999999998e48 < y < -4e6Initial program 99.6%
Taylor expanded in z around inf 79.9%
if -4e6 < y < 1.44999999999999996e79Initial program 100.0%
Taylor expanded in y around 0 94.1%
sub-neg94.1%
+-commutative94.1%
distribute-rgt1-in94.1%
cancel-sign-sub-inv94.1%
Simplified94.1%
if 1.44999999999999996e79 < y Initial program 95.4%
Taylor expanded in y around inf 71.3%
associate-*r*73.5%
*-commutative73.5%
associate-*l*75.7%
Simplified75.7%
Final simplification89.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x z))))
(if (<= z -1.0)
t_0
(if (<= z 4.2e-21) x (if (<= z 2.25e+213) (* x (* y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = -(x * z);
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 4.2e-21) {
tmp = x;
} else if (z <= 2.25e+213) {
tmp = x * (y * z);
} 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 = -(x * z)
if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 4.2d-21) then
tmp = x
else if (z <= 2.25d+213) then
tmp = x * (y * z)
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 tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 4.2e-21) {
tmp = x;
} else if (z <= 2.25e+213) {
tmp = x * (y * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(x * z) tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 4.2e-21: tmp = x elif z <= 2.25e+213: tmp = x * (y * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(x * z)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 4.2e-21) tmp = x; elseif (z <= 2.25e+213) tmp = Float64(x * Float64(y * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(x * z); tmp = 0.0; if (z <= -1.0) tmp = t_0; elseif (z <= 4.2e-21) tmp = x; elseif (z <= 2.25e+213) tmp = x * (y * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * z), $MachinePrecision])}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 4.2e-21], x, If[LessEqual[z, 2.25e+213], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -x \cdot z\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-21}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.25 \cdot 10^{+213}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1 or 2.2500000000000001e213 < z Initial program 90.1%
Taylor expanded in z around inf 87.9%
Taylor expanded in y around 0 63.2%
mul-1-neg63.2%
distribute-rgt-neg-in63.2%
Simplified63.2%
if -1 < z < 4.20000000000000025e-21Initial program 99.9%
Taylor expanded in z around 0 80.3%
if 4.20000000000000025e-21 < z < 2.2500000000000001e213Initial program 93.2%
Taylor expanded in y around inf 64.1%
*-commutative64.1%
Simplified64.1%
Final simplification71.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x z))))
(if (<= z -1.0)
t_0
(if (<= z 2.9e-21) x (if (<= z 4.2e+217) (* y (* x z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = -(x * z);
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 2.9e-21) {
tmp = x;
} else if (z <= 4.2e+217) {
tmp = y * (x * z);
} 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 = -(x * z)
if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 2.9d-21) then
tmp = x
else if (z <= 4.2d+217) then
tmp = y * (x * z)
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 tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 2.9e-21) {
tmp = x;
} else if (z <= 4.2e+217) {
tmp = y * (x * z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -(x * z) tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 2.9e-21: tmp = x elif z <= 4.2e+217: tmp = y * (x * z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-Float64(x * z)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 2.9e-21) tmp = x; elseif (z <= 4.2e+217) tmp = Float64(y * Float64(x * z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(x * z); tmp = 0.0; if (z <= -1.0) tmp = t_0; elseif (z <= 2.9e-21) tmp = x; elseif (z <= 4.2e+217) tmp = y * (x * z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * z), $MachinePrecision])}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 2.9e-21], x, If[LessEqual[z, 4.2e+217], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -x \cdot z\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-21}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{+217}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1 or 4.2000000000000002e217 < z Initial program 90.1%
Taylor expanded in z around inf 87.9%
Taylor expanded in y around 0 63.2%
mul-1-neg63.2%
distribute-rgt-neg-in63.2%
Simplified63.2%
if -1 < z < 2.9e-21Initial program 99.9%
Taylor expanded in z around 0 80.3%
if 2.9e-21 < z < 4.2000000000000002e217Initial program 93.2%
Taylor expanded in y around inf 72.9%
Final simplification73.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 5.2e-29))) (+ x (* y (* x z))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 5.2e-29)) {
tmp = x + (y * (x * z));
} 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 <= (-1.0d0)) .or. (.not. (y <= 5.2d-29))) then
tmp = x + (y * (x * z))
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 <= -1.0) || !(y <= 5.2e-29)) {
tmp = x + (y * (x * z));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 5.2e-29): tmp = x + (y * (x * z)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 5.2e-29)) tmp = Float64(x + Float64(y * Float64(x * z))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 5.2e-29))) tmp = x + (y * (x * z)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 5.2e-29]], $MachinePrecision]], N[(x + N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 5.2 \cdot 10^{-29}\right):\\
\;\;\;\;x + y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -1 or 5.2000000000000004e-29 < y Initial program 91.1%
flip--67.4%
associate-*l/63.0%
metadata-eval63.0%
Applied egg-rr63.0%
Taylor expanded in y around inf 90.4%
associate-*r*90.4%
neg-mul-190.4%
Simplified90.4%
Taylor expanded in y around 0 96.0%
if -1 < y < 5.2000000000000004e-29Initial program 100.0%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt1-in100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
Final simplification98.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (+ x (* y (* x z))) (if (<= y 5.2e-29) (- x (* x z)) (+ x (* z (* y x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = x + (y * (x * z));
} else if (y <= 5.2e-29) {
tmp = x - (x * z);
} else {
tmp = x + (z * (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 (y <= (-1.0d0)) then
tmp = x + (y * (x * z))
else if (y <= 5.2d-29) then
tmp = x - (x * z)
else
tmp = x + (z * (y * x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = x + (y * (x * z));
} else if (y <= 5.2e-29) {
tmp = x - (x * z);
} else {
tmp = x + (z * (y * x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = x + (y * (x * z)) elif y <= 5.2e-29: tmp = x - (x * z) else: tmp = x + (z * (y * x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(x + Float64(y * Float64(x * z))); elseif (y <= 5.2e-29) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x + Float64(z * Float64(y * x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = x + (y * (x * z)); elseif (y <= 5.2e-29) tmp = x - (x * z); else tmp = x + (z * (y * x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(x + N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.2e-29], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x + y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-29}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -1Initial program 84.3%
flip--65.6%
associate-*l/64.0%
metadata-eval64.0%
Applied egg-rr64.0%
Taylor expanded in y around inf 83.6%
associate-*r*83.6%
neg-mul-183.6%
Simplified83.6%
Taylor expanded in y around 0 97.8%
if -1 < y < 5.2000000000000004e-29Initial program 100.0%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt1-in100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
if 5.2000000000000004e-29 < y Initial program 97.1%
distribute-rgt-out--97.2%
*-lft-identity97.2%
cancel-sign-sub-inv97.2%
+-commutative97.2%
distribute-lft-neg-in97.2%
associate-*l*95.1%
fma-def95.1%
neg-sub095.1%
associate--r-95.1%
metadata-eval95.1%
+-commutative95.1%
*-commutative95.1%
Simplified95.1%
fma-udef95.1%
associate-*r*95.7%
Applied egg-rr95.7%
Taylor expanded in y around inf 95.0%
Final simplification98.1%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (+ x (* y (* x z))) (if (<= y 5.2e-29) (- x (* x z)) (* x (+ 1.0 (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = x + (y * (x * z));
} else if (y <= 5.2e-29) {
tmp = x - (x * z);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.0d0)) then
tmp = x + (y * (x * z))
else if (y <= 5.2d-29) then
tmp = x - (x * z)
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = x + (y * (x * z));
} else if (y <= 5.2e-29) {
tmp = x - (x * z);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = x + (y * (x * z)) elif y <= 5.2e-29: tmp = x - (x * z) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(x + Float64(y * Float64(x * z))); elseif (y <= 5.2e-29) tmp = Float64(x - Float64(x * z)); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = x + (y * (x * z)); elseif (y <= 5.2e-29) tmp = x - (x * z); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(x + N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.2e-29], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x + y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-29}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if y < -1Initial program 84.3%
flip--65.6%
associate-*l/64.0%
metadata-eval64.0%
Applied egg-rr64.0%
Taylor expanded in y around inf 83.6%
associate-*r*83.6%
neg-mul-183.6%
Simplified83.6%
Taylor expanded in y around 0 97.8%
if -1 < y < 5.2000000000000004e-29Initial program 100.0%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
+-commutative100.0%
distribute-rgt1-in100.0%
cancel-sign-sub-inv100.0%
Simplified100.0%
if 5.2000000000000004e-29 < y Initial program 97.1%
Taylor expanded in y around inf 96.5%
mul-1-neg96.5%
distribute-lft-neg-out96.5%
*-commutative96.5%
Simplified96.5%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.42e-12))) (- (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.42e-12)) {
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 <= 1.42d-12))) 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 <= 1.42e-12)) {
tmp = -(x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.42e-12): tmp = -(x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.42e-12)) tmp = Float64(-Float64(x * z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.42e-12))) 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, 1.42e-12]], $MachinePrecision]], (-N[(x * z), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1.42 \cdot 10^{-12}\right):\\
\;\;\;\;-x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1.42e-12 < z Initial program 91.0%
Taylor expanded in z around inf 89.0%
Taylor expanded in y around 0 53.5%
mul-1-neg53.5%
distribute-rgt-neg-in53.5%
Simplified53.5%
if -1 < z < 1.42e-12Initial program 99.9%
Taylor expanded in z around 0 79.6%
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 95.5%
Taylor expanded in z around 0 41.5%
Final simplification41.5%
(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 2023257
(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))))