
(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 (or (<= z -0.98) (not (<= z 1.0))) (* z (- (* y x) x)) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.98) || !(z <= 1.0)) {
tmp = z * ((y * x) - x);
} else {
tmp = x + (x * (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 <= (-0.98d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * ((y * x) - x)
else
tmp = x + (x * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.98) || !(z <= 1.0)) {
tmp = z * ((y * x) - x);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.98) or not (z <= 1.0): tmp = z * ((y * x) - x) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.98) || !(z <= 1.0)) tmp = Float64(z * Float64(Float64(y * x) - x)); else tmp = Float64(x + Float64(x * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.98) || ~((z <= 1.0))) tmp = z * ((y * x) - x); else tmp = x + (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.98], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.98 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.97999999999999998 or 1 < z Initial program 90.7%
Taylor expanded in z around inf 97.9%
*-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
distribute-rgt-in97.9%
neg-mul-197.9%
unsub-neg97.9%
Simplified97.9%
if -0.97999999999999998 < z < 1Initial program 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-rgt-neg-in99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification98.5%
(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*97.2%
fma-def97.2%
neg-sub097.2%
associate--r-97.2%
metadata-eval97.2%
+-commutative97.2%
*-commutative97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* y (* x z))))
(if (<= y -5e+101)
t_1
(if (<= y -2.3e-221)
x
(if (<= y -7e-261) t_0 (if (<= y 5e-292) x (if (<= y 1.0) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = y * (x * z);
double tmp;
if (y <= -5e+101) {
tmp = t_1;
} else if (y <= -2.3e-221) {
tmp = x;
} else if (y <= -7e-261) {
tmp = t_0;
} else if (y <= 5e-292) {
tmp = x;
} else if (y <= 1.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
t_1 = y * (x * z)
if (y <= (-5d+101)) then
tmp = t_1
else if (y <= (-2.3d-221)) then
tmp = x
else if (y <= (-7d-261)) then
tmp = t_0
else if (y <= 5d-292) then
tmp = x
else if (y <= 1.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;
double t_1 = y * (x * z);
double tmp;
if (y <= -5e+101) {
tmp = t_1;
} else if (y <= -2.3e-221) {
tmp = x;
} else if (y <= -7e-261) {
tmp = t_0;
} else if (y <= 5e-292) {
tmp = x;
} else if (y <= 1.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = y * (x * z) tmp = 0 if y <= -5e+101: tmp = t_1 elif y <= -2.3e-221: tmp = x elif y <= -7e-261: tmp = t_0 elif y <= 5e-292: tmp = x elif y <= 1.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(y * Float64(x * z)) tmp = 0.0 if (y <= -5e+101) tmp = t_1; elseif (y <= -2.3e-221) tmp = x; elseif (y <= -7e-261) tmp = t_0; elseif (y <= 5e-292) tmp = x; elseif (y <= 1.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = y * (x * z); tmp = 0.0; if (y <= -5e+101) tmp = t_1; elseif (y <= -2.3e-221) tmp = x; elseif (y <= -7e-261) tmp = t_0; elseif (y <= 5e-292) tmp = x; elseif (y <= 1.0) 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[(y * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5e+101], t$95$1, If[LessEqual[y, -2.3e-221], x, If[LessEqual[y, -7e-261], t$95$0, If[LessEqual[y, 5e-292], x, If[LessEqual[y, 1.0], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{+101}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.3 \cdot 10^{-221}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-261}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-292}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -4.99999999999999989e101 or 1 < y Initial program 89.6%
Taylor expanded in y around inf 77.3%
if -4.99999999999999989e101 < y < -2.3e-221 or -6.9999999999999995e-261 < y < 4.99999999999999981e-292Initial program 99.9%
Taylor expanded in z around 0 66.8%
if -2.3e-221 < y < -6.9999999999999995e-261 or 4.99999999999999981e-292 < y < 1Initial program 99.9%
Taylor expanded in z around inf 65.9%
*-commutative65.9%
sub-neg65.9%
metadata-eval65.9%
distribute-rgt-in65.9%
neg-mul-165.9%
unsub-neg65.9%
Simplified65.9%
Taylor expanded in y around 0 64.8%
neg-mul-164.8%
Simplified64.8%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -112.0) (not (<= y 1.0))) (+ x (* z (* y x))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -112.0) || !(y <= 1.0)) {
tmp = x + (z * (y * x));
} 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 <= (-112.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x + (z * (y * x))
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 <= -112.0) || !(y <= 1.0)) {
tmp = x + (z * (y * x));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -112.0) or not (y <= 1.0): tmp = x + (z * (y * x)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -112.0) || !(y <= 1.0)) tmp = Float64(x + Float64(z * Float64(y * x))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -112.0) || ~((y <= 1.0))) tmp = x + (z * (y * x)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -112.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x + N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -112 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -112 or 1 < y Initial program 91.4%
sub-neg91.4%
distribute-rgt-in91.4%
*-un-lft-identity91.4%
distribute-rgt-neg-in91.4%
Applied egg-rr91.4%
Taylor expanded in y around inf 93.9%
*-commutative93.9%
associate-*r*88.4%
Simplified88.4%
if -112 < y < 1Initial program 99.9%
Taylor expanded in y around 0 98.7%
*-commutative98.7%
distribute-rgt-out--98.7%
*-lft-identity98.7%
Simplified98.7%
Final simplification93.4%
(FPCore (x y z) :precision binary64 (if (<= z 5e-33) (+ x (* x (* z (+ y -1.0)))) (+ x (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5e-33) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = x + (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 <= 5d-33) then
tmp = x + (x * (z * (y + (-1.0d0))))
else
tmp = x + (z * ((y * x) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 5e-33) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = x + (z * ((y * x) - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 5e-33: tmp = x + (x * (z * (y + -1.0))) else: tmp = x + (z * ((y * x) - x)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 5e-33) tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); else tmp = Float64(x + Float64(z * Float64(Float64(y * x) - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 5e-33) tmp = x + (x * (z * (y + -1.0))); else tmp = x + (z * ((y * x) - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 5e-33], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{-33}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < 5.00000000000000028e-33Initial program 97.8%
sub-neg97.8%
distribute-rgt-in97.9%
*-un-lft-identity97.9%
distribute-rgt-neg-in97.9%
Applied egg-rr97.9%
if 5.00000000000000028e-33 < z Initial program 89.8%
distribute-rgt-out--89.8%
*-lft-identity89.8%
cancel-sign-sub-inv89.8%
+-commutative89.8%
distribute-lft-neg-in89.8%
associate-*l*99.1%
fma-def99.2%
neg-sub099.2%
associate--r-99.2%
metadata-eval99.2%
+-commutative99.2%
*-commutative99.2%
Simplified99.2%
fma-udef99.1%
associate-*r*99.9%
Applied egg-rr99.9%
*-commutative99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
sub-neg99.9%
Applied egg-rr99.9%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (<= z 15000000.0) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (- (* y x) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 15000000.0) {
tmp = x * (1.0 + (z * (y + -1.0)));
} 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 <= 15000000.0d0) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
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 <= 15000000.0) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * ((y * x) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 15000000.0: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * ((y * x) - x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 15000000.0) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); 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 <= 15000000.0) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * ((y * x) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 15000000.0], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 15000000:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < 1.5e7Initial program 98.0%
if 1.5e7 < z Initial program 87.9%
Taylor expanded in z around inf 99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
unsub-neg99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z 1e-35) (* x (+ 1.0 (* z (+ y -1.0)))) (+ x (* z (- (* y x) x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e-35) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = x + (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 <= 1d-35) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = x + (z * ((y * x) - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e-35) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = x + (z * ((y * x) - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e-35: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = x + (z * ((y * x) - x)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e-35) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(x + Float64(z * Float64(Float64(y * x) - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e-35) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = x + (z * ((y * x) - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e-35], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * x), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-35}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot x - x\right)\\
\end{array}
\end{array}
if z < 1.00000000000000001e-35Initial program 97.8%
if 1.00000000000000001e-35 < z Initial program 89.8%
distribute-rgt-out--89.8%
*-lft-identity89.8%
cancel-sign-sub-inv89.8%
+-commutative89.8%
distribute-lft-neg-in89.8%
associate-*l*99.1%
fma-def99.2%
neg-sub099.2%
associate--r-99.2%
metadata-eval99.2%
+-commutative99.2%
*-commutative99.2%
Simplified99.2%
fma-udef99.1%
associate-*r*99.9%
Applied egg-rr99.9%
*-commutative99.9%
distribute-rgt-in99.9%
neg-mul-199.9%
sub-neg99.9%
Applied egg-rr99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.1e+101) (not (<= y 480000.0))) (* y (* x z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.1e+101) || !(y <= 480000.0)) {
tmp = y * (x * z);
} 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 <= (-5.1d+101)) .or. (.not. (y <= 480000.0d0))) then
tmp = y * (x * z)
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 <= -5.1e+101) || !(y <= 480000.0)) {
tmp = y * (x * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.1e+101) or not (y <= 480000.0): tmp = y * (x * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.1e+101) || !(y <= 480000.0)) tmp = Float64(y * Float64(x * z)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.1e+101) || ~((y <= 480000.0))) tmp = y * (x * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.1e+101], N[Not[LessEqual[y, 480000.0]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.1 \cdot 10^{+101} \lor \neg \left(y \leq 480000\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -5.09999999999999995e101 or 4.8e5 < y Initial program 89.5%
Taylor expanded in y around inf 77.9%
if -5.09999999999999995e101 < y < 4.8e5Initial program 99.9%
Taylor expanded in y around 0 93.8%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.7e+101) (not (<= y 3000000.0))) (* y (* x z)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.7e+101) || !(y <= 3000000.0)) {
tmp = 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 <= (-4.7d+101)) .or. (.not. (y <= 3000000.0d0))) then
tmp = 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 <= -4.7e+101) || !(y <= 3000000.0)) {
tmp = y * (x * z);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.7e+101) or not (y <= 3000000.0): tmp = y * (x * z) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.7e+101) || !(y <= 3000000.0)) tmp = 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 <= -4.7e+101) || ~((y <= 3000000.0))) tmp = y * (x * z); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.7e+101], N[Not[LessEqual[y, 3000000.0]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.7 \cdot 10^{+101} \lor \neg \left(y \leq 3000000\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -4.69999999999999971e101 or 3e6 < y Initial program 89.5%
Taylor expanded in y around inf 77.9%
if -4.69999999999999971e101 < y < 3e6Initial program 99.9%
Taylor expanded in y around 0 93.8%
*-commutative93.8%
distribute-rgt-out--93.8%
*-lft-identity93.8%
Simplified93.8%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 0.0037))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0037)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 0.0037d0))) then
tmp = x * -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 0.0037)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 0.0037): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 0.0037)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 0.0037))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 0.0037]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 0.0037\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 0.0037000000000000002 < z Initial program 90.8%
Taylor expanded in z around inf 97.5%
*-commutative97.5%
sub-neg97.5%
metadata-eval97.5%
distribute-rgt-in97.5%
neg-mul-197.5%
unsub-neg97.5%
Simplified97.5%
Taylor expanded in y around 0 59.0%
neg-mul-159.0%
Simplified59.0%
if -1 < z < 0.0037000000000000002Initial program 99.9%
Taylor expanded in z around 0 67.3%
Final simplification63.3%
(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 36.5%
Final simplification36.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 2023230
(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))))