
(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 1e+84) (+ x (* x (* z (+ y -1.0)))) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1e+84) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (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 <= 1d+84) then
tmp = x + (x * (z * (y + (-1.0d0))))
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1e+84) {
tmp = x + (x * (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1e+84: tmp = x + (x * (z * (y + -1.0))) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1e+84) tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1e+84) tmp = x + (x * (z * (y + -1.0))); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1e+84], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+84}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if z < 1.00000000000000006e84Initial program 98.5%
sub-neg98.5%
distribute-rgt-neg-out98.5%
+-commutative98.5%
distribute-rgt-neg-out98.5%
*-commutative98.5%
distribute-rgt-neg-in98.5%
fma-define98.5%
neg-sub098.5%
associate--r-98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
fma-undefine98.5%
distribute-rgt-in98.5%
*-un-lft-identity98.5%
Applied egg-rr98.5%
if 1.00000000000000006e84 < z Initial program 85.6%
Taylor expanded in y around 0 85.6%
Taylor expanded in z around inf 85.6%
sub-neg85.6%
metadata-eval85.6%
associate-*r*99.8%
Simplified99.8%
Final simplification98.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (- x))) (t_1 (* x (* z y))))
(if (<= z -1.35e+108)
t_0
(if (<= z -2.2e-40)
t_1
(if (<= z 2.6e-94) x (if (<= z 6000000000.0) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (z <= -1.35e+108) {
tmp = t_0;
} else if (z <= -2.2e-40) {
tmp = t_1;
} else if (z <= 2.6e-94) {
tmp = x;
} else if (z <= 6000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * -x
t_1 = x * (z * y)
if (z <= (-1.35d+108)) then
tmp = t_0
else if (z <= (-2.2d-40)) then
tmp = t_1
else if (z <= 2.6d-94) then
tmp = x
else if (z <= 6000000000.0d0) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * -x;
double t_1 = x * (z * y);
double tmp;
if (z <= -1.35e+108) {
tmp = t_0;
} else if (z <= -2.2e-40) {
tmp = t_1;
} else if (z <= 2.6e-94) {
tmp = x;
} else if (z <= 6000000000.0) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * -x t_1 = x * (z * y) tmp = 0 if z <= -1.35e+108: tmp = t_0 elif z <= -2.2e-40: tmp = t_1 elif z <= 2.6e-94: tmp = x elif z <= 6000000000.0: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-x)) t_1 = Float64(x * Float64(z * y)) tmp = 0.0 if (z <= -1.35e+108) tmp = t_0; elseif (z <= -2.2e-40) tmp = t_1; elseif (z <= 2.6e-94) tmp = x; elseif (z <= 6000000000.0) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * -x; t_1 = x * (z * y); tmp = 0.0; if (z <= -1.35e+108) tmp = t_0; elseif (z <= -2.2e-40) tmp = t_1; elseif (z <= 2.6e-94) tmp = x; elseif (z <= 6000000000.0) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * (-x)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.35e+108], t$95$0, If[LessEqual[z, -2.2e-40], t$95$1, If[LessEqual[z, 2.6e-94], x, If[LessEqual[z, 6000000000.0], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \left(-x\right)\\
t_1 := x \cdot \left(z \cdot y\right)\\
\mathbf{if}\;z \leq -1.35 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.2 \cdot 10^{-40}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-94}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6000000000:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.35e108 or 6e9 < z Initial program 89.5%
Taylor expanded in y around 0 89.5%
Taylor expanded in z around inf 89.2%
sub-neg89.2%
metadata-eval89.2%
associate-*r*99.5%
Simplified99.5%
Taylor expanded in y around 0 60.3%
mul-1-neg60.3%
*-commutative60.3%
distribute-rgt-neg-in60.3%
Simplified60.3%
if -1.35e108 < z < -2.20000000000000009e-40 or 2.59999999999999994e-94 < z < 6e9Initial program 99.7%
Taylor expanded in y around inf 65.0%
*-commutative65.0%
Simplified65.0%
if -2.20000000000000009e-40 < z < 2.59999999999999994e-94Initial program 99.9%
Taylor expanded in z around 0 82.8%
Final simplification70.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -0.96) (not (<= z 1.0))) (* (+ y -1.0) (* z x)) (+ x (* x (* z y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -0.96) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x + (x * (z * y));
}
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.96d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (y + (-1.0d0)) * (z * x)
else
tmp = x + (x * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -0.96) || !(z <= 1.0)) {
tmp = (y + -1.0) * (z * x);
} else {
tmp = x + (x * (z * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -0.96) or not (z <= 1.0): tmp = (y + -1.0) * (z * x) else: tmp = x + (x * (z * y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -0.96) || !(z <= 1.0)) tmp = Float64(Float64(y + -1.0) * Float64(z * x)); else tmp = Float64(x + Float64(x * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -0.96) || ~((z <= 1.0))) tmp = (y + -1.0) * (z * x); else tmp = x + (x * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.96], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.96 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if z < -0.95999999999999996 or 1 < z Initial program 91.3%
Taylor expanded in y around 0 91.3%
Taylor expanded in z around inf 89.9%
sub-neg89.9%
metadata-eval89.9%
associate-*r*98.5%
Simplified98.5%
if -0.95999999999999996 < z < 1Initial program 99.9%
Taylor expanded in y around inf 98.2%
mul-1-neg98.2%
distribute-lft-neg-out98.2%
*-commutative98.2%
Simplified98.2%
sub-neg98.2%
distribute-rgt-neg-out98.2%
remove-double-neg98.2%
distribute-lft-in98.2%
*-commutative98.2%
*-un-lft-identity98.2%
Applied egg-rr98.2%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+97) (* z (* y x)) (if (<= y 2.9e+26) (* x (- 1.0 z)) (* (+ y -1.0) (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+97) {
tmp = z * (y * x);
} else if (y <= 2.9e+26) {
tmp = x * (1.0 - z);
} else {
tmp = (y + -1.0) * (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 <= (-2.7d+97)) then
tmp = z * (y * x)
else if (y <= 2.9d+26) then
tmp = x * (1.0d0 - z)
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+97) {
tmp = z * (y * x);
} else if (y <= 2.9e+26) {
tmp = x * (1.0 - z);
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+97: tmp = z * (y * x) elif y <= 2.9e+26: tmp = x * (1.0 - z) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+97) tmp = Float64(z * Float64(y * x)); elseif (y <= 2.9e+26) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+97) tmp = z * (y * x); elseif (y <= 2.9e+26) tmp = x * (1.0 - z); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+97], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+26], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+97}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+26}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -2.69999999999999993e97Initial program 91.6%
Taylor expanded in y around inf 77.5%
associate-*r*85.6%
*-commutative85.6%
Simplified85.6%
if -2.69999999999999993e97 < y < 2.9e26Initial program 99.3%
Taylor expanded in y around 0 95.6%
if 2.9e26 < y Initial program 90.6%
Taylor expanded in y around 0 90.6%
Taylor expanded in z around inf 70.0%
sub-neg70.0%
metadata-eval70.0%
associate-*r*75.8%
Simplified75.8%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.7e+97) (not (<= y 2.6e+23))) (* x (* z y)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e+97) || !(y <= 2.6e+23)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.7d+97)) .or. (.not. (y <= 2.6d+23))) then
tmp = x * (z * y)
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e+97) || !(y <= 2.6e+23)) {
tmp = x * (z * y);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.7e+97) or not (y <= 2.6e+23): tmp = x * (z * y) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.7e+97) || !(y <= 2.6e+23)) tmp = Float64(x * Float64(z * y)); else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.7e+97) || ~((y <= 2.6e+23))) tmp = x * (z * y); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.7e+97], N[Not[LessEqual[y, 2.6e+23]], $MachinePrecision]], N[(x * N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+97} \lor \neg \left(y \leq 2.6 \cdot 10^{+23}\right):\\
\;\;\;\;x \cdot \left(z \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -2.69999999999999993e97 or 2.59999999999999992e23 < y Initial program 91.0%
Taylor expanded in y around inf 73.2%
*-commutative73.2%
Simplified73.2%
if -2.69999999999999993e97 < y < 2.59999999999999992e23Initial program 99.3%
Taylor expanded in y around 0 95.6%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.9e+96) (not (<= y 9.6e+29))) (* z (* y x)) (* x (- 1.0 z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.9e+96) || !(y <= 9.6e+29)) {
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.9d+96)) .or. (.not. (y <= 9.6d+29))) 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.9e+96) || !(y <= 9.6e+29)) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.9e+96) or not (y <= 9.6e+29): tmp = z * (y * x) else: tmp = x * (1.0 - z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.9e+96) || !(y <= 9.6e+29)) 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.9e+96) || ~((y <= 9.6e+29))) tmp = z * (y * x); else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.9e+96], N[Not[LessEqual[y, 9.6e+29]], $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.9 \cdot 10^{+96} \lor \neg \left(y \leq 9.6 \cdot 10^{+29}\right):\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < -5.90000000000000028e96 or 9.6000000000000003e29 < y Initial program 91.0%
Taylor expanded in y around inf 73.2%
associate-*r*78.3%
*-commutative78.3%
Simplified78.3%
if -5.90000000000000028e96 < y < 9.6000000000000003e29Initial program 99.3%
Taylor expanded in y around 0 95.6%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= y -3e+95) (* z (* y x)) (if (<= y 2.8e+27) (* x (- 1.0 z)) (* y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+95) {
tmp = z * (y * x);
} else if (y <= 2.8e+27) {
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 <= (-3d+95)) then
tmp = z * (y * x)
else if (y <= 2.8d+27) 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 <= -3e+95) {
tmp = z * (y * x);
} else if (y <= 2.8e+27) {
tmp = x * (1.0 - z);
} else {
tmp = y * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3e+95: tmp = z * (y * x) elif y <= 2.8e+27: tmp = x * (1.0 - z) else: tmp = y * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3e+95) tmp = Float64(z * Float64(y * x)); elseif (y <= 2.8e+27) 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 <= -3e+95) tmp = z * (y * x); elseif (y <= 2.8e+27) tmp = x * (1.0 - z); else tmp = y * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3e+95], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e+27], 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 -3 \cdot 10^{+95}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+27}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if y < -2.99999999999999991e95Initial program 91.6%
Taylor expanded in y around inf 77.5%
associate-*r*85.6%
*-commutative85.6%
Simplified85.6%
if -2.99999999999999991e95 < y < 2.7999999999999999e27Initial program 99.3%
Taylor expanded in y around 0 95.6%
if 2.7999999999999999e27 < y Initial program 90.6%
Taylor expanded in y around inf 90.6%
mul-1-neg90.6%
distribute-lft-neg-out90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in z around inf 70.0%
*-commutative70.0%
associate-*r*75.8%
Simplified75.8%
Final simplification89.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.3%
Taylor expanded in y around 0 91.3%
Taylor expanded in z around inf 89.9%
sub-neg89.9%
metadata-eval89.9%
associate-*r*98.5%
Simplified98.5%
Taylor expanded in y around 0 55.5%
mul-1-neg55.5%
*-commutative55.5%
distribute-rgt-neg-in55.5%
Simplified55.5%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 72.6%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (if (<= z 1.2e+83) (* x (+ 1.0 (* z (+ y -1.0)))) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.2e+83) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (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 <= 1.2d+83) then
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.2e+83) {
tmp = x * (1.0 + (z * (y + -1.0)));
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.2e+83: tmp = x * (1.0 + (z * (y + -1.0))) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.2e+83) tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.2e+83) tmp = x * (1.0 + (z * (y + -1.0))); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.2e+83], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.2 \cdot 10^{+83}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if z < 1.19999999999999996e83Initial program 98.5%
if 1.19999999999999996e83 < z Initial program 85.6%
Taylor expanded in y around 0 85.6%
Taylor expanded in z around inf 85.6%
sub-neg85.6%
metadata-eval85.6%
associate-*r*99.8%
Simplified99.8%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= z 2e+83) (* x (- (+ 1.0 (* z y)) z)) (* (+ y -1.0) (* z x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2e+83) {
tmp = x * ((1.0 + (z * y)) - z);
} else {
tmp = (y + -1.0) * (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 <= 2d+83) then
tmp = x * ((1.0d0 + (z * y)) - z)
else
tmp = (y + (-1.0d0)) * (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2e+83) {
tmp = x * ((1.0 + (z * y)) - z);
} else {
tmp = (y + -1.0) * (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2e+83: tmp = x * ((1.0 + (z * y)) - z) else: tmp = (y + -1.0) * (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2e+83) tmp = Float64(x * Float64(Float64(1.0 + Float64(z * y)) - z)); else tmp = Float64(Float64(y + -1.0) * Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2e+83) tmp = x * ((1.0 + (z * y)) - z); else tmp = (y + -1.0) * (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2e+83], N[(x * N[(N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{+83}:\\
\;\;\;\;x \cdot \left(\left(1 + z \cdot y\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(z \cdot x\right)\\
\end{array}
\end{array}
if z < 2.00000000000000006e83Initial program 98.5%
Taylor expanded in y around 0 98.5%
if 2.00000000000000006e83 < z Initial program 85.6%
Taylor expanded in y around 0 85.6%
Taylor expanded in z around inf 85.6%
sub-neg85.6%
metadata-eval85.6%
associate-*r*99.8%
Simplified99.8%
Final simplification98.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.9%
Taylor expanded in z around 0 40.4%
Final simplification40.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 2024039
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))