
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -8200000000.0) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8200000000.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.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) :: tmp
if ((z <= (-8200000000.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
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 <= -8200000000.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8200000000.0) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8200000000.0) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); 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 <= -8200000000.0) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8200000000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8200000000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -8.2e9 or 1 < z Initial program 94.5%
Taylor expanded in z around inf 93.9%
*-commutative93.9%
associate-*r*99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
if -8.2e9 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.4%
*-commutative98.4%
Simplified98.4%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (fma (* x z) (+ y -1.0) x))
double code(double x, double y, double z) {
return fma((x * z), (y + -1.0), x);
}
function code(x, y, z) return fma(Float64(x * z), Float64(y + -1.0), x) end
code[x_, y_, z_] := N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x \cdot z, y + -1, x\right)
\end{array}
Initial program 97.0%
Taylor expanded in z around 0 97.0%
+-commutative97.0%
associate-*r*98.4%
fma-def98.4%
sub-neg98.4%
metadata-eval98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ 1.0 (* z (+ y -1.0))))) (if (<= t_0 -5e+195) (* (* x z) (/ 1.0 (/ 1.0 (+ y -1.0)))) (* x t_0))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (y + -1.0));
double tmp;
if (t_0 <= -5e+195) {
tmp = (x * z) * (1.0 / (1.0 / (y + -1.0)));
} else {
tmp = x * 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 = 1.0d0 + (z * (y + (-1.0d0)))
if (t_0 <= (-5d+195)) then
tmp = (x * z) * (1.0d0 / (1.0d0 / (y + (-1.0d0))))
else
tmp = x * t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (y + -1.0));
double tmp;
if (t_0 <= -5e+195) {
tmp = (x * z) * (1.0 / (1.0 / (y + -1.0)));
} else {
tmp = x * t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (y + -1.0)) tmp = 0 if t_0 <= -5e+195: tmp = (x * z) * (1.0 / (1.0 / (y + -1.0))) else: tmp = x * t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(y + -1.0))) tmp = 0.0 if (t_0 <= -5e+195) tmp = Float64(Float64(x * z) * Float64(1.0 / Float64(1.0 / Float64(y + -1.0)))); else tmp = Float64(x * t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (y + -1.0)); tmp = 0.0; if (t_0 <= -5e+195) tmp = (x * z) * (1.0 / (1.0 / (y + -1.0))); else tmp = x * t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+195], N[(N[(x * z), $MachinePrecision] * N[(1.0 / N[(1.0 / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \left(y + -1\right)\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+195}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \frac{1}{\frac{1}{y + -1}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot t_0\\
\end{array}
\end{array}
if (-.f64 1 (*.f64 (-.f64 1 y) z)) < -4.9999999999999998e195Initial program 89.8%
Taylor expanded in z around inf 89.8%
*-commutative89.8%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
associate-*r*99.9%
*-commutative99.9%
flip-+83.8%
associate-*r/79.9%
metadata-eval79.9%
fma-neg79.9%
metadata-eval79.9%
sub-neg79.9%
metadata-eval79.9%
Applied egg-rr79.9%
associate-/l*83.8%
div-inv83.7%
clear-num83.8%
metadata-eval83.8%
fma-neg83.8%
metadata-eval83.8%
flip--100.0%
sub-neg100.0%
metadata-eval100.0%
Applied egg-rr100.0%
if -4.9999999999999998e195 < (-.f64 1 (*.f64 (-.f64 1 y) z)) Initial program 98.6%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* z y))) (t_1 (* x (- z))))
(if (<= z -3.2e+77)
t_0
(if (<= z -1.0)
t_1
(if (<= z -6e-73)
x
(if (<= z -8e-118)
t_0
(if (<= z 4.4e-11) x (if (<= z 95000000000000.0) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = x * (z * y);
double t_1 = x * -z;
double tmp;
if (z <= -3.2e+77) {
tmp = t_0;
} else if (z <= -1.0) {
tmp = t_1;
} else if (z <= -6e-73) {
tmp = x;
} else if (z <= -8e-118) {
tmp = t_0;
} else if (z <= 4.4e-11) {
tmp = x;
} else if (z <= 95000000000000.0) {
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 * y)
t_1 = x * -z
if (z <= (-3.2d+77)) then
tmp = t_0
else if (z <= (-1.0d0)) then
tmp = t_1
else if (z <= (-6d-73)) then
tmp = x
else if (z <= (-8d-118)) then
tmp = t_0
else if (z <= 4.4d-11) then
tmp = x
else if (z <= 95000000000000.0d0) 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 * y);
double t_1 = x * -z;
double tmp;
if (z <= -3.2e+77) {
tmp = t_0;
} else if (z <= -1.0) {
tmp = t_1;
} else if (z <= -6e-73) {
tmp = x;
} else if (z <= -8e-118) {
tmp = t_0;
} else if (z <= 4.4e-11) {
tmp = x;
} else if (z <= 95000000000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (z * y) t_1 = x * -z tmp = 0 if z <= -3.2e+77: tmp = t_0 elif z <= -1.0: tmp = t_1 elif z <= -6e-73: tmp = x elif z <= -8e-118: tmp = t_0 elif z <= 4.4e-11: tmp = x elif z <= 95000000000000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(z * y)) t_1 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -3.2e+77) tmp = t_0; elseif (z <= -1.0) tmp = t_1; elseif (z <= -6e-73) tmp = x; elseif (z <= -8e-118) tmp = t_0; elseif (z <= 4.4e-11) tmp = x; elseif (z <= 95000000000000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (z * y); t_1 = x * -z; tmp = 0.0; if (z <= -3.2e+77) tmp = t_0; elseif (z <= -1.0) tmp = t_1; elseif (z <= -6e-73) tmp = x; elseif (z <= -8e-118) tmp = t_0; elseif (z <= 4.4e-11) tmp = x; elseif (z <= 95000000000000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -3.2e+77], t$95$0, If[LessEqual[z, -1.0], t$95$1, If[LessEqual[z, -6e-73], x, If[LessEqual[z, -8e-118], t$95$0, If[LessEqual[z, 4.4e-11], x, If[LessEqual[z, 95000000000000.0], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(z \cdot y\right)\\
t_1 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -3.2 \cdot 10^{+77}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -6 \cdot 10^{-73}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-118}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 95000000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -3.2000000000000002e77 or -6e-73 < z < -7.99999999999999988e-118 or 4.4000000000000003e-11 < z < 9.5e13Initial program 95.0%
Taylor expanded in y around inf 72.2%
*-commutative72.2%
Simplified72.2%
if -3.2000000000000002e77 < z < -1 or 9.5e13 < z Initial program 94.9%
Taylor expanded in z around inf 94.7%
*-commutative94.7%
associate-*r*99.7%
*-commutative99.7%
sub-neg99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 65.4%
mul-1-neg65.4%
Simplified65.4%
if -1 < z < -6e-73 or -7.99999999999999988e-118 < z < 4.4000000000000003e-11Initial program 99.9%
Taylor expanded in z around 0 81.4%
Final simplification73.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* x (+ y -1.0)))))
(if (<= z -0.00115)
t_0
(if (<= z -8.4e-72)
(- x (* x z))
(if (or (<= z -8e-118) (not (<= z 1.15e-9))) t_0 (* x (- 1.0 z)))))))
double code(double x, double y, double z) {
double t_0 = z * (x * (y + -1.0));
double tmp;
if (z <= -0.00115) {
tmp = t_0;
} else if (z <= -8.4e-72) {
tmp = x - (x * z);
} else if ((z <= -8e-118) || !(z <= 1.15e-9)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = z * (x * (y + (-1.0d0)))
if (z <= (-0.00115d0)) then
tmp = t_0
else if (z <= (-8.4d-72)) then
tmp = x - (x * z)
else if ((z <= (-8d-118)) .or. (.not. (z <= 1.15d-9))) then
tmp = t_0
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (x * (y + -1.0));
double tmp;
if (z <= -0.00115) {
tmp = t_0;
} else if (z <= -8.4e-72) {
tmp = x - (x * z);
} else if ((z <= -8e-118) || !(z <= 1.15e-9)) {
tmp = t_0;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): t_0 = z * (x * (y + -1.0)) tmp = 0 if z <= -0.00115: tmp = t_0 elif z <= -8.4e-72: tmp = x - (x * z) elif (z <= -8e-118) or not (z <= 1.15e-9): tmp = t_0 else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(x * Float64(y + -1.0))) tmp = 0.0 if (z <= -0.00115) tmp = t_0; elseif (z <= -8.4e-72) tmp = Float64(x - Float64(x * z)); elseif ((z <= -8e-118) || !(z <= 1.15e-9)) tmp = t_0; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (x * (y + -1.0)); tmp = 0.0; if (z <= -0.00115) tmp = t_0; elseif (z <= -8.4e-72) tmp = x - (x * z); elseif ((z <= -8e-118) || ~((z <= 1.15e-9))) tmp = t_0; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.00115], t$95$0, If[LessEqual[z, -8.4e-72], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -8e-118], N[Not[LessEqual[z, 1.15e-9]], $MachinePrecision]], t$95$0, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;z \leq -0.00115:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -8.4 \cdot 10^{-72}:\\
\;\;\;\;x - x \cdot z\\
\mathbf{elif}\;z \leq -8 \cdot 10^{-118} \lor \neg \left(z \leq 1.15 \cdot 10^{-9}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if z < -0.00115 or -8.4e-72 < z < -7.99999999999999988e-118 or 1.15e-9 < z Initial program 95.0%
Taylor expanded in z around inf 93.2%
*-commutative93.2%
associate-*r*98.1%
*-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
Simplified98.1%
if -0.00115 < z < -8.4e-72Initial program 99.7%
Taylor expanded in z around 0 99.9%
+-commutative99.9%
associate-*r*99.9%
fma-def99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.6%
mul-1-neg82.6%
sub-neg82.6%
Simplified82.6%
if -7.99999999999999988e-118 < z < 1.15e-9Initial program 99.9%
Taylor expanded in y around 0 82.4%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (<= (* z (- 1.0 y)) 5e+191) (* x (+ 1.0 (* z (+ y -1.0)))) (* (* x z) (+ y -1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z * (1.0 - y)) <= 5e+191) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (x * z) * (y + -1.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) :: tmp
if ((z * (1.0d0 - y)) <= 5d+191) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = (x * z) * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * (1.0 - y)) <= 5e+191) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (x * z) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * (1.0 - y)) <= 5e+191: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = (x * z) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * Float64(1.0 - y)) <= 5e+191) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(x * z) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * (1.0 - y)) <= 5e+191) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = (x * z) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], 5e+191], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot \left(1 - y\right) \leq 5 \cdot 10^{+191}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < 5.0000000000000002e191Initial program 98.6%
if 5.0000000000000002e191 < (*.f64 (-.f64 1 y) z) Initial program 89.8%
Taylor expanded in z around inf 89.8%
*-commutative89.8%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
associate-*r*99.9%
*-commutative99.9%
flip-+83.8%
associate-*r/79.9%
metadata-eval79.9%
fma-neg79.9%
metadata-eval79.9%
sub-neg79.9%
metadata-eval79.9%
Applied egg-rr79.9%
Taylor expanded in y around 0 83.4%
*-commutative83.4%
*-commutative83.4%
associate-*r*93.6%
distribute-lft-in99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(if (or (<= y -3.9e+96)
(not (or (<= y -9.2e+61) (and (not (<= y -2.5e+38)) (<= y 1.3e+14)))))
(* x (* z y))
(* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.9e+96) || !((y <= -9.2e+61) || (!(y <= -2.5e+38) && (y <= 1.3e+14)))) {
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.9d+96)) .or. (.not. (y <= (-9.2d+61)) .or. (.not. (y <= (-2.5d+38))) .and. (y <= 1.3d+14))) 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.9e+96) || !((y <= -9.2e+61) || (!(y <= -2.5e+38) && (y <= 1.3e+14)))) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.9e+96) or not ((y <= -9.2e+61) or (not (y <= -2.5e+38) and (y <= 1.3e+14))): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.9e+96) || !((y <= -9.2e+61) || (!(y <= -2.5e+38) && (y <= 1.3e+14)))) 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.9e+96) || ~(((y <= -9.2e+61) || (~((y <= -2.5e+38)) && (y <= 1.3e+14))))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.9e+96], N[Not[Or[LessEqual[y, -9.2e+61], And[N[Not[LessEqual[y, -2.5e+38]], $MachinePrecision], LessEqual[y, 1.3e+14]]]], $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.9 \cdot 10^{+96} \lor \neg \left(y \leq -9.2 \cdot 10^{+61} \lor \neg \left(y \leq -2.5 \cdot 10^{+38}\right) \land y \leq 1.3 \cdot 10^{+14}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.9e96 or -9.1999999999999998e61 < y < -2.49999999999999985e38 or 1.3e14 < y Initial program 92.3%
Taylor expanded in y around inf 77.9%
*-commutative77.9%
Simplified77.9%
if -3.9e96 < y < -9.1999999999999998e61 or -2.49999999999999985e38 < y < 1.3e14Initial program 100.0%
Taylor expanded in y around 0 94.3%
Final simplification87.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* x y))) (t_1 (* x (- 1.0 z))))
(if (<= y -9e+88)
t_0
(if (<= y -1.1e+59)
t_1
(if (<= y -4.2e+39) t_0 (if (<= y 3.9e+14) t_1 (* x (* z y))))))))
double code(double x, double y, double z) {
double t_0 = z * (x * y);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -9e+88) {
tmp = t_0;
} else if (y <= -1.1e+59) {
tmp = t_1;
} else if (y <= -4.2e+39) {
tmp = t_0;
} else if (y <= 3.9e+14) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * (x * y)
t_1 = x * (1.0d0 - z)
if (y <= (-9d+88)) then
tmp = t_0
else if (y <= (-1.1d+59)) then
tmp = t_1
else if (y <= (-4.2d+39)) then
tmp = t_0
else if (y <= 3.9d+14) then
tmp = t_1
else
tmp = x * (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (x * y);
double t_1 = x * (1.0 - z);
double tmp;
if (y <= -9e+88) {
tmp = t_0;
} else if (y <= -1.1e+59) {
tmp = t_1;
} else if (y <= -4.2e+39) {
tmp = t_0;
} else if (y <= 3.9e+14) {
tmp = t_1;
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): t_0 = z * (x * y) t_1 = x * (1.0 - z) tmp = 0 if y <= -9e+88: tmp = t_0 elif y <= -1.1e+59: tmp = t_1 elif y <= -4.2e+39: tmp = t_0 elif y <= 3.9e+14: tmp = t_1 else: tmp = x * (z * y) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(x * y)) t_1 = Float64(x * Float64(1.0 - z)) tmp = 0.0 if (y <= -9e+88) tmp = t_0; elseif (y <= -1.1e+59) tmp = t_1; elseif (y <= -4.2e+39) tmp = t_0; elseif (y <= 3.9e+14) tmp = t_1; else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (x * y); t_1 = x * (1.0 - z); tmp = 0.0; if (y <= -9e+88) tmp = t_0; elseif (y <= -1.1e+59) tmp = t_1; elseif (y <= -4.2e+39) tmp = t_0; elseif (y <= 3.9e+14) tmp = t_1; else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9e+88], t$95$0, If[LessEqual[y, -1.1e+59], t$95$1, If[LessEqual[y, -4.2e+39], t$95$0, If[LessEqual[y, 3.9e+14], t$95$1, N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(x \cdot y\right)\\
t_1 := x \cdot \left(1 - z\right)\\
\mathbf{if}\;y \leq -9 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{+59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+14}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -9e88 or -1.1e59 < y < -4.1999999999999997e39Initial program 88.8%
Taylor expanded in y around inf 80.3%
associate-*r*88.7%
*-commutative88.7%
Simplified88.7%
if -9e88 < y < -1.1e59 or -4.1999999999999997e39 < y < 3.9e14Initial program 100.0%
Taylor expanded in y around 0 94.3%
if 3.9e14 < y Initial program 96.0%
Taylor expanded in y around inf 75.4%
*-commutative75.4%
Simplified75.4%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(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.0d0)) .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.0) || !(z <= 1.0)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) 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 <= 1.0))) 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.0]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 94.5%
Taylor expanded in z around inf 93.9%
*-commutative93.9%
associate-*r*99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in y around 0 60.0%
mul-1-neg60.0%
Simplified60.0%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 73.7%
Final simplification66.2%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 97.0%
Taylor expanded in z around 0 35.2%
Final simplification35.2%
(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 2023332
(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))))