
(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
(let* ((t_0 (* z (- 1.0 y))))
(if (<= t_0 (- INFINITY))
(+ x (* y (* z x)))
(if (<= t_0 4e+296) (* x (+ 1.0 (* z (+ -1.0 y)))) (* z (* y x))))))
double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x + (y * (z * x));
} else if (t_0 <= 4e+296) {
tmp = x * (1.0 + (z * (-1.0 + y)));
} else {
tmp = z * (y * x);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = z * (1.0 - y);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x + (y * (z * x));
} else if (t_0 <= 4e+296) {
tmp = x * (1.0 + (z * (-1.0 + y)));
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): t_0 = z * (1.0 - y) tmp = 0 if t_0 <= -math.inf: tmp = x + (y * (z * x)) elif t_0 <= 4e+296: tmp = x * (1.0 + (z * (-1.0 + y))) else: tmp = z * (y * x) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(1.0 - y)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x + Float64(y * Float64(z * x))); elseif (t_0 <= 4e+296) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(-1.0 + y)))); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (1.0 - y); tmp = 0.0; if (t_0 <= -Inf) tmp = x + (y * (z * x)); elseif (t_0 <= 4e+296) tmp = x * (1.0 + (z * (-1.0 + y))); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x + N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+296], N[(x * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(1 - y\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;x + y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+296}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 1 y) z) < -inf.0Initial program 57.1%
sub-neg57.1%
distribute-rgt-in57.1%
*-un-lft-identity57.1%
*-commutative57.1%
+-commutative57.1%
distribute-lft-neg-in57.1%
*-commutative57.1%
sub-neg57.1%
distribute-neg-in57.1%
+-commutative57.1%
*-un-lft-identity57.1%
distribute-lft-neg-in57.1%
distribute-lft-neg-in57.1%
metadata-eval57.1%
metadata-eval57.1%
*-un-lft-identity57.1%
metadata-eval57.1%
Applied egg-rr57.1%
Taylor expanded in y around inf 57.1%
associate-*r*99.9%
*-commutative99.9%
associate-*r*100.0%
Simplified100.0%
if -inf.0 < (*.f64 (-.f64 1 y) z) < 3.99999999999999993e296Initial program 99.9%
if 3.99999999999999993e296 < (*.f64 (-.f64 1 y) z) Initial program 66.6%
Taylor expanded in y around inf 66.6%
associate-*r*99.8%
*-commutative99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -5e+77) (+ x (/ z (/ (/ -1.0 (+ -1.0 y)) (- x)))) (* x (+ 1.0 (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e+77) {
tmp = x + (z / ((-1.0 / (-1.0 + y)) / -x));
} else {
tmp = x * (1.0 + (z * (-1.0 + 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 <= (-5d+77)) then
tmp = x + (z / (((-1.0d0) / ((-1.0d0) + y)) / -x))
else
tmp = x * (1.0d0 + (z * ((-1.0d0) + y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5e+77) {
tmp = x + (z / ((-1.0 / (-1.0 + y)) / -x));
} else {
tmp = x * (1.0 + (z * (-1.0 + y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e+77: tmp = x + (z / ((-1.0 / (-1.0 + y)) / -x)) else: tmp = x * (1.0 + (z * (-1.0 + y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e+77) tmp = Float64(x + Float64(z / Float64(Float64(-1.0 / Float64(-1.0 + y)) / Float64(-x)))); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(-1.0 + y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e+77) tmp = x + (z / ((-1.0 / (-1.0 + y)) / -x)); else tmp = x * (1.0 + (z * (-1.0 + y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e+77], N[(x + N[(z / N[(N[(-1.0 / N[(-1.0 + y), $MachinePrecision]), $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+77}:\\
\;\;\;\;x + \frac{z}{\frac{\frac{-1}{-1 + y}}{-x}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if z < -5.00000000000000004e77Initial program 77.1%
sub-neg77.1%
distribute-rgt-in77.1%
*-un-lft-identity77.1%
*-commutative77.1%
+-commutative77.1%
distribute-lft-neg-in77.1%
*-commutative77.1%
sub-neg77.1%
distribute-neg-in77.1%
+-commutative77.1%
*-un-lft-identity77.1%
distribute-lft-neg-in77.1%
distribute-lft-neg-in77.1%
metadata-eval77.1%
metadata-eval77.1%
*-un-lft-identity77.1%
metadata-eval77.1%
Applied egg-rr77.1%
associate-*r*99.9%
flip-+87.5%
associate-*r/79.2%
metadata-eval79.2%
fma-neg79.2%
metadata-eval79.2%
sub-neg79.2%
metadata-eval79.2%
Applied egg-rr79.2%
associate-/l*87.5%
Simplified87.5%
frac-2neg87.5%
distribute-frac-neg87.5%
clear-num87.5%
clear-num87.5%
distribute-neg-frac87.5%
metadata-eval87.5%
clear-num87.5%
fma-udef87.5%
difference-of-sqr--187.5%
difference-of-sqr-187.5%
metadata-eval87.5%
flip--99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
distribute-neg-frac99.9%
*-commutative99.9%
distribute-rgt-neg-out99.9%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
if -5.00000000000000004e77 < z Initial program 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= z -5e+77) (+ x (/ z (/ (/ 1.0 x) (+ -1.0 y)))) (* x (+ 1.0 (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e+77) {
tmp = x + (z / ((1.0 / x) / (-1.0 + y)));
} else {
tmp = x * (1.0 + (z * (-1.0 + 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 <= (-5d+77)) then
tmp = x + (z / ((1.0d0 / x) / ((-1.0d0) + y)))
else
tmp = x * (1.0d0 + (z * ((-1.0d0) + y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5e+77) {
tmp = x + (z / ((1.0 / x) / (-1.0 + y)));
} else {
tmp = x * (1.0 + (z * (-1.0 + y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e+77: tmp = x + (z / ((1.0 / x) / (-1.0 + y))) else: tmp = x * (1.0 + (z * (-1.0 + y))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e+77) tmp = Float64(x + Float64(z / Float64(Float64(1.0 / x) / Float64(-1.0 + y)))); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(-1.0 + y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e+77) tmp = x + (z / ((1.0 / x) / (-1.0 + y))); else tmp = x * (1.0 + (z * (-1.0 + y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e+77], N[(x + N[(z / N[(N[(1.0 / x), $MachinePrecision] / N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+77}:\\
\;\;\;\;x + \frac{z}{\frac{\frac{1}{x}}{-1 + y}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if z < -5.00000000000000004e77Initial program 77.1%
sub-neg77.1%
distribute-rgt-in77.1%
*-un-lft-identity77.1%
*-commutative77.1%
+-commutative77.1%
distribute-lft-neg-in77.1%
*-commutative77.1%
sub-neg77.1%
distribute-neg-in77.1%
+-commutative77.1%
*-un-lft-identity77.1%
distribute-lft-neg-in77.1%
distribute-lft-neg-in77.1%
metadata-eval77.1%
metadata-eval77.1%
*-un-lft-identity77.1%
metadata-eval77.1%
Applied egg-rr77.1%
associate-*r*99.9%
flip-+87.5%
associate-*r/79.2%
metadata-eval79.2%
fma-neg79.2%
metadata-eval79.2%
sub-neg79.2%
metadata-eval79.2%
Applied egg-rr79.2%
associate-/l*87.5%
Simplified87.5%
frac-2neg87.5%
distribute-frac-neg87.5%
clear-num87.5%
clear-num87.5%
distribute-neg-frac87.5%
metadata-eval87.5%
clear-num87.5%
fma-udef87.5%
difference-of-sqr--187.5%
difference-of-sqr-187.5%
metadata-eval87.5%
flip--99.9%
sub-neg99.9%
metadata-eval99.9%
Applied egg-rr99.9%
distribute-neg-frac99.9%
*-commutative99.9%
distribute-rgt-neg-out99.9%
associate-/l*99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in x around 0 99.6%
associate-/r*99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
if -5.00000000000000004e77 < z Initial program 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.2e+31) (not (<= z 1.0))) (* x (* z (+ -1.0 y))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.2e+31) || !(z <= 1.0)) {
tmp = x * (z * (-1.0 + y));
} else {
tmp = x * (1.0 + (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 <= (-2.2d+31)) .or. (.not. (z <= 1.0d0))) then
tmp = x * (z * ((-1.0d0) + y))
else
tmp = x * (1.0d0 + (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.2e+31) || !(z <= 1.0)) {
tmp = x * (z * (-1.0 + y));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.2e+31) or not (z <= 1.0): tmp = x * (z * (-1.0 + y)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.2e+31) || !(z <= 1.0)) tmp = Float64(x * Float64(z * Float64(-1.0 + y))); else tmp = Float64(x * Float64(1.0 + Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.2e+31) || ~((z <= 1.0))) tmp = x * (z * (-1.0 + y)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.2e+31], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+31} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(z \cdot \left(-1 + y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -2.2000000000000001e31 or 1 < z Initial program 90.6%
Taylor expanded in z around inf 90.5%
if -2.2000000000000001e31 < z < 1Initial program 99.9%
Taylor expanded in y around inf 99.3%
mul-1-neg99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
Simplified99.3%
sub-neg99.3%
+-commutative99.3%
distribute-rgt-neg-out99.3%
remove-double-neg99.3%
Applied egg-rr99.3%
Final simplification95.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e+14) (not (<= y 1.0))) (+ x (* y (* z x))) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+14) || !(y <= 1.0)) {
tmp = x + (y * (z * 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 <= (-3.4d+14)) .or. (.not. (y <= 1.0d0))) then
tmp = x + (y * (z * 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 <= -3.4e+14) || !(y <= 1.0)) {
tmp = x + (y * (z * x));
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+14) or not (y <= 1.0): tmp = x + (y * (z * x)) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+14) || !(y <= 1.0)) tmp = Float64(x + Float64(y * Float64(z * 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 <= -3.4e+14) || ~((y <= 1.0))) tmp = x + (y * (z * x)); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+14], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x + N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+14} \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x + y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.4e14 or 1 < y Initial program 89.6%
sub-neg89.6%
distribute-rgt-in89.6%
*-un-lft-identity89.6%
*-commutative89.6%
+-commutative89.6%
distribute-lft-neg-in89.6%
*-commutative89.6%
sub-neg89.6%
distribute-neg-in89.6%
+-commutative89.6%
*-un-lft-identity89.6%
distribute-lft-neg-in89.6%
distribute-lft-neg-in89.6%
metadata-eval89.6%
metadata-eval89.6%
*-un-lft-identity89.6%
metadata-eval89.6%
Applied egg-rr89.6%
Taylor expanded in y around inf 89.6%
associate-*r*87.1%
*-commutative87.1%
associate-*r*94.2%
Simplified94.2%
if -3.4e14 < y < 1Initial program 100.0%
Taylor expanded in y around 0 99.1%
Final simplification97.0%
(FPCore (x y z) :precision binary64 (if (<= y -2.12e+40) (* z (* y x)) (if (<= y 8e+146) (* x (- 1.0 z)) (* x (* z (+ -1.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.12e+40) {
tmp = z * (y * x);
} else if (y <= 8e+146) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * (-1.0 + 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 (y <= (-2.12d+40)) then
tmp = z * (y * x)
else if (y <= 8d+146) then
tmp = x * (1.0d0 - z)
else
tmp = x * (z * ((-1.0d0) + y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.12e+40) {
tmp = z * (y * x);
} else if (y <= 8e+146) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * (-1.0 + y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.12e+40: tmp = z * (y * x) elif y <= 8e+146: tmp = x * (1.0 - z) else: tmp = x * (z * (-1.0 + y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.12e+40) tmp = Float64(z * Float64(y * x)); elseif (y <= 8e+146) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(z * Float64(-1.0 + y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.12e+40) tmp = z * (y * x); elseif (y <= 8e+146) tmp = x * (1.0 - z); else tmp = x * (z * (-1.0 + y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.12e+40], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+146], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * N[(-1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.12 \cdot 10^{+40}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+146}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(-1 + y\right)\right)\\
\end{array}
\end{array}
if y < -2.11999999999999991e40Initial program 85.6%
Taylor expanded in y around inf 65.6%
associate-*r*74.0%
*-commutative74.0%
Simplified74.0%
if -2.11999999999999991e40 < y < 7.99999999999999947e146Initial program 98.9%
Taylor expanded in y around 0 91.9%
if 7.99999999999999947e146 < y Initial program 91.3%
Taylor expanded in z around inf 74.1%
Final simplification86.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.5e-14) (not (<= z 2.95e-22))) (* x (* z y)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e-14) || !(z <= 2.95e-22)) {
tmp = x * (z * y);
} 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 <= (-9.5d-14)) .or. (.not. (z <= 2.95d-22))) then
tmp = x * (z * y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -9.5e-14) || !(z <= 2.95e-22)) {
tmp = x * (z * y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.5e-14) or not (z <= 2.95e-22): tmp = x * (z * y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.5e-14) || !(z <= 2.95e-22)) tmp = Float64(x * Float64(z * y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.5e-14) || ~((z <= 2.95e-22))) tmp = x * (z * y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.5e-14], N[Not[LessEqual[z, 2.95e-22]], $MachinePrecision]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-14} \lor \neg \left(z \leq 2.95 \cdot 10^{-22}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9.4999999999999999e-14 or 2.95000000000000004e-22 < z Initial program 91.3%
Taylor expanded in y around inf 39.2%
*-commutative39.2%
Simplified39.2%
if -9.4999999999999999e-14 < z < 2.95000000000000004e-22Initial program 99.9%
Taylor expanded in z around 0 82.7%
Final simplification60.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.08e+40) (not (<= y 8e+146))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.08e+40) || !(y <= 8e+146)) {
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 <= (-1.08d+40)) .or. (.not. (y <= 8d+146))) 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 <= -1.08e+40) || !(y <= 8e+146)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.08e+40) or not (y <= 8e+146): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.08e+40) || !(y <= 8e+146)) 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 <= -1.08e+40) || ~((y <= 8e+146))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.08e+40], N[Not[LessEqual[y, 8e+146]], $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 -1.08 \cdot 10^{+40} \lor \neg \left(y \leq 8 \cdot 10^{+146}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.08000000000000001e40 or 7.99999999999999947e146 < y Initial program 87.9%
Taylor expanded in y around inf 69.1%
*-commutative69.1%
Simplified69.1%
if -1.08000000000000001e40 < y < 7.99999999999999947e146Initial program 98.9%
Taylor expanded in y around 0 91.9%
Final simplification84.9%
(FPCore (x y z) :precision binary64 (if (<= y -4.2e+39) (* z (* y x)) (if (<= y 5.8e+152) (* x (- 1.0 z)) (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+39) {
tmp = z * (y * x);
} else if (y <= 5.8e+152) {
tmp = x * (1.0 - z);
} 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) :: tmp
if (y <= (-4.2d+39)) then
tmp = z * (y * x)
else if (y <= 5.8d+152) then
tmp = x * (1.0d0 - z)
else
tmp = x * (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.2e+39) {
tmp = z * (y * x);
} else if (y <= 5.8e+152) {
tmp = x * (1.0 - z);
} else {
tmp = x * (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.2e+39: tmp = z * (y * x) elif y <= 5.8e+152: tmp = x * (1.0 - z) else: tmp = x * (z * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.2e+39) tmp = Float64(z * Float64(y * x)); elseif (y <= 5.8e+152) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.2e+39) tmp = z * (y * x); elseif (y <= 5.8e+152) tmp = x * (1.0 - z); else tmp = x * (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.2e+39], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.8e+152], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+39}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+152}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if y < -4.1999999999999997e39Initial program 85.6%
Taylor expanded in y around inf 65.6%
associate-*r*74.0%
*-commutative74.0%
Simplified74.0%
if -4.1999999999999997e39 < y < 5.7999999999999997e152Initial program 98.9%
Taylor expanded in y around 0 91.9%
if 5.7999999999999997e152 < y Initial program 91.3%
Taylor expanded in y around inf 74.1%
*-commutative74.1%
Simplified74.1%
Final simplification86.4%
(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 42.3%
Final simplification42.3%
(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 2023301
(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))))