
(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 (<= z 5e+16) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 5e+16) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (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 <= 5d+16) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = z * (x * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 5e+16) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 5e+16: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 5e+16) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 5e+16) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 5e+16], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{+16}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 5e16Initial program 98.5%
if 5e16 < z Initial program 88.5%
Taylor expanded in z around inf 88.5%
*-commutative88.5%
associate-*l*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -1.0)
t_0
(if (<= z 3.5e-14) x (if (<= z 3.4e+131) (* x (* z y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 3.5e-14) {
tmp = x;
} else if (z <= 3.4e+131) {
tmp = x * (z * y);
} else {
tmp = 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 = z * -x
if (z <= (-1.0d0)) then
tmp = t_0
else if (z <= 3.5d-14) then
tmp = x
else if (z <= 3.4d+131) then
tmp = x * (z * y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -1.0) {
tmp = t_0;
} else if (z <= 3.5e-14) {
tmp = x;
} else if (z <= 3.4e+131) {
tmp = x * (z * y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -1.0: tmp = t_0 elif z <= 3.5e-14: tmp = x elif z <= 3.4e+131: tmp = x * (z * y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -1.0) tmp = t_0; elseif (z <= 3.5e-14) tmp = x; elseif (z <= 3.4e+131) tmp = Float64(x * Float64(z * y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -1.0) tmp = t_0; elseif (z <= 3.5e-14) tmp = x; elseif (z <= 3.4e+131) tmp = x * (z * y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -1.0], t$95$0, If[LessEqual[z, 3.5e-14], x, If[LessEqual[z, 3.4e+131], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -1:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-14}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+131}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1 or 3.39999999999999986e131 < z Initial program 91.5%
sub-neg91.5%
distribute-rgt-neg-out91.5%
+-commutative91.5%
distribute-rgt-neg-out91.5%
*-commutative91.5%
distribute-rgt-neg-in91.5%
fma-define91.5%
neg-sub091.5%
associate--r-91.5%
metadata-eval91.5%
+-commutative91.5%
Simplified91.5%
fma-undefine91.5%
distribute-rgt-in91.5%
*-un-lft-identity91.5%
Applied egg-rr91.5%
Taylor expanded in z around 0 91.5%
sub-neg91.5%
metadata-eval91.5%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in y around 0 64.6%
mul-1-neg64.6%
sub-neg64.6%
Simplified64.6%
Taylor expanded in z around inf 63.7%
mul-1-neg63.7%
distribute-rgt-neg-out63.7%
Simplified63.7%
if -1 < z < 3.5000000000000002e-14Initial program 99.9%
Taylor expanded in z around 0 73.3%
if 3.5000000000000002e-14 < z < 3.39999999999999986e131Initial program 96.6%
Taylor expanded in y around inf 67.4%
*-commutative67.4%
Simplified67.4%
Final simplification68.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -0.95) (not (<= y 1.0))) (* x (+ 1.0 (* z y))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -0.95) || !(y <= 1.0)) {
tmp = x * (1.0 + (z * y));
} else {
tmp = x - (x * z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-0.95d0)) .or. (.not. (y <= 1.0d0))) then
tmp = x * (1.0d0 + (z * y))
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -0.95) || !(y <= 1.0)) {
tmp = x * (1.0 + (z * y));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -0.95) or not (y <= 1.0): tmp = x * (1.0 + (z * y)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -0.95) || !(y <= 1.0)) tmp = Float64(x * Float64(1.0 + Float64(z * y))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -0.95) || ~((y <= 1.0))) tmp = x * (1.0 + (z * y)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -0.95], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.95 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -0.94999999999999996 or 1 < y Initial program 91.9%
Taylor expanded in y around inf 91.8%
mul-1-neg91.8%
distribute-lft-neg-out91.8%
*-commutative91.8%
Simplified91.8%
sub-neg91.8%
distribute-rgt-neg-out91.8%
remove-double-neg91.8%
+-commutative91.8%
Applied egg-rr91.8%
if -0.94999999999999996 < y < 1Initial program 100.0%
sub-neg100.0%
distribute-rgt-neg-out100.0%
+-commutative100.0%
distribute-rgt-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
neg-sub0100.0%
associate--r-100.0%
metadata-eval100.0%
+-commutative100.0%
Simplified100.0%
fma-undefine100.0%
distribute-rgt-in100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 100.0%
sub-neg100.0%
metadata-eval100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in y around 0 99.1%
mul-1-neg99.1%
sub-neg99.1%
Simplified99.1%
Final simplification95.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} 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 <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
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 <= -1.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); 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 <= -1.0) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot y\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 92.5%
Taylor expanded in z around inf 91.2%
*-commutative91.2%
associate-*l*98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
Simplified98.7%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around inf 98.7%
mul-1-neg98.7%
distribute-lft-neg-out98.7%
*-commutative98.7%
Simplified98.7%
sub-neg98.7%
distribute-rgt-neg-out98.7%
remove-double-neg98.7%
+-commutative98.7%
Applied egg-rr98.7%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.06e+69) (not (<= y 17000000000.0))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.06e+69) || !(y <= 17000000000.0)) {
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.06d+69)) .or. (.not. (y <= 17000000000.0d0))) 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.06e+69) || !(y <= 17000000000.0)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.06e+69) or not (y <= 17000000000.0): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.06e+69) || !(y <= 17000000000.0)) 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.06e+69) || ~((y <= 17000000000.0))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.06e+69], N[Not[LessEqual[y, 17000000000.0]], $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.06 \cdot 10^{+69} \lor \neg \left(y \leq 17000000000\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1.06000000000000004e69 or 1.7e10 < y Initial program 92.0%
Taylor expanded in y around inf 70.1%
*-commutative70.1%
Simplified70.1%
if -1.06000000000000004e69 < y < 1.7e10Initial program 99.3%
Taylor expanded in y around 0 96.1%
Final simplification85.1%
(FPCore (x y z) :precision binary64 (if (<= y -6e+64) (* x (* z y)) (if (<= y 22000000000.0) (* x (- 1.0 z)) (* (* x z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+64) {
tmp = x * (z * y);
} else if (y <= 22000000000.0) {
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 <= (-6d+64)) then
tmp = x * (z * y)
else if (y <= 22000000000.0d0) 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 <= -6e+64) {
tmp = x * (z * y);
} else if (y <= 22000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = (x * z) * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e+64: tmp = x * (z * y) elif y <= 22000000000.0: tmp = x * (1.0 - z) else: tmp = (x * z) * y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e+64) tmp = Float64(x * Float64(z * y)); elseif (y <= 22000000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(x * z) * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e+64) tmp = x * (z * y); elseif (y <= 22000000000.0) tmp = x * (1.0 - z); else tmp = (x * z) * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e+64], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 22000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+64}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq 22000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot y\\
\end{array}
\end{array}
if y < -6.0000000000000004e64Initial program 94.1%
Taylor expanded in y around inf 71.0%
*-commutative71.0%
Simplified71.0%
if -6.0000000000000004e64 < y < 2.2e10Initial program 99.3%
Taylor expanded in y around 0 96.1%
if 2.2e10 < y Initial program 90.3%
Taylor expanded in y around inf 83.6%
+-commutative83.6%
associate-/l*92.1%
distribute-lft-out95.4%
Simplified95.4%
Taylor expanded in y around inf 75.6%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (<= y -5.3e+63) (* x (* z y)) (if (<= y 27000000000.0) (* x (- 1.0 z)) (* z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+63) {
tmp = x * (z * y);
} else if (y <= 27000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * 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 <= (-5.3d+63)) then
tmp = x * (z * y)
else if (y <= 27000000000.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = z * (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.3e+63) {
tmp = x * (z * y);
} else if (y <= 27000000000.0) {
tmp = x * (1.0 - z);
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.3e+63: tmp = x * (z * y) elif y <= 27000000000.0: tmp = x * (1.0 - z) else: tmp = z * (x * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.3e+63) tmp = Float64(x * Float64(z * y)); elseif (y <= 27000000000.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.3e+63) tmp = x * (z * y); elseif (y <= 27000000000.0) tmp = x * (1.0 - z); else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.3e+63], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 27000000000.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.3 \cdot 10^{+63}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq 27000000000:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -5.2999999999999999e63Initial program 94.1%
Taylor expanded in y around inf 71.0%
*-commutative71.0%
Simplified71.0%
if -5.2999999999999999e63 < y < 2.7e10Initial program 99.3%
Taylor expanded in y around 0 96.1%
if 2.7e10 < y Initial program 90.3%
Taylor expanded in y around inf 69.3%
associate-*r*77.2%
*-commutative77.2%
Simplified77.2%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e+65) (* x (* z y)) (if (<= y 25000000000.0) (- x (* x z)) (* z (* x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+65) {
tmp = x * (z * y);
} else if (y <= 25000000000.0) {
tmp = x - (x * z);
} else {
tmp = z * (x * 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.1d+65)) then
tmp = x * (z * y)
else if (y <= 25000000000.0d0) then
tmp = x - (x * z)
else
tmp = z * (x * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+65) {
tmp = x * (z * y);
} else if (y <= 25000000000.0) {
tmp = x - (x * z);
} else {
tmp = z * (x * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e+65: tmp = x * (z * y) elif y <= 25000000000.0: tmp = x - (x * z) else: tmp = z * (x * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e+65) tmp = Float64(x * Float64(z * y)); elseif (y <= 25000000000.0) tmp = Float64(x - Float64(x * z)); else tmp = Float64(z * Float64(x * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.1e+65) tmp = x * (z * y); elseif (y <= 25000000000.0) tmp = x - (x * z); else tmp = z * (x * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e+65], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 25000000000.0], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.1 \cdot 10^{+65}:\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{elif}\;y \leq 25000000000:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\end{array}
\end{array}
if y < -2.09999999999999991e65Initial program 94.1%
Taylor expanded in y around inf 71.0%
*-commutative71.0%
Simplified71.0%
if -2.09999999999999991e65 < y < 2.5e10Initial program 99.3%
sub-neg99.3%
distribute-rgt-neg-out99.3%
+-commutative99.3%
distribute-rgt-neg-out99.3%
*-commutative99.3%
distribute-rgt-neg-in99.3%
fma-define99.3%
neg-sub099.3%
associate--r-99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
fma-undefine99.3%
distribute-rgt-in99.3%
*-un-lft-identity99.3%
Applied egg-rr99.3%
Taylor expanded in z around 0 99.3%
sub-neg99.3%
metadata-eval99.3%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.1%
mul-1-neg96.1%
sub-neg96.1%
Simplified96.1%
if 2.5e10 < y Initial program 90.3%
Taylor expanded in y around inf 69.3%
associate-*r*77.2%
*-commutative77.2%
Simplified77.2%
Final simplification87.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
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 <= 1.0d0))) 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 <= 1.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) 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 <= 1.0))) 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, 1.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 92.5%
sub-neg92.5%
distribute-rgt-neg-out92.5%
+-commutative92.5%
distribute-rgt-neg-out92.5%
*-commutative92.5%
distribute-rgt-neg-in92.5%
fma-define92.5%
neg-sub092.5%
associate--r-92.5%
metadata-eval92.5%
+-commutative92.5%
Simplified92.5%
fma-undefine92.5%
distribute-rgt-in92.5%
*-un-lft-identity92.5%
Applied egg-rr92.5%
Taylor expanded in z around 0 92.5%
sub-neg92.5%
metadata-eval92.5%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in y around 0 58.0%
mul-1-neg58.0%
sub-neg58.0%
Simplified58.0%
Taylor expanded in z around inf 56.8%
mul-1-neg56.8%
distribute-rgt-neg-out56.8%
Simplified56.8%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 71.4%
Final simplification64.2%
(FPCore (x y z) :precision binary64 (- x (* (* x z) (- 1.0 y))))
double code(double x, double y, double z) {
return x - ((x * z) * (1.0 - y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x - ((x * z) * (1.0d0 - y))
end function
public static double code(double x, double y, double z) {
return x - ((x * z) * (1.0 - y));
}
def code(x, y, z): return x - ((x * z) * (1.0 - y))
function code(x, y, z) return Float64(x - Float64(Float64(x * z) * Float64(1.0 - y))) end
function tmp = code(x, y, z) tmp = x - ((x * z) * (1.0 - y)); end
code[x_, y_, z_] := N[(x - N[(N[(x * z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \left(x \cdot z\right) \cdot \left(1 - y\right)
\end{array}
Initial program 96.2%
sub-neg96.2%
distribute-rgt-neg-out96.2%
+-commutative96.2%
distribute-rgt-neg-out96.2%
*-commutative96.2%
distribute-rgt-neg-in96.2%
fma-define96.2%
neg-sub096.2%
associate--r-96.2%
metadata-eval96.2%
+-commutative96.2%
Simplified96.2%
fma-undefine96.2%
distribute-rgt-in96.3%
*-un-lft-identity96.3%
Applied egg-rr96.3%
Taylor expanded in z around 0 96.3%
sub-neg96.3%
metadata-eval96.3%
associate-*r*97.3%
Simplified97.3%
Final simplification97.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 96.2%
Taylor expanded in z around 0 38.1%
Final simplification38.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))
(t_1 (+ x (* (- 1.0 y) (* (- z) x)))))
(if (< t_0 -1.618195973607049e+50)
t_1
(if (< t_0 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) t_1))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
t_1 = x + ((1.0d0 - y) * (-z * x))
if (t_0 < (-1.618195973607049d+50)) then
tmp = t_1
else if (t_0 < 3.892237649663903d+134) then
tmp = ((x * y) * z) - ((x * z) - x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double t_1 = x + ((1.0 - y) * (-z * x));
double tmp;
if (t_0 < -1.618195973607049e+50) {
tmp = t_1;
} else if (t_0 < 3.892237649663903e+134) {
tmp = ((x * y) * z) - ((x * z) - x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) t_1 = x + ((1.0 - y) * (-z * x)) tmp = 0 if t_0 < -1.618195973607049e+50: tmp = t_1 elif t_0 < 3.892237649663903e+134: tmp = ((x * y) * z) - ((x * z) - x) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) t_1 = Float64(x + Float64(Float64(1.0 - y) * Float64(Float64(-z) * x))) tmp = 0.0 if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = Float64(Float64(Float64(x * y) * z) - Float64(Float64(x * z) - x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); t_1 = x + ((1.0 - y) * (-z * x)); tmp = 0.0; if (t_0 < -1.618195973607049e+50) tmp = t_1; elseif (t_0 < 3.892237649663903e+134) tmp = ((x * y) * z) - ((x * z) - x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(N[(1.0 - y), $MachinePrecision] * N[((-z) * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$0, -1.618195973607049e+50], t$95$1, If[Less[t$95$0, 3.892237649663903e+134], N[(N[(N[(x * y), $MachinePrecision] * z), $MachinePrecision] - N[(N[(x * z), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_1 := x + \left(1 - y\right) \cdot \left(\left(-z\right) \cdot x\right)\\
\mathbf{if}\;t\_0 < -1.618195973607049 \cdot 10^{+50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 < 3.892237649663903 \cdot 10^{+134}:\\
\;\;\;\;\left(x \cdot y\right) \cdot z - \left(x \cdot z - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024067
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(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))))