
(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 13 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 (<= (* x (- 1.0 (* (- 1.0 y) z))) 2e+51) (+ x (* z (- (* x y) x))) (fma (+ y -1.0) (* x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((x * (1.0 - ((1.0 - y) * z))) <= 2e+51) {
tmp = x + (z * ((x * y) - x));
} else {
tmp = fma((y + -1.0), (x * z), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) <= 2e+51) tmp = Float64(x + Float64(z * Float64(Float64(x * y) - x))); else tmp = fma(Float64(y + -1.0), Float64(x * z), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+51], N[(x + N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right) \leq 2 \cdot 10^{+51}:\\
\;\;\;\;x + z \cdot \left(x \cdot y - x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y + -1, x \cdot z, x\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 2e51Initial program 97.2%
sub-neg97.2%
+-commutative97.2%
distribute-rgt-neg-in97.2%
sub-neg97.2%
+-commutative97.2%
distribute-rgt1-in97.2%
distribute-rgt-neg-in97.2%
associate-+l+97.2%
associate-+l+97.2%
distribute-rgt-neg-in97.2%
distribute-rgt1-in97.2%
+-commutative97.2%
sub-neg97.2%
distribute-rgt-neg-in97.2%
*-commutative97.2%
distribute-rgt-neg-in97.2%
fma-def97.2%
Simplified97.2%
fma-udef97.2%
distribute-lft-in97.2%
*-commutative97.2%
*-un-lft-identity97.2%
Applied egg-rr97.2%
Taylor expanded in x around 0 99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
distribute-lft-in99.4%
*-commutative99.4%
neg-mul-199.4%
unsub-neg99.4%
*-commutative99.4%
Simplified99.4%
if 2e51 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) 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.6%
(FPCore (x y z) :precision binary64 (if (<= z 5e-45) (* x (fma z (+ y -1.0) 1.0)) (+ x (* z (- (* x y) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5e-45) {
tmp = x * fma(z, (y + -1.0), 1.0);
} else {
tmp = x + (z * ((x * y) - x));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 5e-45) tmp = Float64(x * fma(z, Float64(y + -1.0), 1.0)); else tmp = Float64(x + Float64(z * Float64(Float64(x * y) - x))); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 5e-45], N[(x * N[(z * N[(y + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{-45}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(z, y + -1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if z < 4.99999999999999976e-45Initial program 97.9%
sub-neg97.9%
+-commutative97.9%
distribute-rgt-neg-in97.9%
sub-neg97.9%
+-commutative97.9%
distribute-rgt1-in97.9%
distribute-rgt-neg-in97.9%
associate-+l+97.9%
associate-+l+97.9%
distribute-rgt-neg-in97.9%
distribute-rgt1-in97.9%
+-commutative97.9%
sub-neg97.9%
distribute-rgt-neg-in97.9%
*-commutative97.9%
distribute-rgt-neg-in97.9%
fma-def97.9%
Simplified97.9%
if 4.99999999999999976e-45 < z Initial program 91.6%
sub-neg91.6%
+-commutative91.6%
distribute-rgt-neg-in91.6%
sub-neg91.6%
+-commutative91.6%
distribute-rgt1-in91.6%
distribute-rgt-neg-in91.6%
associate-+l+91.6%
associate-+l+91.6%
distribute-rgt-neg-in91.6%
distribute-rgt1-in91.6%
+-commutative91.6%
sub-neg91.6%
distribute-rgt-neg-in91.6%
*-commutative91.6%
distribute-rgt-neg-in91.6%
fma-def91.6%
Simplified91.6%
fma-udef91.6%
distribute-lft-in91.6%
*-commutative91.6%
*-un-lft-identity91.6%
Applied egg-rr91.6%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
*-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
neg-mul-199.9%
unsub-neg99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x z))) (t_1 (* x (* y z))))
(if (<= z -1.15e+43)
t_0
(if (<= z -3.9e-76)
t_1
(if (<= z 1.0)
x
(if (or (<= z 2.2e+54) (not (<= z 5.8e+149))) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = -(x * z);
double t_1 = x * (y * z);
double tmp;
if (z <= -1.15e+43) {
tmp = t_0;
} else if (z <= -3.9e-76) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 2.2e+54) || !(z <= 5.8e+149)) {
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 = -(x * z)
t_1 = x * (y * z)
if (z <= (-1.15d+43)) then
tmp = t_0
else if (z <= (-3.9d-76)) then
tmp = t_1
else if (z <= 1.0d0) then
tmp = x
else if ((z <= 2.2d+54) .or. (.not. (z <= 5.8d+149))) 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 = -(x * z);
double t_1 = x * (y * z);
double tmp;
if (z <= -1.15e+43) {
tmp = t_0;
} else if (z <= -3.9e-76) {
tmp = t_1;
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 2.2e+54) || !(z <= 5.8e+149)) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = -(x * z) t_1 = x * (y * z) tmp = 0 if z <= -1.15e+43: tmp = t_0 elif z <= -3.9e-76: tmp = t_1 elif z <= 1.0: tmp = x elif (z <= 2.2e+54) or not (z <= 5.8e+149): tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(-Float64(x * z)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -1.15e+43) tmp = t_0; elseif (z <= -3.9e-76) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 2.2e+54) || !(z <= 5.8e+149)) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(x * z); t_1 = x * (y * z); tmp = 0.0; if (z <= -1.15e+43) tmp = t_0; elseif (z <= -3.9e-76) tmp = t_1; elseif (z <= 1.0) tmp = x; elseif ((z <= 2.2e+54) || ~((z <= 5.8e+149))) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * z), $MachinePrecision])}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e+43], t$95$0, If[LessEqual[z, -3.9e-76], t$95$1, If[LessEqual[z, 1.0], x, If[Or[LessEqual[z, 2.2e+54], N[Not[LessEqual[z, 5.8e+149]], $MachinePrecision]], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -x \cdot z\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.9 \cdot 10^{-76}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+54} \lor \neg \left(z \leq 5.8 \cdot 10^{+149}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -1.1500000000000001e43 or 1 < z < 2.1999999999999999e54 or 5.8000000000000004e149 < z Initial program 94.7%
Taylor expanded in z around inf 98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
associate-*l*98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in y around 0 68.1%
neg-mul-168.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
if -1.1500000000000001e43 < z < -3.90000000000000025e-76 or 2.1999999999999999e54 < z < 5.8000000000000004e149Initial program 90.2%
Taylor expanded in y around inf 62.3%
*-commutative62.3%
Simplified62.3%
if -3.90000000000000025e-76 < z < 1Initial program 99.9%
Taylor expanded in z around 0 80.1%
Final simplification72.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x z))))
(if (<= z -6.8e+42)
t_0
(if (<= z -3.2e-76)
(* x (* y z))
(if (<= z 1.0)
x
(if (or (<= z 1.4e+50) (not (<= z 1.8e+166))) t_0 (* y (* x z))))))))
double code(double x, double y, double z) {
double t_0 = -(x * z);
double tmp;
if (z <= -6.8e+42) {
tmp = t_0;
} else if (z <= -3.2e-76) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 1.4e+50) || !(z <= 1.8e+166)) {
tmp = t_0;
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = -(x * z)
if (z <= (-6.8d+42)) then
tmp = t_0
else if (z <= (-3.2d-76)) then
tmp = x * (y * z)
else if (z <= 1.0d0) then
tmp = x
else if ((z <= 1.4d+50) .or. (.not. (z <= 1.8d+166))) then
tmp = t_0
else
tmp = y * (x * z)
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 <= -6.8e+42) {
tmp = t_0;
} else if (z <= -3.2e-76) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} else if ((z <= 1.4e+50) || !(z <= 1.8e+166)) {
tmp = t_0;
} else {
tmp = y * (x * z);
}
return tmp;
}
def code(x, y, z): t_0 = -(x * z) tmp = 0 if z <= -6.8e+42: tmp = t_0 elif z <= -3.2e-76: tmp = x * (y * z) elif z <= 1.0: tmp = x elif (z <= 1.4e+50) or not (z <= 1.8e+166): tmp = t_0 else: tmp = y * (x * z) return tmp
function code(x, y, z) t_0 = Float64(-Float64(x * z)) tmp = 0.0 if (z <= -6.8e+42) tmp = t_0; elseif (z <= -3.2e-76) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.0) tmp = x; elseif ((z <= 1.4e+50) || !(z <= 1.8e+166)) tmp = t_0; else tmp = Float64(y * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = -(x * z); tmp = 0.0; if (z <= -6.8e+42) tmp = t_0; elseif (z <= -3.2e-76) tmp = x * (y * z); elseif (z <= 1.0) tmp = x; elseif ((z <= 1.4e+50) || ~((z <= 1.8e+166))) tmp = t_0; else tmp = y * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = (-N[(x * z), $MachinePrecision])}, If[LessEqual[z, -6.8e+42], t$95$0, If[LessEqual[z, -3.2e-76], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], x, If[Or[LessEqual[z, 1.4e+50], N[Not[LessEqual[z, 1.8e+166]], $MachinePrecision]], t$95$0, N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -x \cdot z\\
\mathbf{if}\;z \leq -6.8 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.2 \cdot 10^{-76}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+50} \lor \neg \left(z \leq 1.8 \cdot 10^{+166}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -6.7999999999999995e42 or 1 < z < 1.3999999999999999e50 or 1.7999999999999999e166 < z Initial program 94.5%
Taylor expanded in z around inf 98.0%
*-commutative98.0%
sub-neg98.0%
metadata-eval98.0%
associate-*l*98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in y around 0 68.1%
neg-mul-168.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
if -6.7999999999999995e42 < z < -3.1999999999999998e-76Initial program 99.8%
Taylor expanded in y around inf 63.3%
*-commutative63.3%
Simplified63.3%
if -3.1999999999999998e-76 < z < 1Initial program 99.9%
Taylor expanded in z around 0 80.1%
if 1.3999999999999999e50 < z < 1.7999999999999999e166Initial program 81.1%
Taylor expanded in y around inf 84.5%
Final simplification74.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -960000000000.0) (not (<= y 1.35e-30))) (* x (+ 1.0 (* y z))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -960000000000.0) || !(y <= 1.35e-30)) {
tmp = x * (1.0 + (y * 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 <= (-960000000000.0d0)) .or. (.not. (y <= 1.35d-30))) then
tmp = x * (1.0d0 + (y * 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 <= -960000000000.0) || !(y <= 1.35e-30)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -960000000000.0) or not (y <= 1.35e-30): tmp = x * (1.0 + (y * z)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -960000000000.0) || !(y <= 1.35e-30)) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -960000000000.0) || ~((y <= 1.35e-30))) tmp = x * (1.0 + (y * z)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -960000000000.0], N[Not[LessEqual[y, 1.35e-30]], $MachinePrecision]], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -960000000000 \lor \neg \left(y \leq 1.35 \cdot 10^{-30}\right):\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -9.6e11 or 1.34999999999999994e-30 < y Initial program 92.8%
Taylor expanded in y around inf 91.8%
mul-1-neg91.8%
distribute-lft-neg-out91.8%
*-commutative91.8%
Simplified91.8%
sub-neg91.8%
distribute-rgt-neg-out91.8%
remove-double-neg91.8%
+-commutative91.8%
Applied egg-rr91.8%
if -9.6e11 < y < 1.34999999999999994e-30Initial program 99.9%
Taylor expanded in y around 0 99.1%
sub-neg99.1%
+-commutative99.1%
distribute-rgt1-in99.2%
cancel-sign-sub-inv99.2%
Simplified99.2%
Final simplification95.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.2e+29) (not (<= z 1.0))) (* (+ y -1.0) (* x z)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.2e+29) || !(z <= 1.0)) {
tmp = (y + -1.0) * (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 ((z <= (-4.2d+29)) .or. (.not. (z <= 1.0d0))) then
tmp = (y + (-1.0d0)) * (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 ((z <= -4.2e+29) || !(z <= 1.0)) {
tmp = (y + -1.0) * (x * z);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.2e+29) or not (z <= 1.0): tmp = (y + -1.0) * (x * z) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.2e+29) || !(z <= 1.0)) tmp = Float64(Float64(y + -1.0) * 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 ((z <= -4.2e+29) || ~((z <= 1.0))) tmp = (y + -1.0) * (x * z); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.2e+29], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+29} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -4.2000000000000003e29 or 1 < z Initial program 91.6%
Taylor expanded in z around inf 98.4%
*-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
associate-*l*98.5%
*-commutative98.5%
Simplified98.5%
if -4.2000000000000003e29 < z < 1Initial program 99.9%
Taylor expanded in y around inf 99.0%
mul-1-neg99.0%
distribute-lft-neg-out99.0%
*-commutative99.0%
Simplified99.0%
sub-neg99.0%
distribute-rgt-neg-out99.0%
remove-double-neg99.0%
+-commutative99.0%
Applied egg-rr99.0%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= z 8.8e+15) (* x (- 1.0 (* (- 1.0 y) z))) (* (+ y -1.0) (* x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.8e+15) {
tmp = x * (1.0 - ((1.0 - y) * z));
} else {
tmp = (y + -1.0) * (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 (z <= 8.8d+15) then
tmp = x * (1.0d0 - ((1.0d0 - y) * z))
else
tmp = (y + (-1.0d0)) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 8.8e+15) {
tmp = x * (1.0 - ((1.0 - y) * z));
} else {
tmp = (y + -1.0) * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 8.8e+15: tmp = x * (1.0 - ((1.0 - y) * z)) else: tmp = (y + -1.0) * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 8.8e+15) tmp = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))); else tmp = Float64(Float64(y + -1.0) * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 8.8e+15) tmp = x * (1.0 - ((1.0 - y) * z)); else tmp = (y + -1.0) * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 8.8e+15], N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.8 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < 8.8e15Initial program 98.0%
if 8.8e15 < z Initial program 89.5%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z 1.5e+17) (- x (* x (* (- 1.0 y) z))) (* (+ y -1.0) (* x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.5e+17) {
tmp = x - (x * ((1.0 - y) * z));
} else {
tmp = (y + -1.0) * (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 (z <= 1.5d+17) then
tmp = x - (x * ((1.0d0 - y) * z))
else
tmp = (y + (-1.0d0)) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.5e+17) {
tmp = x - (x * ((1.0 - y) * z));
} else {
tmp = (y + -1.0) * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.5e+17: tmp = x - (x * ((1.0 - y) * z)) else: tmp = (y + -1.0) * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.5e+17) tmp = Float64(x - Float64(x * Float64(Float64(1.0 - y) * z))); else tmp = Float64(Float64(y + -1.0) * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.5e+17) tmp = x - (x * ((1.0 - y) * z)); else tmp = (y + -1.0) * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.5e+17], N[(x - N[(x * N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.5 \cdot 10^{+17}:\\
\;\;\;\;x - x \cdot \left(\left(1 - y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < 1.5e17Initial program 98.0%
sub-neg98.0%
+-commutative98.0%
distribute-rgt-neg-in98.0%
sub-neg98.0%
+-commutative98.0%
distribute-rgt1-in98.1%
distribute-rgt-neg-in98.1%
associate-+l+98.1%
associate-+l+98.1%
distribute-rgt-neg-in98.1%
distribute-rgt1-in98.0%
+-commutative98.0%
sub-neg98.0%
distribute-rgt-neg-in98.0%
*-commutative98.0%
distribute-rgt-neg-in98.0%
fma-def98.1%
Simplified98.1%
fma-udef98.0%
distribute-lft-in98.1%
*-commutative98.1%
*-un-lft-identity98.1%
Applied egg-rr98.1%
if 1.5e17 < z Initial program 89.5%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
associate-*l*99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (<= z 1e-79) (- x (* x (* (- 1.0 y) z))) (+ x (* z (- (* x y) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e-79) {
tmp = x - (x * ((1.0 - y) * z));
} else {
tmp = x + (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 <= 1d-79) then
tmp = x - (x * ((1.0d0 - y) * z))
else
tmp = x + (z * ((x * y) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e-79) {
tmp = x - (x * ((1.0 - y) * z));
} else {
tmp = x + (z * ((x * y) - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e-79: tmp = x - (x * ((1.0 - y) * z)) else: tmp = x + (z * ((x * y) - x)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e-79) tmp = Float64(x - Float64(x * Float64(Float64(1.0 - y) * z))); else tmp = Float64(x + Float64(z * Float64(Float64(x * y) - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e-79) tmp = x - (x * ((1.0 - y) * z)); else tmp = x + (z * ((x * y) - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e-79], N[(x - N[(x * N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-79}:\\
\;\;\;\;x - x \cdot \left(\left(1 - y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if z < 1e-79Initial program 97.9%
sub-neg97.9%
+-commutative97.9%
distribute-rgt-neg-in97.9%
sub-neg97.9%
+-commutative97.9%
distribute-rgt1-in97.9%
distribute-rgt-neg-in97.9%
associate-+l+97.9%
associate-+l+97.9%
distribute-rgt-neg-in97.9%
distribute-rgt1-in97.9%
+-commutative97.9%
sub-neg97.9%
distribute-rgt-neg-in97.9%
*-commutative97.9%
distribute-rgt-neg-in97.9%
fma-def97.9%
Simplified97.9%
fma-udef97.9%
distribute-lft-in97.9%
*-commutative97.9%
*-un-lft-identity97.9%
Applied egg-rr97.9%
if 1e-79 < z Initial program 92.3%
sub-neg92.3%
+-commutative92.3%
distribute-rgt-neg-in92.3%
sub-neg92.3%
+-commutative92.3%
distribute-rgt1-in92.3%
distribute-rgt-neg-in92.3%
associate-+l+92.3%
associate-+l+92.3%
distribute-rgt-neg-in92.3%
distribute-rgt1-in92.3%
+-commutative92.3%
sub-neg92.3%
distribute-rgt-neg-in92.3%
*-commutative92.3%
distribute-rgt-neg-in92.3%
fma-def92.3%
Simplified92.3%
fma-udef92.3%
distribute-lft-in92.3%
*-commutative92.3%
*-un-lft-identity92.3%
Applied egg-rr92.3%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
*-commutative99.9%
distribute-lft-in99.9%
*-commutative99.9%
neg-mul-199.9%
unsub-neg99.9%
*-commutative99.9%
Simplified99.9%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+35) (not (<= y 6.7e+165))) (* z (* x y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+35) || !(y <= 6.7e+165)) {
tmp = z * (x * 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 <= (-1d+35)) .or. (.not. (y <= 6.7d+165))) then
tmp = z * (x * 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 <= -1e+35) || !(y <= 6.7e+165)) {
tmp = z * (x * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+35) or not (y <= 6.7e+165): tmp = z * (x * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+35) || !(y <= 6.7e+165)) tmp = Float64(z * Float64(x * 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 <= -1e+35) || ~((y <= 6.7e+165))) tmp = z * (x * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+35], N[Not[LessEqual[y, 6.7e+165]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+35} \lor \neg \left(y \leq 6.7 \cdot 10^{+165}\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -9.9999999999999997e34 or 6.70000000000000037e165 < y Initial program 90.6%
Taylor expanded in y around inf 79.0%
associate-*r*76.9%
*-commutative76.9%
associate-*l*82.0%
Simplified82.0%
if -9.9999999999999997e34 < y < 6.70000000000000037e165Initial program 99.3%
Taylor expanded in y around 0 91.0%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e+36) (not (<= y 6.7e+165))) (* z (* x y)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+36) || !(y <= 6.7e+165)) {
tmp = z * (x * 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 <= (-3d+36)) .or. (.not. (y <= 6.7d+165))) then
tmp = z * (x * 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 <= -3e+36) || !(y <= 6.7e+165)) {
tmp = z * (x * y);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+36) or not (y <= 6.7e+165): tmp = z * (x * y) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e+36) || !(y <= 6.7e+165)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3e+36) || ~((y <= 6.7e+165))) tmp = z * (x * y); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e+36], N[Not[LessEqual[y, 6.7e+165]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+36} \lor \neg \left(y \leq 6.7 \cdot 10^{+165}\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -3e36 or 6.70000000000000037e165 < y Initial program 90.6%
Taylor expanded in y around inf 79.0%
associate-*r*76.9%
*-commutative76.9%
associate-*l*82.0%
Simplified82.0%
if -3e36 < y < 6.70000000000000037e165Initial program 99.3%
Taylor expanded in y around 0 91.0%
sub-neg91.0%
+-commutative91.0%
distribute-rgt1-in91.0%
cancel-sign-sub-inv91.0%
Simplified91.0%
Final simplification87.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.86e-6) (not (<= z 1.0))) (- (* x z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.86e-6) || !(z <= 1.0)) {
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.86d-6)) .or. (.not. (z <= 1.0d0))) 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.86e-6) || !(z <= 1.0)) {
tmp = -(x * z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.86e-6) or not (z <= 1.0): tmp = -(x * z) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.86e-6) || !(z <= 1.0)) 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.86e-6) || ~((z <= 1.0))) tmp = -(x * z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.86e-6], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-N[(x * z), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.86 \cdot 10^{-6} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.86e-6 or 1 < z Initial program 92.0%
Taylor expanded in z around inf 98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
associate-*l*98.5%
*-commutative98.5%
Simplified98.5%
Taylor expanded in y around 0 58.9%
neg-mul-158.9%
distribute-rgt-neg-in58.9%
Simplified58.9%
if -1.86e-6 < z < 1Initial program 99.9%
Taylor expanded in z around 0 75.4%
Final simplification67.8%
(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.3%
Taylor expanded in z around 0 42.1%
Final simplification42.1%
(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 2023240
(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))))