
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (1.0d0 - ((1.0d0 - y) * z))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
def code(x, y, z): return x * (1.0 - ((1.0 - y) * z))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) end
function tmp = code(x, y, z) tmp = x * (1.0 - ((1.0 - y) * z)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -1.06) (* z (* x (+ y -1.0))) (if (<= z 1.32e-11) (* x (+ 1.0 (* y z))) (* (* z x) (+ y -1.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.06) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.32e-11) {
tmp = x * (1.0 + (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 <= (-1.06d0)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 1.32d-11) then
tmp = x * (1.0d0 + (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 <= -1.06) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.32e-11) {
tmp = x * (1.0 + (y * z));
} else {
tmp = (z * x) * (y + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.06: tmp = z * (x * (y + -1.0)) elif z <= 1.32e-11: tmp = x * (1.0 + (y * z)) else: tmp = (z * x) * (y + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.06) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 1.32e-11) tmp = Float64(x * Float64(1.0 + Float64(y * z))); else tmp = Float64(Float64(z * x) * Float64(y + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.06) tmp = z * (x * (y + -1.0)); elseif (z <= 1.32e-11) tmp = x * (1.0 + (y * z)); else tmp = (z * x) * (y + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.06], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.32e-11], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * x), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 1.32 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y + -1\right)\\
\end{array}
\end{array}
if z < -1.0600000000000001Initial program 89.4%
Taylor expanded in z around inf 89.2%
associate-*r*99.6%
*-commutative99.6%
sub-neg99.6%
remove-double-neg99.6%
distribute-neg-in99.6%
+-commutative99.6%
sub-neg99.6%
associate-*r*99.7%
*-commutative99.7%
*-commutative99.7%
neg-sub099.7%
associate--r-99.7%
metadata-eval99.7%
Simplified99.7%
if -1.0600000000000001 < z < 1.32e-11Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.5%
associate-*r*91.5%
Simplified91.5%
Taylor expanded in x around 0 98.5%
if 1.32e-11 < z Initial program 92.0%
Taylor expanded in z around inf 90.3%
associate-*r*98.3%
*-commutative98.3%
sub-neg98.3%
metadata-eval98.3%
Simplified98.3%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* (- 1.0 y) z))) (if (<= t_0 4e+307) (- x (* t_0 x)) (* z (* y x)))))
double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (t_0 <= 4e+307) {
tmp = x - (t_0 * x);
} else {
tmp = z * (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 = (1.0d0 - y) * z
if (t_0 <= 4d+307) then
tmp = x - (t_0 * x)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (1.0 - y) * z;
double tmp;
if (t_0 <= 4e+307) {
tmp = x - (t_0 * x);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): t_0 = (1.0 - y) * z tmp = 0 if t_0 <= 4e+307: tmp = x - (t_0 * x) else: tmp = z * (y * x) return tmp
function code(x, y, z) t_0 = Float64(Float64(1.0 - y) * z) tmp = 0.0 if (t_0 <= 4e+307) tmp = Float64(x - Float64(t_0 * x)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (1.0 - y) * z; tmp = 0.0; if (t_0 <= 4e+307) tmp = x - (t_0 * x); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, 4e+307], N[(x - N[(t$95$0 * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - y\right) \cdot z\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{+307}:\\
\;\;\;\;x - t\_0 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 3.99999999999999994e307Initial program 98.3%
Taylor expanded in z around 0 98.3%
if 3.99999999999999994e307 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 42.6%
Taylor expanded in y around inf 42.6%
*-commutative42.6%
*-commutative42.6%
associate-*l*99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) 4e+307) (* x (+ 1.0 (* z (+ y -1.0)))) (* z (* y x))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 4e+307) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (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 (((1.0d0 - y) * z) <= 4d+307) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= 4e+307) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= 4e+307: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= 4e+307) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= 4e+307) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], 4e+307], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq 4 \cdot 10^{+307}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < 3.99999999999999994e307Initial program 98.3%
if 3.99999999999999994e307 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 42.6%
Taylor expanded in y around inf 42.6%
*-commutative42.6%
*-commutative42.6%
associate-*l*99.9%
Simplified99.9%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.95) (not (<= z 1.0))) (* z (* x (+ y -1.0))) (* x (+ 1.0 (* y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.95) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} 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 <= (-0.95d0)) .or. (.not. (z <= 1.0d0))) then
tmp = z * (x * (y + (-1.0d0)))
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 <= -0.95) || !(z <= 1.0)) {
tmp = z * (x * (y + -1.0));
} else {
tmp = x * (1.0 + (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.95) or not (z <= 1.0): tmp = z * (x * (y + -1.0)) else: tmp = x * (1.0 + (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.95) || !(z <= 1.0)) tmp = Float64(z * Float64(x * Float64(y + -1.0))); 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 <= -0.95) || ~((z <= 1.0))) tmp = z * (x * (y + -1.0)); else tmp = x * (1.0 + (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.95], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.95 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\end{array}
\end{array}
if z < -0.94999999999999996 or 1 < z Initial program 90.5%
Taylor expanded in z around inf 89.6%
associate-*r*99.0%
*-commutative99.0%
sub-neg99.0%
remove-double-neg99.0%
distribute-neg-in99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
*-commutative99.0%
neg-sub099.0%
associate--r-99.0%
metadata-eval99.0%
Simplified99.0%
if -0.94999999999999996 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.9%
Taylor expanded in y around inf 98.5%
associate-*r*91.6%
Simplified91.6%
Taylor expanded in x around 0 98.6%
Final simplification98.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* x (+ 1.0 (* y z))) (- x (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = x * (1.0 + (y * z));
} 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 <= 1.0d0))) then
tmp = x * (1.0d0 + (y * z))
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 <= 1.0)) {
tmp = x * (1.0 + (y * z));
} else {
tmp = x - (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x * (1.0 + (y * z)) else: tmp = x - (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) tmp = Float64(x * Float64(1.0 + Float64(y * z))); 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 <= 1.0))) tmp = x * (1.0 + (y * z)); else tmp = x - (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(x * N[(1.0 + N[(y * z), $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 1\right):\\
\;\;\;\;x \cdot \left(1 + y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 90.6%
Taylor expanded in z around 0 90.6%
Taylor expanded in y around inf 90.0%
associate-*r*91.5%
Simplified91.5%
Taylor expanded in x around 0 90.1%
if -1 < y < 1Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 98.6%
neg-mul-198.6%
distribute-rgt-neg-in98.6%
Simplified98.6%
distribute-rgt-neg-out98.6%
unsub-neg98.6%
*-commutative98.6%
Applied egg-rr98.6%
Final simplification94.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+47) (not (<= y 7.5e+51))) (* y (* z x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+47) || !(y <= 7.5e+51)) {
tmp = y * (z * 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 <= (-1d+47)) .or. (.not. (y <= 7.5d+51))) then
tmp = y * (z * 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 <= -1e+47) || !(y <= 7.5e+51)) {
tmp = y * (z * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+47) or not (y <= 7.5e+51): tmp = y * (z * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+47) || !(y <= 7.5e+51)) tmp = Float64(y * Float64(z * 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 <= -1e+47) || ~((y <= 7.5e+51))) tmp = y * (z * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+47], N[Not[LessEqual[y, 7.5e+51]], $MachinePrecision]], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+47} \lor \neg \left(y \leq 7.5 \cdot 10^{+51}\right):\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -1e47 or 7.4999999999999999e51 < y Initial program 89.0%
Taylor expanded in z around 0 89.0%
Taylor expanded in y around inf 89.0%
associate-*r*90.6%
Simplified90.6%
Taylor expanded in x around 0 89.0%
Taylor expanded in y around inf 70.6%
*-commutative70.6%
associate-*r*75.0%
*-commutative75.0%
Simplified75.0%
if -1e47 < y < 7.4999999999999999e51Initial program 99.9%
Taylor expanded in y around 0 97.0%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (<= y -4.1e+47) (* y (* z x)) (if (<= y 1.05e+52) (- x (* z x)) (* z (* y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+47) {
tmp = y * (z * x);
} else if (y <= 1.05e+52) {
tmp = x - (z * x);
} else {
tmp = z * (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 <= (-4.1d+47)) then
tmp = y * (z * x)
else if (y <= 1.05d+52) then
tmp = x - (z * x)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+47) {
tmp = y * (z * x);
} else if (y <= 1.05e+52) {
tmp = x - (z * x);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.1e+47: tmp = y * (z * x) elif y <= 1.05e+52: tmp = x - (z * x) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.1e+47) tmp = Float64(y * Float64(z * x)); elseif (y <= 1.05e+52) tmp = Float64(x - Float64(z * x)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.1e+47) tmp = y * (z * x); elseif (y <= 1.05e+52) tmp = x - (z * x); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.1e+47], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e+52], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+47}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+52}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -4.1000000000000001e47Initial program 91.5%
Taylor expanded in z around 0 91.6%
Taylor expanded in y around inf 91.6%
associate-*r*87.8%
Simplified87.8%
Taylor expanded in x around 0 91.5%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
associate-*r*80.7%
*-commutative80.7%
Simplified80.7%
if -4.1000000000000001e47 < y < 1.05e52Initial program 99.9%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 97.0%
neg-mul-197.0%
distribute-rgt-neg-in97.0%
Simplified97.0%
distribute-rgt-neg-out97.0%
unsub-neg97.0%
*-commutative97.0%
Applied egg-rr97.0%
if 1.05e52 < y Initial program 86.0%
Taylor expanded in y around inf 62.3%
*-commutative62.3%
*-commutative62.3%
associate-*l*72.3%
Simplified72.3%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -4.5e+47) (* y (* z x)) (if (<= y 2.5e+53) (* x (- 1.0 z)) (* z (* y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+47) {
tmp = y * (z * x);
} else if (y <= 2.5e+53) {
tmp = x * (1.0 - z);
} else {
tmp = z * (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 <= (-4.5d+47)) then
tmp = y * (z * x)
else if (y <= 2.5d+53) then
tmp = x * (1.0d0 - z)
else
tmp = z * (y * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+47) {
tmp = y * (z * x);
} else if (y <= 2.5e+53) {
tmp = x * (1.0 - z);
} else {
tmp = z * (y * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e+47: tmp = y * (z * x) elif y <= 2.5e+53: tmp = x * (1.0 - z) else: tmp = z * (y * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+47) tmp = Float64(y * Float64(z * x)); elseif (y <= 2.5e+53) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(z * Float64(y * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e+47) tmp = y * (z * x); elseif (y <= 2.5e+53) tmp = x * (1.0 - z); else tmp = z * (y * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+47], N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+53], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+47}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+53}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\end{array}
\end{array}
if y < -4.49999999999999979e47Initial program 91.5%
Taylor expanded in z around 0 91.6%
Taylor expanded in y around inf 91.6%
associate-*r*87.8%
Simplified87.8%
Taylor expanded in x around 0 91.5%
Taylor expanded in y around inf 77.7%
*-commutative77.7%
associate-*r*80.7%
*-commutative80.7%
Simplified80.7%
if -4.49999999999999979e47 < y < 2.5000000000000002e53Initial program 99.9%
Taylor expanded in y around 0 97.0%
if 2.5000000000000002e53 < y Initial program 86.0%
Taylor expanded in y around inf 62.3%
*-commutative62.3%
*-commutative62.3%
associate-*l*72.3%
Simplified72.3%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 52.0))) (* z (- x)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 52.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 <= 52.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 <= 52.0)) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 52.0): tmp = z * -x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 52.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 <= 52.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, 52.0]], $MachinePrecision]], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 52\right):\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1 or 52 < z Initial program 90.4%
Taylor expanded in z around inf 89.5%
Taylor expanded in y around 0 62.4%
neg-mul-163.3%
distribute-rgt-neg-in63.3%
Simplified62.4%
if -1 < z < 52Initial program 99.9%
Taylor expanded in z around 0 70.3%
Final simplification66.7%
(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 67.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 39.4%
(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 2024172
(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))))