
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -2e+75) (* (* z x) (+ y -1.0)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+75) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + (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 <= (-2d+75)) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e+75) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e+75: tmp = (z * x) * (y + -1.0) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e+75) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e+75) tmp = (z * x) * (y + -1.0); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e+75], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+75}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < -1.99999999999999985e75Initial program 87.1%
Taylor expanded in z around inf 99.8%
*-commutative99.8%
associate-*l*99.8%
sub-neg99.8%
metadata-eval99.8%
*-commutative99.8%
Simplified99.8%
if -1.99999999999999985e75 < z Initial program 99.5%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (* z x))))
(if (<= z -1.02e-13)
t_0
(if (<= z 1.15e-19)
x
(if (or (<= z 9.8e+17)
(and (not (<= z 1.25e+42))
(or (<= z 1.32e+91)
(and (not (<= z 2.65e+209)) (<= z 3.4e+256)))))
t_0
(* z (- x)))))))
double code(double x, double y, double z) {
double t_0 = y * (z * x);
double tmp;
if (z <= -1.02e-13) {
tmp = t_0;
} else if (z <= 1.15e-19) {
tmp = x;
} else if ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256))))) {
tmp = t_0;
} else {
tmp = z * -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (z * x)
if (z <= (-1.02d-13)) then
tmp = t_0
else if (z <= 1.15d-19) then
tmp = x
else if ((z <= 9.8d+17) .or. (.not. (z <= 1.25d+42)) .and. (z <= 1.32d+91) .or. (.not. (z <= 2.65d+209)) .and. (z <= 3.4d+256)) then
tmp = t_0
else
tmp = z * -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (z * x);
double tmp;
if (z <= -1.02e-13) {
tmp = t_0;
} else if (z <= 1.15e-19) {
tmp = x;
} else if ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256))))) {
tmp = t_0;
} else {
tmp = z * -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (z * x) tmp = 0 if z <= -1.02e-13: tmp = t_0 elif z <= 1.15e-19: tmp = x elif (z <= 9.8e+17) or (not (z <= 1.25e+42) and ((z <= 1.32e+91) or (not (z <= 2.65e+209) and (z <= 3.4e+256)))): tmp = t_0 else: tmp = z * -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(z * x)) tmp = 0.0 if (z <= -1.02e-13) tmp = t_0; elseif (z <= 1.15e-19) tmp = x; elseif ((z <= 9.8e+17) || (!(z <= 1.25e+42) && ((z <= 1.32e+91) || (!(z <= 2.65e+209) && (z <= 3.4e+256))))) tmp = t_0; else tmp = Float64(z * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (z * x); tmp = 0.0; if (z <= -1.02e-13) tmp = t_0; elseif (z <= 1.15e-19) tmp = x; elseif ((z <= 9.8e+17) || (~((z <= 1.25e+42)) && ((z <= 1.32e+91) || (~((z <= 2.65e+209)) && (z <= 3.4e+256))))) tmp = t_0; else tmp = z * -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.02e-13], t$95$0, If[LessEqual[z, 1.15e-19], x, If[Or[LessEqual[z, 9.8e+17], And[N[Not[LessEqual[z, 1.25e+42]], $MachinePrecision], Or[LessEqual[z, 1.32e+91], And[N[Not[LessEqual[z, 2.65e+209]], $MachinePrecision], LessEqual[z, 3.4e+256]]]]], t$95$0, N[(z * (-x)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;z \leq -1.02 \cdot 10^{-13}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-19}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 9.8 \cdot 10^{+17} \lor \neg \left(z \leq 1.25 \cdot 10^{+42}\right) \land \left(z \leq 1.32 \cdot 10^{+91} \lor \neg \left(z \leq 2.65 \cdot 10^{+209}\right) \land z \leq 3.4 \cdot 10^{+256}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if z < -1.0199999999999999e-13 or 1.1499999999999999e-19 < z < 9.8e17 or 1.25000000000000002e42 < z < 1.32000000000000003e91 or 2.64999999999999997e209 < z < 3.39999999999999984e256Initial program 93.2%
Taylor expanded in y around inf 69.0%
if -1.0199999999999999e-13 < z < 1.1499999999999999e-19Initial program 100.0%
Taylor expanded in z around 0 81.5%
if 9.8e17 < z < 1.25000000000000002e42 or 1.32000000000000003e91 < z < 2.64999999999999997e209 or 3.39999999999999984e256 < z Initial program 96.8%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
associate-*l*100.0%
sub-neg100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 81.3%
mul-1-neg81.3%
distribute-rgt-neg-in81.3%
Simplified81.3%
Final simplification76.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (* y x))) (t_1 (* z (- x))) (t_2 (* y (* z x))))
(if (<= z -8.5e-14)
t_2
(if (<= z 1.2e-19)
x
(if (<= z 1.2e+23)
t_0
(if (<= z 5.6e+40)
t_1
(if (<= z 1.35e+94)
t_0
(if (or (<= z 1.85e+210) (not (<= z 3.7e+256))) t_1 t_2))))))))
double code(double x, double y, double z) {
double t_0 = z * (y * x);
double t_1 = z * -x;
double t_2 = y * (z * x);
double tmp;
if (z <= -8.5e-14) {
tmp = t_2;
} else if (z <= 1.2e-19) {
tmp = x;
} else if (z <= 1.2e+23) {
tmp = t_0;
} else if (z <= 5.6e+40) {
tmp = t_1;
} else if (z <= 1.35e+94) {
tmp = t_0;
} else if ((z <= 1.85e+210) || !(z <= 3.7e+256)) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_2
real(8) :: tmp
t_0 = z * (y * x)
t_1 = z * -x
t_2 = y * (z * x)
if (z <= (-8.5d-14)) then
tmp = t_2
else if (z <= 1.2d-19) then
tmp = x
else if (z <= 1.2d+23) then
tmp = t_0
else if (z <= 5.6d+40) then
tmp = t_1
else if (z <= 1.35d+94) then
tmp = t_0
else if ((z <= 1.85d+210) .or. (.not. (z <= 3.7d+256))) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y * x);
double t_1 = z * -x;
double t_2 = y * (z * x);
double tmp;
if (z <= -8.5e-14) {
tmp = t_2;
} else if (z <= 1.2e-19) {
tmp = x;
} else if (z <= 1.2e+23) {
tmp = t_0;
} else if (z <= 5.6e+40) {
tmp = t_1;
} else if (z <= 1.35e+94) {
tmp = t_0;
} else if ((z <= 1.85e+210) || !(z <= 3.7e+256)) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y * x) t_1 = z * -x t_2 = y * (z * x) tmp = 0 if z <= -8.5e-14: tmp = t_2 elif z <= 1.2e-19: tmp = x elif z <= 1.2e+23: tmp = t_0 elif z <= 5.6e+40: tmp = t_1 elif z <= 1.35e+94: tmp = t_0 elif (z <= 1.85e+210) or not (z <= 3.7e+256): tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y * x)) t_1 = Float64(z * Float64(-x)) t_2 = Float64(y * Float64(z * x)) tmp = 0.0 if (z <= -8.5e-14) tmp = t_2; elseif (z <= 1.2e-19) tmp = x; elseif (z <= 1.2e+23) tmp = t_0; elseif (z <= 5.6e+40) tmp = t_1; elseif (z <= 1.35e+94) tmp = t_0; elseif ((z <= 1.85e+210) || !(z <= 3.7e+256)) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y * x); t_1 = z * -x; t_2 = y * (z * x); tmp = 0.0; if (z <= -8.5e-14) tmp = t_2; elseif (z <= 1.2e-19) tmp = x; elseif (z <= 1.2e+23) tmp = t_0; elseif (z <= 5.6e+40) tmp = t_1; elseif (z <= 1.35e+94) tmp = t_0; elseif ((z <= 1.85e+210) || ~((z <= 3.7e+256))) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.5e-14], t$95$2, If[LessEqual[z, 1.2e-19], x, If[LessEqual[z, 1.2e+23], t$95$0, If[LessEqual[z, 5.6e+40], t$95$1, If[LessEqual[z, 1.35e+94], t$95$0, If[Or[LessEqual[z, 1.85e+210], N[Not[LessEqual[z, 3.7e+256]], $MachinePrecision]], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(y \cdot x\right)\\
t_1 := z \cdot \left(-x\right)\\
t_2 := y \cdot \left(z \cdot x\right)\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{-14}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-19}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{+23}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{+40}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+94}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{+210} \lor \neg \left(z \leq 3.7 \cdot 10^{+256}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -8.50000000000000038e-14 or 1.84999999999999999e210 < z < 3.70000000000000031e256Initial program 91.6%
Taylor expanded in y around inf 64.1%
if -8.50000000000000038e-14 < z < 1.20000000000000011e-19Initial program 100.0%
Taylor expanded in z around 0 81.5%
if 1.20000000000000011e-19 < z < 1.2e23 or 5.6000000000000003e40 < z < 1.3500000000000001e94Initial program 99.9%
Taylor expanded in y around inf 90.6%
associate-*r*90.7%
*-commutative90.7%
associate-*l*90.8%
Simplified90.8%
if 1.2e23 < z < 5.6000000000000003e40 or 1.3500000000000001e94 < z < 1.84999999999999999e210 or 3.70000000000000031e256 < z Initial program 96.8%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
associate-*l*100.0%
sub-neg100.0%
metadata-eval100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around 0 81.3%
mul-1-neg81.3%
distribute-rgt-neg-in81.3%
Simplified81.3%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.8e-5) (not (<= z 1.6e-19))) (* z (- (* y x) x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e-5) || !(z <= 1.6e-19)) {
tmp = z * ((y * x) - x);
} 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 ((z <= (-2.8d-5)) .or. (.not. (z <= 1.6d-19))) then
tmp = z * ((y * x) - x)
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 ((z <= -2.8e-5) || !(z <= 1.6e-19)) {
tmp = z * ((y * x) - x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.8e-5) or not (z <= 1.6e-19): tmp = z * ((y * x) - x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.8e-5) || !(z <= 1.6e-19)) tmp = Float64(z * Float64(Float64(y * x) - x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.8e-5) || ~((z <= 1.6e-19))) tmp = z * ((y * x) - x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.8e-5], N[Not[LessEqual[z, 1.6e-19]], $MachinePrecision]], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{-5} \lor \neg \left(z \leq 1.6 \cdot 10^{-19}\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if z < -2.79999999999999996e-5 or 1.59999999999999991e-19 < z Initial program 93.9%
Taylor expanded in z around inf 98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
distribute-rgt-in98.7%
neg-mul-198.7%
unsub-neg98.7%
Simplified98.7%
if -2.79999999999999996e-5 < z < 1.59999999999999991e-19Initial program 100.0%
Taylor expanded in y around 0 81.1%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.7e-5) (* (* z x) (+ y -1.0)) (if (<= z 1.45e-19) (* x (- 1.0 z)) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.7e-5) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.45e-19) {
tmp = x * (1.0 - z);
} else {
tmp = z * ((y * x) - 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.7d-5)) then
tmp = (z * x) * (y + (-1.0d0))
else if (z <= 1.45d-19) then
tmp = x * (1.0d0 - z)
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.7e-5) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.45e-19) {
tmp = x * (1.0 - z);
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.7e-5: tmp = (z * x) * (y + -1.0) elif z <= 1.45e-19: tmp = x * (1.0 - z) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.7e-5) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); elseif (z <= 1.45e-19) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.7e-5) tmp = (z * x) * (y + -1.0); elseif (z <= 1.45e-19) tmp = x * (1.0 - z); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.7e-5], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e-19], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-5}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-19}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -1.7e-5Initial program 90.5%
Taylor expanded in z around inf 98.5%
*-commutative98.5%
associate-*l*98.5%
sub-neg98.5%
metadata-eval98.5%
*-commutative98.5%
Simplified98.5%
if -1.7e-5 < z < 1.45e-19Initial program 100.0%
Taylor expanded in y around 0 81.1%
if 1.45e-19 < z Initial program 98.3%
Taylor expanded in z around inf 99.0%
*-commutative99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-in99.0%
neg-mul-199.0%
unsub-neg99.0%
Simplified99.0%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (<= z -0.95) (* (* z x) (+ y -1.0)) (if (<= z 1.76e-19) (+ x (* x (* z y))) (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.95) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.76e-19) {
tmp = x + (x * (z * y));
} else {
tmp = z * ((y * x) - 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 <= (-0.95d0)) then
tmp = (z * x) * (y + (-1.0d0))
else if (z <= 1.76d-19) then
tmp = x + (x * (z * y))
else
tmp = z * ((y * x) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.95) {
tmp = (z * x) * (y + -1.0);
} else if (z <= 1.76e-19) {
tmp = x + (x * (z * y));
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.95: tmp = (z * x) * (y + -1.0) elif z <= 1.76e-19: tmp = x + (x * (z * y)) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.95) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); elseif (z <= 1.76e-19) tmp = Float64(x + Float64(x * Float64(z * y))); else tmp = Float64(z * Float64(Float64(y * x) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.95) tmp = (z * x) * (y + -1.0); elseif (z <= 1.76e-19) tmp = x + (x * (z * y)); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.95], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.76e-19], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.95:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{elif}\;z \leq 1.76 \cdot 10^{-19}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < -0.94999999999999996Initial program 90.4%
Taylor expanded in z around inf 98.4%
*-commutative98.4%
associate-*l*98.5%
sub-neg98.5%
metadata-eval98.5%
*-commutative98.5%
Simplified98.5%
if -0.94999999999999996 < z < 1.75999999999999993e-19Initial program 100.0%
Taylor expanded in y around inf 99.4%
mul-1-neg99.4%
distribute-lft-neg-out99.4%
*-commutative99.4%
Simplified99.4%
sub-neg99.4%
distribute-rgt-neg-out99.4%
remove-double-neg99.4%
distribute-lft-in99.4%
*-commutative99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
if 1.75999999999999993e-19 < z Initial program 98.3%
Taylor expanded in z around inf 99.0%
*-commutative99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-rgt-in99.0%
neg-mul-199.0%
unsub-neg99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.1e+48) (not (<= y 5.3))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.1e+48) || !(y <= 5.3)) {
tmp = z * (y * x);
} 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 <= (-2.1d+48)) .or. (.not. (y <= 5.3d0))) then
tmp = z * (y * x)
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 <= -2.1e+48) || !(y <= 5.3)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.1e+48) or not (y <= 5.3): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.1e+48) || !(y <= 5.3)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.1e+48) || ~((y <= 5.3))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.1e+48], N[Not[LessEqual[y, 5.3]], $MachinePrecision]], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+48} \lor \neg \left(y \leq 5.3\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.0999999999999998e48 or 5.29999999999999982 < y Initial program 93.5%
Taylor expanded in y around inf 74.8%
associate-*r*75.6%
*-commutative75.6%
associate-*l*80.3%
Simplified80.3%
if -2.0999999999999998e48 < y < 5.29999999999999982Initial program 99.3%
Taylor expanded in y around 0 97.8%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 4e-14))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 4e-14)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 4d-14))) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 4e-14)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 4e-14): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 4e-14)) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 4e-14))) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 4e-14]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 4 \cdot 10^{-14}\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 4e-14 < z Initial program 93.8%
Taylor expanded in z around inf 98.7%
*-commutative98.7%
associate-*l*98.7%
sub-neg98.7%
metadata-eval98.7%
*-commutative98.7%
Simplified98.7%
Taylor expanded in y around 0 49.2%
mul-1-neg49.2%
distribute-rgt-neg-in49.2%
Simplified49.2%
if -1 < z < 4e-14Initial program 100.0%
Taylor expanded in z around 0 79.2%
Final simplification62.9%
(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.6%
Taylor expanded in z around 0 38.0%
Final simplification38.0%
(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 2023229
(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))))