
(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 (* (- 1.0 y) z)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+307)))
(* z (* y x))
(+ x (* x (* z (+ y -1.0)))))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+307)) {
tmp = z * (y * x);
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e+307)) {
tmp = z * (y * x);
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e+307): tmp = z * (y * x) else: tmp = x + (x * (z * (y + -1.0))) return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+307)) 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) t_0 = (1.0 - y) * z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e+307))) tmp = z * (y * x); else tmp = x + (x * (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+307]], $MachinePrecision]], 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}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 10^{+307}\right):\\
\;\;\;\;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) < -inf.0 or 9.99999999999999986e306 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 69.7%
Taylor expanded in y around inf 69.7%
*-commutative69.7%
*-commutative69.7%
associate-*l*99.9%
Simplified99.9%
if -inf.0 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999986e306Initial program 99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (- 1.0 y) z)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 1e+307)))
(* z (* y x))
(* x (+ 1.0 (* z (+ y -1.0)))))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 1e+307)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 1e+307)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 1e+307): tmp = z * (y * x) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 1e+307)) 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) t_0 = (1.0 - y) * z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 1e+307))) tmp = z * (y * x); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 1e+307]], $MachinePrecision]], 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}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 10^{+307}\right):\\
\;\;\;\;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) < -inf.0 or 9.99999999999999986e306 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 69.7%
Taylor expanded in y around inf 69.7%
*-commutative69.7%
*-commutative69.7%
associate-*l*99.9%
Simplified99.9%
if -inf.0 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 9.99999999999999986e306Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.9) (not (<= z 0.0115))) (* (* z x) (+ y -1.0)) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9) || !(z <= 0.0115)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.9d0)) .or. (.not. (z <= 0.0115d0))) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x + (x * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.9) || !(z <= 0.0115)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.9) or not (z <= 0.0115): tmp = (z * x) * (y + -1.0) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.9) || !(z <= 0.0115)) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x + Float64(x * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.9) || ~((z <= 0.0115))) tmp = (z * x) * (y + -1.0); else tmp = x + (x * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.9], N[Not[LessEqual[z, 0.0115]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \lor \neg \left(z \leq 0.0115\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -1.8999999999999999 or 0.0115 < z Initial program 91.8%
Taylor expanded in z around inf 91.3%
associate-*r*99.4%
*-commutative99.4%
sub-neg99.4%
metadata-eval99.4%
Simplified99.4%
if -1.8999999999999999 < z < 0.0115Initial program 99.8%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.6e-66) (not (<= z 5.5e-11))) (* (* z x) (+ y -1.0)) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-66) || !(z <= 5.5e-11)) {
tmp = (z * x) * (y + -1.0);
} 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 ((z <= (-5.6d-66)) .or. (.not. (z <= 5.5d-11))) then
tmp = (z * x) * (y + (-1.0d0))
else
tmp = x - (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-66) || !(z <= 5.5e-11)) {
tmp = (z * x) * (y + -1.0);
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.6e-66) or not (z <= 5.5e-11): tmp = (z * x) * (y + -1.0) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.6e-66) || !(z <= 5.5e-11)) tmp = Float64(Float64(z * x) * Float64(y + -1.0)); else tmp = Float64(x - Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.6e-66) || ~((z <= 5.5e-11))) tmp = (z * x) * (y + -1.0); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.6e-66], N[Not[LessEqual[z, 5.5e-11]], $MachinePrecision]], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-66} \lor \neg \left(z \leq 5.5 \cdot 10^{-11}\right):\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if z < -5.6000000000000001e-66 or 5.49999999999999975e-11 < z Initial program 92.5%
Taylor expanded in z around inf 89.0%
associate-*r*95.8%
*-commutative95.8%
sub-neg95.8%
metadata-eval95.8%
Simplified95.8%
if -5.6000000000000001e-66 < z < 5.49999999999999975e-11Initial program 99.8%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around 0 75.6%
mul-1-neg75.6%
*-commutative75.6%
distribute-rgt-neg-in75.6%
Simplified75.6%
add-cube-cbrt74.3%
fma-define74.3%
distribute-rgt-neg-out74.3%
add-sqr-sqrt46.8%
sqrt-unprod71.6%
sqr-neg71.6%
distribute-rgt-neg-out71.6%
distribute-rgt-neg-out71.6%
sqrt-unprod46.6%
add-sqr-sqrt74.0%
*-commutative74.0%
*-commutative74.0%
fmm-def74.0%
add-cube-cbrt75.4%
add-sqr-sqrt47.6%
sqrt-unprod72.9%
distribute-rgt-neg-out72.9%
distribute-rgt-neg-out72.9%
Applied egg-rr75.6%
Final simplification87.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -21000.0) (not (<= y 1.12e+36))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -21000.0) || !(y <= 1.12e+36)) {
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 <= (-21000.0d0)) .or. (.not. (y <= 1.12d+36))) 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 <= -21000.0) || !(y <= 1.12e+36)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -21000.0) or not (y <= 1.12e+36): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -21000.0) || !(y <= 1.12e+36)) 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 <= -21000.0) || ~((y <= 1.12e+36))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -21000.0], N[Not[LessEqual[y, 1.12e+36]], $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 -21000 \lor \neg \left(y \leq 1.12 \cdot 10^{+36}\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -21000 or 1.11999999999999999e36 < y Initial program 91.6%
Taylor expanded in y around inf 70.2%
*-commutative70.2%
*-commutative70.2%
associate-*l*74.6%
Simplified74.6%
if -21000 < y < 1.11999999999999999e36Initial program 100.0%
Taylor expanded in y around 0 97.8%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= y -21000.0) (* z (* y x)) (if (<= y 1.1e+36) (- x (* z x)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -21000.0) {
tmp = z * (y * x);
} else if (y <= 1.1e+36) {
tmp = x - (z * x);
} 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 <= (-21000.0d0)) then
tmp = z * (y * x)
else if (y <= 1.1d+36) then
tmp = x - (z * x)
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 <= -21000.0) {
tmp = z * (y * x);
} else if (y <= 1.1e+36) {
tmp = x - (z * x);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -21000.0: tmp = z * (y * x) elif y <= 1.1e+36: tmp = x - (z * x) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -21000.0) tmp = Float64(z * Float64(y * x)); elseif (y <= 1.1e+36) tmp = Float64(x - Float64(z * x)); else tmp = Float64(y * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -21000.0) tmp = z * (y * x); elseif (y <= 1.1e+36) tmp = x - (z * x); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -21000.0], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+36], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -21000:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+36}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -21000Initial program 90.1%
Taylor expanded in y around inf 74.2%
*-commutative74.2%
*-commutative74.2%
associate-*l*80.1%
Simplified80.1%
if -21000 < y < 1.1e36Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 97.8%
mul-1-neg97.8%
*-commutative97.8%
distribute-rgt-neg-in97.8%
Simplified97.8%
add-cube-cbrt97.0%
fma-define97.0%
distribute-rgt-neg-out97.0%
add-sqr-sqrt59.2%
sqrt-unprod60.0%
sqr-neg60.0%
distribute-rgt-neg-out60.0%
distribute-rgt-neg-out60.0%
sqrt-unprod25.1%
add-sqr-sqrt45.1%
*-commutative45.1%
*-commutative45.1%
fmm-def45.1%
add-cube-cbrt45.9%
add-sqr-sqrt25.7%
sqrt-unprod60.8%
distribute-rgt-neg-out60.8%
distribute-rgt-neg-out60.8%
Applied egg-rr97.8%
if 1.1e36 < y Initial program 93.0%
Taylor expanded in z around inf 66.3%
associate-*r*71.4%
*-commutative71.4%
sub-neg71.4%
metadata-eval71.4%
Simplified71.4%
Taylor expanded in y around inf 71.4%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (if (<= y -21000.0) (* z (* y x)) (if (<= y 3.35e+38) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -21000.0) {
tmp = z * (y * x);
} else if (y <= 3.35e+38) {
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 <= (-21000.0d0)) then
tmp = z * (y * x)
else if (y <= 3.35d+38) 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 <= -21000.0) {
tmp = z * (y * x);
} else if (y <= 3.35e+38) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -21000.0: tmp = z * (y * x) elif y <= 3.35e+38: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -21000.0) tmp = Float64(z * Float64(y * x)); elseif (y <= 3.35e+38) 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 <= -21000.0) tmp = z * (y * x); elseif (y <= 3.35e+38) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -21000.0], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.35e+38], 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 -21000:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 3.35 \cdot 10^{+38}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -21000Initial program 90.1%
Taylor expanded in y around inf 74.2%
*-commutative74.2%
*-commutative74.2%
associate-*l*80.1%
Simplified80.1%
if -21000 < y < 3.35000000000000012e38Initial program 100.0%
Taylor expanded in y around 0 97.8%
if 3.35000000000000012e38 < y Initial program 93.0%
Taylor expanded in z around inf 66.3%
associate-*r*71.4%
*-commutative71.4%
sub-neg71.4%
metadata-eval71.4%
Simplified71.4%
Taylor expanded in y around inf 71.4%
Final simplification86.1%
(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.8%
Taylor expanded in z around inf 91.3%
Taylor expanded in y around 0 53.1%
mul-1-neg53.6%
*-commutative53.6%
distribute-rgt-neg-in53.6%
Simplified53.1%
if -1 < z < 1Initial program 99.8%
Taylor expanded in z around 0 70.5%
Final simplification61.1%
(FPCore (x y z) :precision binary64 (* x (- 1.0 z)))
double code(double x, double y, double z) {
return x * (1.0 - 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 - z)
end function
public static double code(double x, double y, double z) {
return x * (1.0 - z);
}
def code(x, y, z): return x * (1.0 - z)
function code(x, y, z) return Float64(x * Float64(1.0 - z)) end
function tmp = code(x, y, z) tmp = x * (1.0 - z); end
code[x_, y_, z_] := N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - z\right)
\end{array}
Initial program 95.5%
Taylor expanded in y around 0 61.8%
(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 34.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 2024181
(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))))