
(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 13 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 (<= (* (- 1.0 y) z) -1e+308) (* z (* y x)) (+ x (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x + (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 (((1.0d0 - y) * z) <= (-1d+308)) then
tmp = z * (y * x)
else
tmp = x + (x * (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -1e+308: tmp = z * (y * x) else: tmp = x + (x * (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -1e+308) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -1e+308) tmp = z * (y * x); else tmp = x + (x * (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -1e+308], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -1 \cdot 10^{+308}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -1e308Initial program 60.4%
Taylor expanded in y around inf 60.4%
*-commutative60.4%
*-commutative60.4%
associate-*l*99.8%
Simplified99.8%
if -1e308 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 99.5%
Taylor expanded in z around 0 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -1e+308) (* z (* y x)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (((1.0d0 - y) * z) <= (-1d+308)) then
tmp = z * (y * x)
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -1e+308: tmp = z * (y * x) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -1e+308) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -1e+308) tmp = z * (y * x); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -1e+308], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -1 \cdot 10^{+308}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -1e308Initial program 60.4%
Taylor expanded in y around inf 60.4%
*-commutative60.4%
*-commutative60.4%
associate-*l*99.8%
Simplified99.8%
if -1e308 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.35e+19) (not (<= z 1.0))) (* (+ y -1.0) (* z x)) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.35e+19) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * 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 <= (-1.35d+19)) .or. (.not. (z <= 1.0d0))) then
tmp = (y + (-1.0d0)) * (z * 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 <= -1.35e+19) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.35e+19) or not (z <= 1.0): tmp = (y + -1.0) * (z * x) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.35e+19) || !(z <= 1.0)) tmp = Float64(Float64(y + -1.0) * Float64(z * 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 <= -1.35e+19) || ~((z <= 1.0))) tmp = (y + -1.0) * (z * x); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.35e+19], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+19} \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.35e19 or 1 < z Initial program 93.4%
Taylor expanded in z around inf 91.7%
associate-*r*98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
if -1.35e19 < z < 1Initial program 99.9%
Taylor expanded in y around inf 99.0%
neg-mul-199.0%
Simplified99.0%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 0.0115))) (+ x (* z (* y x))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.0115)) {
tmp = x + (z * (y * x));
} else {
tmp = x - (z * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.0d0)) .or. (.not. (y <= 0.0115d0))) then
tmp = x + (z * (y * x))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 0.0115)) {
tmp = x + (z * (y * x));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 0.0115): tmp = x + (z * (y * x)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 0.0115)) tmp = Float64(x + Float64(z * Float64(y * x))); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 0.0115))) tmp = x + (z * (y * x)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 0.0115]], $MachinePrecision]], N[(x + N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 0.0115\right):\\
\;\;\;\;x + z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -1 or 0.0115 < y Initial program 93.3%
Taylor expanded in z around 0 93.3%
Taylor expanded in y around inf 92.0%
associate-*r*92.7%
*-commutative92.7%
Simplified92.7%
if -1 < y < 0.0115Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 99.5%
mul-1-neg99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
Simplified99.5%
Taylor expanded in x around 0 99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
mul-1-neg99.5%
distribute-rgt-neg-in99.5%
sub-neg99.5%
Simplified99.5%
Final simplification96.1%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+29) (* z (* y x)) (if (<= y 1.0) (- x (* z x)) (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+29) {
tmp = z * (y * x);
} else if (y <= 1.0) {
tmp = x - (z * x);
} 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 (y <= (-7.2d+29)) then
tmp = z * (y * x)
else if (y <= 1.0d0) then
tmp = x - (z * x)
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 (y <= -7.2e+29) {
tmp = z * (y * x);
} else if (y <= 1.0) {
tmp = x - (z * x);
} else {
tmp = x * (z * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+29: tmp = z * (y * x) elif y <= 1.0: tmp = x - (z * x) else: tmp = x * (z * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+29) tmp = Float64(z * Float64(y * x)); elseif (y <= 1.0) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(z * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+29) tmp = z * (y * x); elseif (y <= 1.0) tmp = x - (z * x); else tmp = x * (z * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+29], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+29}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if y < -7.19999999999999952e29Initial program 85.7%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
*-commutative68.4%
associate-*l*78.9%
Simplified78.9%
if -7.19999999999999952e29 < y < 1Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.3%
*-rgt-identity98.3%
mul-1-neg98.3%
distribute-rgt-neg-in98.3%
sub-neg98.3%
Simplified98.3%
if 1 < y Initial program 98.4%
Taylor expanded in z around inf 81.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.2e+34) (not (<= y 55.0))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+34) || !(y <= 55.0)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-5.2d+34)) .or. (.not. (y <= 55.0d0))) then
tmp = z * (y * x)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+34) || !(y <= 55.0)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.2e+34) or not (y <= 55.0): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.2e+34) || !(y <= 55.0)) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.2e+34) || ~((y <= 55.0))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e+34], N[Not[LessEqual[y, 55.0]], $MachinePrecision]], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+34} \lor \neg \left(y \leq 55\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -5.19999999999999995e34 or 55 < y Initial program 92.7%
Taylor expanded in y around inf 75.3%
*-commutative75.3%
*-commutative75.3%
associate-*l*79.2%
Simplified79.2%
if -5.19999999999999995e34 < y < 55Initial program 100.0%
Taylor expanded in y around 0 98.2%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.9e+32) (* z (* y x)) (if (<= y 180.0) (- x (* z x)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+32) {
tmp = z * (y * x);
} else if (y <= 180.0) {
tmp = x - (z * x);
} else {
tmp = 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 (y <= (-1.9d+32)) then
tmp = z * (y * x)
else if (y <= 180.0d0) then
tmp = x - (z * x)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.9e+32) {
tmp = z * (y * x);
} else if (y <= 180.0) {
tmp = x - (z * x);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.9e+32: tmp = z * (y * x) elif y <= 180.0: tmp = x - (z * x) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.9e+32) tmp = Float64(z * Float64(y * x)); elseif (y <= 180.0) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.9e+32) tmp = z * (y * x); elseif (y <= 180.0) tmp = x - (z * x); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.9e+32], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 180.0], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.9 \cdot 10^{+32}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 180:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -1.9000000000000002e32Initial program 85.7%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
*-commutative68.4%
associate-*l*78.9%
Simplified78.9%
if -1.9000000000000002e32 < y < 180Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 98.3%
mul-1-neg98.3%
*-commutative98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
Taylor expanded in x around 0 98.2%
distribute-lft-in98.3%
*-rgt-identity98.3%
mul-1-neg98.3%
distribute-rgt-neg-in98.3%
sub-neg98.3%
Simplified98.3%
if 180 < y Initial program 98.4%
Taylor expanded in y around inf 80.9%
*-commutative80.9%
*-commutative80.9%
Simplified80.9%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -6.6e+33) (* z (* y x)) (if (<= y 190.0) (* x (- 1.0 z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.6e+33) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = 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 (y <= (-6.6d+33)) then
tmp = z * (y * x)
else if (y <= 190.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.6e+33) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.6e+33: tmp = z * (y * x) elif y <= 190.0: tmp = x * (1.0 - z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.6e+33) tmp = Float64(z * Float64(y * x)); elseif (y <= 190.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.6e+33) tmp = z * (y * x); elseif (y <= 190.0) tmp = x * (1.0 - z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.6e+33], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 190.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{+33}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 190:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -6.59999999999999953e33Initial program 85.7%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
*-commutative68.4%
associate-*l*78.9%
Simplified78.9%
if -6.59999999999999953e33 < y < 190Initial program 100.0%
Taylor expanded in y around 0 98.2%
if 190 < y Initial program 98.4%
Taylor expanded in y around inf 80.9%
*-commutative80.9%
*-commutative80.9%
Simplified80.9%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.05e+30) (* z (* y x)) (if (<= y 190.0) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+30) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.05d+30)) then
tmp = z * (y * x)
else if (y <= 190.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = y * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+30) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.05e+30: tmp = z * (y * x) elif y <= 190.0: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+30) tmp = Float64(z * Float64(y * x)); elseif (y <= 190.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.05e+30) tmp = z * (y * x); elseif (y <= 190.0) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+30], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 190.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+30}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 190:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -1.05e30Initial program 85.7%
Taylor expanded in y around inf 68.4%
*-commutative68.4%
*-commutative68.4%
associate-*l*78.9%
Simplified78.9%
if -1.05e30 < y < 190Initial program 100.0%
Taylor expanded in y around 0 98.2%
if 190 < y Initial program 98.4%
Taylor expanded in z around inf 81.8%
associate-*r*81.8%
*-commutative81.8%
sub-neg81.8%
metadata-eval81.8%
Simplified81.8%
Taylor expanded in y around inf 80.9%
Final simplification89.8%
(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 93.5%
Taylor expanded in z around inf 91.9%
Taylor expanded in y around 0 49.5%
mul-1-neg50.9%
*-commutative50.9%
distribute-rgt-neg-in50.9%
Simplified49.5%
if -1 < z < 1Initial program 99.8%
Taylor expanded in z around 0 76.5%
Final simplification62.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.3e+70) (not (<= z 52000000.0))) (* z x) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.3e+70) || !(z <= 52000000.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 <= (-2.3d+70)) .or. (.not. (z <= 52000000.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 <= -2.3e+70) || !(z <= 52000000.0)) {
tmp = z * x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.3e+70) or not (z <= 52000000.0): tmp = z * x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.3e+70) || !(z <= 52000000.0)) tmp = Float64(z * x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.3e+70) || ~((z <= 52000000.0))) tmp = z * x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.3e+70], N[Not[LessEqual[z, 52000000.0]], $MachinePrecision]], N[(z * x), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.3 \cdot 10^{+70} \lor \neg \left(z \leq 52000000\right):\\
\;\;\;\;z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.29999999999999994e70 or 5.2e7 < z Initial program 93.4%
Taylor expanded in z around inf 93.0%
associate-*r*99.5%
*-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
Simplified99.5%
distribute-lft-in78.5%
associate-*r*83.8%
*-commutative83.8%
add-cube-cbrt83.3%
unpow283.3%
associate-*r*83.3%
fma-undefine84.1%
associate-*l*84.1%
*-commutative84.1%
associate-*r*84.1%
neg-mul-184.1%
add-sqr-sqrt32.1%
sqrt-unprod55.7%
sqr-neg55.7%
sqrt-unprod29.4%
add-sqr-sqrt46.6%
Applied egg-rr46.6%
Taylor expanded in y around 0 14.1%
if -2.29999999999999994e70 < z < 5.2e7Initial program 99.2%
Taylor expanded in z around 0 67.3%
Final simplification43.6%
(FPCore (x y z) :precision binary64 (if (<= y 1.45e+165) (* x (- 1.0 z)) (* z x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e+165) {
tmp = x * (1.0 - z);
} else {
tmp = z * x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.45d+165) then
tmp = x * (1.0d0 - z)
else
tmp = z * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e+165) {
tmp = x * (1.0 - z);
} else {
tmp = z * x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.45e+165: tmp = x * (1.0 - z) else: tmp = z * x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.45e+165) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.45e+165) tmp = x * (1.0 - z); else tmp = z * x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.45e+165], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{+165}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot x\\
\end{array}
\end{array}
if y < 1.45000000000000003e165Initial program 96.2%
Taylor expanded in y around 0 70.7%
if 1.45000000000000003e165 < y Initial program 99.8%
Taylor expanded in z around inf 96.4%
associate-*r*92.9%
*-commutative92.9%
sub-neg92.9%
metadata-eval92.9%
Simplified92.9%
distribute-lft-in67.0%
associate-*r*63.8%
*-commutative63.8%
add-cube-cbrt63.0%
unpow263.0%
associate-*r*63.0%
fma-undefine63.0%
associate-*l*63.0%
*-commutative63.0%
associate-*r*63.0%
neg-mul-163.0%
add-sqr-sqrt40.3%
sqrt-unprod81.5%
sqr-neg81.5%
sqrt-unprod41.2%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in y around 0 29.3%
Final simplification66.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.6%
Taylor expanded in z around 0 38.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 2024158
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:alt
(! :herbie-platform default (if (< (* x (- 1 (* (- 1 y) z))) -161819597360704900000000000000000000000000000000000) (+ x (* (- 1 y) (* (- z) x))) (if (< (* x (- 1 (* (- 1 y) z))) 389223764966390300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1 y) (* (- z) x))))))
(* x (- 1.0 (* (- 1.0 y) z))))