
(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 (let* ((t_0 (* x (+ 1.0 (* z (+ y -1.0)))))) (if (<= t_0 1e+306) t_0 (* z (- (* x y) x)))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= 1e+306) {
tmp = t_0;
} else {
tmp = z * ((x * y) - 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 = x * (1.0d0 + (z * (y + (-1.0d0))))
if (t_0 <= 1d+306) then
tmp = t_0
else
tmp = z * ((x * y) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (1.0 + (z * (y + -1.0)));
double tmp;
if (t_0 <= 1e+306) {
tmp = t_0;
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 + (z * (y + -1.0))) tmp = 0 if t_0 <= 1e+306: tmp = t_0 else: tmp = z * ((x * y) - x) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))) tmp = 0.0 if (t_0 <= 1e+306) tmp = t_0; else tmp = Float64(z * Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 + (z * (y + -1.0))); tmp = 0.0; if (t_0 <= 1e+306) tmp = t_0; else tmp = z * ((x * y) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+306], t$95$0, N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{if}\;t_0 \leq 10^{+306}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 1.00000000000000002e306Initial program 98.2%
if 1.00000000000000002e306 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 76.9%
Taylor expanded in y around 0 68.5%
Taylor expanded in z around inf 100.0%
+-commutative100.0%
mul-1-neg100.0%
unsub-neg100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -57000.0) (not (<= z 1.0))) (* z (- (* x y) x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -57000.0) || !(z <= 1.0)) {
tmp = z * ((x * y) - x);
} else {
tmp = x * (1.0 + (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 <= (-57000.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * ((x * y) - x)
else
tmp = x * (1.0d0 + (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -57000.0) || !(z <= 1.0)) {
tmp = z * ((x * y) - x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -57000.0) or not (z <= 1.0): tmp = z * ((x * y) - x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -57000.0) || !(z <= 1.0)) tmp = Float64(z * Float64(Float64(x * y) - x)); else tmp = Float64(x * Float64(1.0 + Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -57000.0) || ~((z <= 1.0))) tmp = z * ((x * y) - x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -57000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -57000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -57000 or 1 < z Initial program 90.9%
Taylor expanded in y around 0 85.6%
Taylor expanded in z around inf 98.7%
+-commutative98.7%
mul-1-neg98.7%
unsub-neg98.7%
*-commutative98.7%
Applied egg-rr98.7%
if -57000 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 97.7%
*-commutative97.7%
Simplified97.7%
*-commutative97.7%
*-commutative97.7%
distribute-rgt1-in97.7%
Applied egg-rr97.7%
Final simplification98.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.65e+32) (* z (* x y)) (if (<= y 7.4) (- x (* x z)) (* z (- (* x y) x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+32) {
tmp = z * (x * y);
} else if (y <= 7.4) {
tmp = x - (x * z);
} else {
tmp = z * ((x * y) - 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 (y <= (-1.65d+32)) then
tmp = z * (x * y)
else if (y <= 7.4d0) then
tmp = x - (x * z)
else
tmp = z * ((x * y) - x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+32) {
tmp = z * (x * y);
} else if (y <= 7.4) {
tmp = x - (x * z);
} else {
tmp = z * ((x * y) - x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.65e+32: tmp = z * (x * y) elif y <= 7.4: tmp = x - (x * z) else: tmp = z * ((x * y) - x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.65e+32) tmp = Float64(z * Float64(x * y)); elseif (y <= 7.4) tmp = Float64(x - Float64(x * z)); else tmp = Float64(z * Float64(Float64(x * y) - x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.65e+32) tmp = z * (x * y); elseif (y <= 7.4) tmp = x - (x * z); else tmp = z * ((x * y) - x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.65e+32], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.4], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+32}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;y \leq 7.4:\\
\;\;\;\;x - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\end{array}
\end{array}
if y < -1.6500000000000001e32Initial program 84.6%
Taylor expanded in y around inf 74.5%
associate-*r*85.9%
*-commutative85.9%
Simplified85.9%
if -1.6500000000000001e32 < y < 7.4000000000000004Initial program 100.0%
Taylor expanded in y around 0 97.8%
sub-neg97.8%
distribute-rgt-in97.8%
*-un-lft-identity97.8%
*-commutative97.8%
distribute-rgt-neg-out97.8%
unsub-neg97.8%
Applied egg-rr97.8%
if 7.4000000000000004 < y Initial program 92.8%
Taylor expanded in y around 0 83.7%
Taylor expanded in z around inf 78.1%
+-commutative78.1%
mul-1-neg78.1%
unsub-neg78.1%
*-commutative78.1%
Applied egg-rr78.1%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (<= z -57000.0) (* z (- (* x y) x)) (if (<= z 1.0) (* x (+ 1.0 (* y z))) (* (* x z) (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -57000.0) {
tmp = z * ((x * y) - x);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = (x * z) * (y + -1.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-57000.0d0)) then
tmp = z * ((x * y) - x)
else if (z <= 1.0d0) then
tmp = x * (1.0d0 + (y * z))
else
tmp = (x * z) * (y + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -57000.0) {
tmp = z * ((x * y) - x);
} else if (z <= 1.0) {
tmp = x * (1.0 + (y * z));
} else {
tmp = (x * z) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -57000.0: tmp = z * ((x * y) - x) elif z <= 1.0: tmp = x * (1.0 + (y * z)) else: tmp = (x * z) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -57000.0) tmp = Float64(z * Float64(Float64(x * y) - x)); elseif (z <= 1.0) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(Float64(x * z) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -57000.0) tmp = z * ((x * y) - x); elseif (z <= 1.0) tmp = x * (1.0 + (y * z)); else tmp = (x * z) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -57000.0], N[(z * N[(N[(x * y), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -57000:\\
\;\;\;\;z \cdot \left(x \cdot y - x\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot z\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if z < -57000Initial program 92.1%
Taylor expanded in y around 0 87.0%
Taylor expanded in z around inf 97.8%
+-commutative97.8%
mul-1-neg97.8%
unsub-neg97.8%
*-commutative97.8%
Applied egg-rr97.8%
if -57000 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 97.7%
*-commutative97.7%
Simplified97.7%
*-commutative97.7%
*-commutative97.7%
distribute-rgt1-in97.7%
Applied egg-rr97.7%
if 1 < z Initial program 89.9%
add-cbrt-cube58.5%
pow358.5%
sub-neg58.5%
+-commutative58.5%
distribute-rgt-neg-in58.5%
fma-def58.5%
Applied egg-rr58.5%
Taylor expanded in z around inf 89.4%
*-commutative89.4%
associate-*r*89.4%
*-commutative89.4%
associate-*r*89.4%
associate-*r*99.5%
mul-1-neg99.5%
Simplified99.5%
Final simplification98.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))))
(if (<= z -3.8e+194)
t_0
(if (<= z -3e-23) (* x (* y z)) (if (<= z 1.0) x t_0)))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double tmp;
if (z <= -3.8e+194) {
tmp = t_0;
} else if (z <= -3e-23) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} 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 <= (-3.8d+194)) then
tmp = t_0
else if (z <= (-3d-23)) then
tmp = x * (y * z)
else if (z <= 1.0d0) then
tmp = x
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 <= -3.8e+194) {
tmp = t_0;
} else if (z <= -3e-23) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x tmp = 0 if z <= -3.8e+194: tmp = t_0 elif z <= -3e-23: tmp = x * (y * z) elif z <= 1.0: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) tmp = 0.0 if (z <= -3.8e+194) tmp = t_0; elseif (z <= -3e-23) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.0) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; tmp = 0.0; if (z <= -3.8e+194) tmp = t_0; elseif (z <= -3e-23) tmp = x * (y * z); elseif (z <= 1.0) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, If[LessEqual[z, -3.8e+194], t$95$0, If[LessEqual[z, -3e-23], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], x, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
\mathbf{if}\;z \leq -3.8 \cdot 10^{+194}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3 \cdot 10^{-23}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3.7999999999999999e194 or 1 < z Initial program 88.7%
Taylor expanded in y around 0 61.8%
Taylor expanded in z around inf 61.5%
associate-*r*61.5%
neg-mul-161.5%
Simplified61.5%
if -3.7999999999999999e194 < z < -3.00000000000000003e-23Initial program 97.6%
Taylor expanded in y around inf 59.0%
*-commutative59.0%
Simplified59.0%
if -3.00000000000000003e-23 < z < 1Initial program 99.9%
Taylor expanded in z around 0 74.5%
Final simplification67.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.6e+31) (not (<= y 12.0))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.6e+31) || !(y <= 12.0)) {
tmp = x * (y * 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 <= (-3.6d+31)) .or. (.not. (y <= 12.0d0))) then
tmp = x * (y * 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 <= -3.6e+31) || !(y <= 12.0)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.6e+31) or not (y <= 12.0): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.6e+31) || !(y <= 12.0)) tmp = Float64(x * Float64(y * 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 <= -3.6e+31) || ~((y <= 12.0))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.6e+31], N[Not[LessEqual[y, 12.0]], $MachinePrecision]], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+31} \lor \neg \left(y \leq 12\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -3.59999999999999996e31 or 12 < y Initial program 89.3%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
Simplified72.8%
if -3.59999999999999996e31 < y < 12Initial program 100.0%
Taylor expanded in y around 0 97.8%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+33) (not (<= y 6.6))) (* y (* x z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+33) || !(y <= 6.6)) {
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 <= (-4.8d+33)) .or. (.not. (y <= 6.6d0))) 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 <= -4.8e+33) || !(y <= 6.6)) {
tmp = y * (x * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.8e+33) or not (y <= 6.6): tmp = y * (x * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.8e+33) || !(y <= 6.6)) 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 <= -4.8e+33) || ~((y <= 6.6))) tmp = y * (x * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.8e+33], N[Not[LessEqual[y, 6.6]], $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 -4.8 \cdot 10^{+33} \lor \neg \left(y \leq 6.6\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -4.8e33 or 6.5999999999999996 < y Initial program 89.3%
Taylor expanded in y around 0 84.0%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
associate-*l*77.9%
*-commutative77.9%
Simplified77.9%
if -4.8e33 < y < 6.5999999999999996Initial program 100.0%
Taylor expanded in y around 0 97.8%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e+33) (not (<= y 10.2))) (* z (* x y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+33) || !(y <= 10.2)) {
tmp = z * (x * 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 <= (-6.2d+33)) .or. (.not. (y <= 10.2d0))) then
tmp = z * (x * 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 <= -6.2e+33) || !(y <= 10.2)) {
tmp = z * (x * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e+33) or not (y <= 10.2): tmp = z * (x * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e+33) || !(y <= 10.2)) tmp = Float64(z * Float64(x * 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 <= -6.2e+33) || ~((y <= 10.2))) tmp = z * (x * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e+33], N[Not[LessEqual[y, 10.2]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+33} \lor \neg \left(y \leq 10.2\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -6.2e33 or 10.199999999999999 < y Initial program 89.3%
Taylor expanded in y around inf 72.8%
associate-*r*80.8%
*-commutative80.8%
Simplified80.8%
if -6.2e33 < y < 10.199999999999999Initial program 100.0%
Taylor expanded in y around 0 97.8%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.1e+31) (not (<= y 14.5))) (* z (* x y)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e+31) || !(y <= 14.5)) {
tmp = z * (x * 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 <= (-1.1d+31)) .or. (.not. (y <= 14.5d0))) then
tmp = z * (x * 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 <= -1.1e+31) || !(y <= 14.5)) {
tmp = z * (x * y);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.1e+31) or not (y <= 14.5): tmp = z * (x * y) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.1e+31) || !(y <= 14.5)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.1e+31) || ~((y <= 14.5))) tmp = z * (x * y); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.1e+31], N[Not[LessEqual[y, 14.5]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+31} \lor \neg \left(y \leq 14.5\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -1.10000000000000005e31 or 14.5 < y Initial program 89.3%
Taylor expanded in y around inf 72.8%
associate-*r*80.8%
*-commutative80.8%
Simplified80.8%
if -1.10000000000000005e31 < y < 14.5Initial program 100.0%
Taylor expanded in y around 0 97.8%
sub-neg97.8%
distribute-rgt-in97.8%
*-un-lft-identity97.8%
*-commutative97.8%
distribute-rgt-neg-out97.8%
unsub-neg97.8%
Applied egg-rr97.8%
Final simplification90.2%
(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 91.0%
Taylor expanded in y around 0 55.7%
Taylor expanded in z around inf 54.7%
associate-*r*54.7%
neg-mul-154.7%
Simplified54.7%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 72.1%
Final simplification63.0%
(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.2%
Taylor expanded in z around 0 35.7%
Final simplification35.7%
(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 2023320
(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))))