
(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 12 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 500000000000.0) (- x (* x (- z (* y z)))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 500000000000.0) {
tmp = x - (x * (z - (y * z)));
} 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 <= 500000000000.0d0) then
tmp = x - (x * (z - (y * z)))
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 <= 500000000000.0) {
tmp = x - (x * (z - (y * z)));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 500000000000.0: tmp = x - (x * (z - (y * z))) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 500000000000.0) tmp = Float64(x - Float64(x * Float64(z - Float64(y * z)))); 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 <= 500000000000.0) tmp = x - (x * (z - (y * z))); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 500000000000.0], N[(x - N[(x * N[(z - N[(y * z), $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 500000000000:\\
\;\;\;\;x - x \cdot \left(z - y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 5e11Initial program 98.9%
Taylor expanded in z around 0 98.9%
sub-neg98.9%
distribute-rgt-in98.9%
*-commutative98.9%
metadata-eval98.9%
neg-mul-198.9%
Applied egg-rr98.9%
Taylor expanded in x around 0 98.9%
if 5e11 < z Initial program 89.9%
Taylor expanded in z around inf 89.9%
*-commutative89.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -5300000000000.0) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (+ x (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5300000000000.0) || !(z <= 1.0)) {
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 <= (-5300000000000.0d0)) .or. (.not. (z <= 1.0d0))) 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 <= -5300000000000.0) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x + (x * (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5300000000000.0) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x + (x * (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5300000000000.0) || !(z <= 1.0)) tmp = Float64(z * Float64(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 <= -5300000000000.0) || ~((z <= 1.0))) 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, -5300000000000.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5300000000000 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if z < -5.3e12 or 1 < z Initial program 93.3%
Taylor expanded in z around inf 93.3%
*-commutative93.3%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -5.3e12 < z < 1Initial program 99.8%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.0%
*-commutative98.0%
Simplified98.0%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.000122) (not (<= z 0.00015))) (* z (* x (+ y -1.0))) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.000122) || !(z <= 0.00015)) {
tmp = z * (x * (y + -1.0));
} 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 ((z <= (-0.000122d0)) .or. (.not. (z <= 0.00015d0))) then
tmp = z * (x * (y + (-1.0d0)))
else
tmp = x - (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.000122) || !(z <= 0.00015)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.000122) or not (z <= 0.00015): tmp = z * (x * (y + -1.0)) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.000122) || !(z <= 0.00015)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.000122) || ~((z <= 0.00015))) tmp = z * (x * (y + -1.0)); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.000122], N[Not[LessEqual[z, 0.00015]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.000122 \lor \neg \left(z \leq 0.00015\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if z < -1.21999999999999997e-4 or 1.49999999999999987e-4 < z Initial program 93.4%
Taylor expanded in z around inf 93.4%
*-commutative93.4%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
if -1.21999999999999997e-4 < z < 1.49999999999999987e-4Initial program 99.9%
Taylor expanded in z around 0 99.9%
add-cube-cbrt99.7%
pow399.7%
associate-*r*96.7%
*-commutative96.7%
sub-neg96.7%
metadata-eval96.7%
Applied egg-rr96.7%
Taylor expanded in y around 0 77.9%
mul-1-neg77.9%
unsub-neg77.9%
Simplified77.9%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2e+15) (not (<= y 7.6e+17))) (* y (* x z)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2e+15) || !(y <= 7.6e+17)) {
tmp = y * (x * z);
} 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 <= (-2d+15)) .or. (.not. (y <= 7.6d+17))) then
tmp = y * (x * z)
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 <= -2e+15) || !(y <= 7.6e+17)) {
tmp = y * (x * z);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2e+15) or not (y <= 7.6e+17): tmp = y * (x * z) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2e+15) || !(y <= 7.6e+17)) tmp = Float64(y * Float64(x * z)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2e+15) || ~((y <= 7.6e+17))) tmp = y * (x * z); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2e+15], N[Not[LessEqual[y, 7.6e+17]], $MachinePrecision]], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+15} \lor \neg \left(y \leq 7.6 \cdot 10^{+17}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -2e15 or 7.6e17 < y Initial program 92.6%
Taylor expanded in y around inf 87.5%
Taylor expanded in y around inf 77.6%
if -2e15 < y < 7.6e17Initial program 100.0%
Taylor expanded in z around 0 100.0%
add-cube-cbrt99.3%
pow399.4%
associate-*r*99.3%
*-commutative99.3%
sub-neg99.3%
metadata-eval99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 97.0%
mul-1-neg97.0%
unsub-neg97.0%
Simplified97.0%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+14) (not (<= y 3.4e+18))) (* y (* x z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+14) || !(y <= 3.4e+18)) {
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 <= (-2.8d+14)) .or. (.not. (y <= 3.4d+18))) 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 <= -2.8e+14) || !(y <= 3.4e+18)) {
tmp = y * (x * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.8e+14) or not (y <= 3.4e+18): tmp = y * (x * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+14) || !(y <= 3.4e+18)) 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 <= -2.8e+14) || ~((y <= 3.4e+18))) tmp = y * (x * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+14], N[Not[LessEqual[y, 3.4e+18]], $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 -2.8 \cdot 10^{+14} \lor \neg \left(y \leq 3.4 \cdot 10^{+18}\right):\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.8e14 or 3.4e18 < y Initial program 92.6%
Taylor expanded in y around inf 87.5%
Taylor expanded in y around inf 77.6%
if -2.8e14 < y < 3.4e18Initial program 100.0%
Taylor expanded in y around 0 97.0%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.2e+14) (not (<= y 2.8e+82))) (* x (* y z)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+14) || !(y <= 2.8e+82)) {
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 <= (-4.2d+14)) .or. (.not. (y <= 2.8d+82))) 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 <= -4.2e+14) || !(y <= 2.8e+82)) {
tmp = x * (y * z);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.2e+14) or not (y <= 2.8e+82): tmp = x * (y * z) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.2e+14) || !(y <= 2.8e+82)) 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 <= -4.2e+14) || ~((y <= 2.8e+82))) tmp = x * (y * z); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.2e+14], N[Not[LessEqual[y, 2.8e+82]], $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 -4.2 \cdot 10^{+14} \lor \neg \left(y \leq 2.8 \cdot 10^{+82}\right):\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -4.2e14 or 2.8e82 < y Initial program 92.7%
Taylor expanded in y around inf 75.9%
*-commutative75.9%
Simplified75.9%
if -4.2e14 < y < 2.8e82Initial program 99.3%
Taylor expanded in y around 0 92.9%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * -z;
} 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 = x * -z
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 = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(x * Float64(-z)); 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 = x * -z; 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[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 93.4%
Taylor expanded in z around inf 93.4%
*-commutative93.4%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 54.0%
neg-mul-154.0%
Simplified54.0%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 76.2%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (<= z -3.4e-10) (* x (* y z)) (if (<= z 1.0) x (* x (- z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e-10) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = 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 (z <= (-3.4d-10)) then
tmp = x * (y * z)
else if (z <= 1.0d0) then
tmp = x
else
tmp = x * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.4e-10) {
tmp = x * (y * z);
} else if (z <= 1.0) {
tmp = x;
} else {
tmp = x * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.4e-10: tmp = x * (y * z) elif z <= 1.0: tmp = x else: tmp = x * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.4e-10) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.0) tmp = x; else tmp = Float64(x * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.4e-10) tmp = x * (y * z); elseif (z <= 1.0) tmp = x; else tmp = x * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.4e-10], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], x, N[(x * (-z)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-10}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < -3.40000000000000015e-10Initial program 97.0%
Taylor expanded in y around inf 58.3%
*-commutative58.3%
Simplified58.3%
if -3.40000000000000015e-10 < z < 1Initial program 99.9%
Taylor expanded in z around 0 77.3%
if 1 < z Initial program 89.9%
Taylor expanded in z around inf 89.9%
*-commutative89.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 59.2%
neg-mul-159.2%
Simplified59.2%
Final simplification67.8%
(FPCore (x y z) :precision binary64 (if (<= z 500000000000.0) (+ x (* x (* (+ y -1.0) z))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 500000000000.0) {
tmp = x + (x * ((y + -1.0) * z));
} 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 <= 500000000000.0d0) then
tmp = x + (x * ((y + (-1.0d0)) * z))
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 <= 500000000000.0) {
tmp = x + (x * ((y + -1.0) * z));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 500000000000.0: tmp = x + (x * ((y + -1.0) * z)) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 500000000000.0) tmp = Float64(x + Float64(x * Float64(Float64(y + -1.0) * z))); 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 <= 500000000000.0) tmp = x + (x * ((y + -1.0) * z)); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 500000000000.0], N[(x + N[(x * N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 500000000000:\\
\;\;\;\;x + x \cdot \left(\left(y + -1\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 5e11Initial program 98.9%
Taylor expanded in z around 0 98.9%
if 5e11 < z Initial program 89.9%
Taylor expanded in z around inf 89.9%
*-commutative89.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (<= z 500000000000.0) (* x (+ 1.0 (* (+ y -1.0) z))) (* z (* x (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 500000000000.0) {
tmp = x * (1.0 + ((y + -1.0) * z));
} 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 <= 500000000000.0d0) then
tmp = x * (1.0d0 + ((y + (-1.0d0)) * z))
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 <= 500000000000.0) {
tmp = x * (1.0 + ((y + -1.0) * z));
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 500000000000.0: tmp = x * (1.0 + ((y + -1.0) * z)) else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 500000000000.0) tmp = Float64(x * Float64(1.0 + Float64(Float64(y + -1.0) * z))); 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 <= 500000000000.0) tmp = x * (1.0 + ((y + -1.0) * z)); else tmp = z * (x * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 500000000000.0], N[(x * N[(1.0 + N[(N[(y + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 500000000000:\\
\;\;\;\;x \cdot \left(1 + \left(y + -1\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if z < 5e11Initial program 98.9%
if 5e11 < z Initial program 89.9%
Taylor expanded in z around inf 89.9%
*-commutative89.9%
associate-*r*99.9%
*-commutative99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (+ x (* (+ y -1.0) (* x z))))
double code(double x, double y, double z) {
return x + ((y + -1.0) * (x * 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 + ((y + (-1.0d0)) * (x * z))
end function
public static double code(double x, double y, double z) {
return x + ((y + -1.0) * (x * z));
}
def code(x, y, z): return x + ((y + -1.0) * (x * z))
function code(x, y, z) return Float64(x + Float64(Float64(y + -1.0) * Float64(x * z))) end
function tmp = code(x, y, z) tmp = x + ((y + -1.0) * (x * z)); end
code[x_, y_, z_] := N[(x + N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(y + -1\right) \cdot \left(x \cdot z\right)
\end{array}
Initial program 96.6%
Taylor expanded in z around 0 96.6%
add-cube-cbrt96.1%
pow396.1%
associate-*r*97.8%
*-commutative97.8%
sub-neg97.8%
metadata-eval97.8%
Applied egg-rr97.8%
rem-cube-cbrt98.4%
Applied egg-rr98.4%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 96.6%
Taylor expanded in z around 0 39.6%
(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 2024106
(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))))