
(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 8 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 -9e-8) (* z (* x (+ y -1.0))) (if (<= z 1.3e-8) (+ x (* x (* y z))) (* (+ y -1.0) (* x z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -9e-8) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.3e-8) {
tmp = x + (x * (y * z));
} else {
tmp = (y + -1.0) * (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 <= (-9d-8)) then
tmp = z * (x * (y + (-1.0d0)))
else if (z <= 1.3d-8) then
tmp = x + (x * (y * z))
else
tmp = (y + (-1.0d0)) * (x * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9e-8) {
tmp = z * (x * (y + -1.0));
} else if (z <= 1.3e-8) {
tmp = x + (x * (y * z));
} else {
tmp = (y + -1.0) * (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9e-8: tmp = z * (x * (y + -1.0)) elif z <= 1.3e-8: tmp = x + (x * (y * z)) else: tmp = (y + -1.0) * (x * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9e-8) tmp = Float64(z * Float64(x * Float64(y + -1.0))); elseif (z <= 1.3e-8) tmp = Float64(x + Float64(x * Float64(y * z))); else tmp = Float64(Float64(y + -1.0) * Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9e-8) tmp = z * (x * (y + -1.0)); elseif (z <= 1.3e-8) tmp = x + (x * (y * z)); else tmp = (y + -1.0) * (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9e-8], N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.3e-8], N[(x + N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + -1.0), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-8}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;x + x \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + -1\right) \cdot \left(x \cdot z\right)\\
\end{array}
\end{array}
if z < -8.99999999999999986e-8Initial program 91.4%
Taylor expanded in z around inf 89.6%
*-commutative89.6%
associate-*l*98.1%
sub-neg98.1%
metadata-eval98.1%
Simplified98.1%
if -8.99999999999999986e-8 < z < 1.3000000000000001e-8Initial program 99.9%
Taylor expanded in y around inf 99.7%
mul-1-neg99.7%
distribute-lft-neg-out99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in z around 0 99.7%
if 1.3000000000000001e-8 < z Initial program 96.4%
Taylor expanded in z around inf 96.4%
associate-*r*100.0%
*-commutative100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z))))) (if (<= t_0 2e+304) t_0 (* z (* x (+ y -1.0))))))
double code(double x, double y, double z) {
double t_0 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if (t_0 <= 2e+304) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (1.0d0 - ((1.0d0 - y) * z))
if (t_0 <= 2d+304) then
tmp = t_0
else
tmp = z * (x * (y + (-1.0d0)))
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 tmp;
if (t_0 <= 2e+304) {
tmp = t_0;
} else {
tmp = z * (x * (y + -1.0));
}
return tmp;
}
def code(x, y, z): t_0 = x * (1.0 - ((1.0 - y) * z)) tmp = 0 if t_0 <= 2e+304: tmp = t_0 else: tmp = z * (x * (y + -1.0)) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(1.0 - Float64(Float64(1.0 - y) * z))) tmp = 0.0 if (t_0 <= 2e+304) tmp = t_0; else tmp = Float64(z * Float64(x * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (1.0 - ((1.0 - y) * z)); tmp = 0.0; if (t_0 <= 2e+304) tmp = t_0; else tmp = z * (x * (y + -1.0)); 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]}, If[LessEqual[t$95$0, 2e+304], t$95$0, N[(z * N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{+304}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 1.9999999999999999e304Initial program 99.1%
if 1.9999999999999999e304 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 84.9%
Taylor expanded in z around inf 84.9%
*-commutative84.9%
associate-*l*100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification99.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* z (* x y))))
(if (<= z -6e+250)
t_0
(if (<= z -9e+186)
t_1
(if (<= z -2.05e+30)
t_0
(if (<= z -6.2e-29)
t_1
(if (<= z 1.2e-88)
x
(if (<= z 6.2e-68) (* x (* y z)) (if (<= z 1.3e-8) x t_0)))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = z * (x * y);
double tmp;
if (z <= -6e+250) {
tmp = t_0;
} else if (z <= -9e+186) {
tmp = t_1;
} else if (z <= -2.05e+30) {
tmp = t_0;
} else if (z <= -6.2e-29) {
tmp = t_1;
} else if (z <= 1.2e-88) {
tmp = x;
} else if (z <= 6.2e-68) {
tmp = x * (y * z);
} else if (z <= 1.3e-8) {
tmp = x;
} 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 = x * -z
t_1 = z * (x * y)
if (z <= (-6d+250)) then
tmp = t_0
else if (z <= (-9d+186)) then
tmp = t_1
else if (z <= (-2.05d+30)) then
tmp = t_0
else if (z <= (-6.2d-29)) then
tmp = t_1
else if (z <= 1.2d-88) then
tmp = x
else if (z <= 6.2d-68) then
tmp = x * (y * z)
else if (z <= 1.3d-8) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = z * (x * y);
double tmp;
if (z <= -6e+250) {
tmp = t_0;
} else if (z <= -9e+186) {
tmp = t_1;
} else if (z <= -2.05e+30) {
tmp = t_0;
} else if (z <= -6.2e-29) {
tmp = t_1;
} else if (z <= 1.2e-88) {
tmp = x;
} else if (z <= 6.2e-68) {
tmp = x * (y * z);
} else if (z <= 1.3e-8) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = z * (x * y) tmp = 0 if z <= -6e+250: tmp = t_0 elif z <= -9e+186: tmp = t_1 elif z <= -2.05e+30: tmp = t_0 elif z <= -6.2e-29: tmp = t_1 elif z <= 1.2e-88: tmp = x elif z <= 6.2e-68: tmp = x * (y * z) elif z <= 1.3e-8: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(z * Float64(x * y)) tmp = 0.0 if (z <= -6e+250) tmp = t_0; elseif (z <= -9e+186) tmp = t_1; elseif (z <= -2.05e+30) tmp = t_0; elseif (z <= -6.2e-29) tmp = t_1; elseif (z <= 1.2e-88) tmp = x; elseif (z <= 6.2e-68) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = z * (x * y); tmp = 0.0; if (z <= -6e+250) tmp = t_0; elseif (z <= -9e+186) tmp = t_1; elseif (z <= -2.05e+30) tmp = t_0; elseif (z <= -6.2e-29) tmp = t_1; elseif (z <= 1.2e-88) tmp = x; elseif (z <= 6.2e-68) tmp = x * (y * z); elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6e+250], t$95$0, If[LessEqual[z, -9e+186], t$95$1, If[LessEqual[z, -2.05e+30], t$95$0, If[LessEqual[z, -6.2e-29], t$95$1, If[LessEqual[z, 1.2e-88], x, If[LessEqual[z, 6.2e-68], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.3e-8], x, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := z \cdot \left(x \cdot y\right)\\
\mathbf{if}\;z \leq -6 \cdot 10^{+250}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -9 \cdot 10^{+186}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.05 \cdot 10^{+30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-88}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-68}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -5.99999999999999953e250 or -9.0000000000000009e186 < z < -2.05000000000000003e30 or 1.3000000000000001e-8 < z Initial program 96.3%
Taylor expanded in y around 0 72.1%
sub-neg72.1%
distribute-rgt-in72.1%
*-lft-identity72.1%
distribute-lft-neg-out72.1%
*-commutative72.1%
unsub-neg72.1%
Simplified72.1%
Taylor expanded in z around inf 72.2%
mul-1-neg72.2%
*-commutative72.2%
distribute-rgt-neg-in72.2%
Simplified72.2%
if -5.99999999999999953e250 < z < -9.0000000000000009e186 or -2.05000000000000003e30 < z < -6.20000000000000052e-29Initial program 85.1%
add-cube-cbrt84.2%
pow384.3%
Applied egg-rr84.3%
Taylor expanded in y around inf 57.1%
*-commutative57.3%
Simplified57.1%
rem-cube-cbrt57.3%
*-commutative57.3%
associate-*r*72.1%
Applied egg-rr72.1%
if -6.20000000000000052e-29 < z < 1.2e-88 or 6.1999999999999999e-68 < z < 1.3000000000000001e-8Initial program 99.9%
Taylor expanded in z around 0 80.5%
if 1.2e-88 < z < 6.1999999999999999e-68Initial program 100.0%
Taylor expanded in y around inf 84.7%
*-commutative84.7%
Simplified84.7%
Final simplification76.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))))
(if (<= z -3.6e+154)
(* y (* x z))
(if (<= z -2.8e+30)
t_0
(if (<= z -3.2e-30)
(* z (* x y))
(if (<= z 8.4e-89)
x
(if (<= z 6.8e-68) (* x (* y z)) (if (<= z 1.3e-8) x t_0))))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -3.6e+154) {
tmp = y * (x * z);
} else if (z <= -2.8e+30) {
tmp = t_0;
} else if (z <= -3.2e-30) {
tmp = z * (x * y);
} else if (z <= 8.4e-89) {
tmp = x;
} else if (z <= 6.8e-68) {
tmp = x * (y * z);
} else if (z <= 1.3e-8) {
tmp = x;
} 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) :: tmp
t_0 = x * -z
if (z <= (-3.6d+154)) then
tmp = y * (x * z)
else if (z <= (-2.8d+30)) then
tmp = t_0
else if (z <= (-3.2d-30)) then
tmp = z * (x * y)
else if (z <= 8.4d-89) then
tmp = x
else if (z <= 6.8d-68) then
tmp = x * (y * z)
else if (z <= 1.3d-8) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double tmp;
if (z <= -3.6e+154) {
tmp = y * (x * z);
} else if (z <= -2.8e+30) {
tmp = t_0;
} else if (z <= -3.2e-30) {
tmp = z * (x * y);
} else if (z <= 8.4e-89) {
tmp = x;
} else if (z <= 6.8e-68) {
tmp = x * (y * z);
} else if (z <= 1.3e-8) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z tmp = 0 if z <= -3.6e+154: tmp = y * (x * z) elif z <= -2.8e+30: tmp = t_0 elif z <= -3.2e-30: tmp = z * (x * y) elif z <= 8.4e-89: tmp = x elif z <= 6.8e-68: tmp = x * (y * z) elif z <= 1.3e-8: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) tmp = 0.0 if (z <= -3.6e+154) tmp = Float64(y * Float64(x * z)); elseif (z <= -2.8e+30) tmp = t_0; elseif (z <= -3.2e-30) tmp = Float64(z * Float64(x * y)); elseif (z <= 8.4e-89) tmp = x; elseif (z <= 6.8e-68) tmp = Float64(x * Float64(y * z)); elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; tmp = 0.0; if (z <= -3.6e+154) tmp = y * (x * z); elseif (z <= -2.8e+30) tmp = t_0; elseif (z <= -3.2e-30) tmp = z * (x * y); elseif (z <= 8.4e-89) tmp = x; elseif (z <= 6.8e-68) tmp = x * (y * z); elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, If[LessEqual[z, -3.6e+154], N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2.8e+30], t$95$0, If[LessEqual[z, -3.2e-30], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.4e-89], x, If[LessEqual[z, 6.8e-68], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.3e-8], x, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -3.6 \cdot 10^{+154}:\\
\;\;\;\;y \cdot \left(x \cdot z\right)\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{+30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -3.2 \cdot 10^{-30}:\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{elif}\;z \leq 8.4 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-68}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -3.6000000000000001e154Initial program 86.8%
add-cube-cbrt86.2%
pow386.3%
Applied egg-rr86.3%
Taylor expanded in y around inf 46.8%
*-commutative46.8%
Simplified46.8%
rem-cube-cbrt46.8%
associate-*r*67.5%
*-commutative67.5%
Applied egg-rr67.5%
if -3.6000000000000001e154 < z < -2.79999999999999983e30 or 1.3000000000000001e-8 < z Initial program 95.4%
Taylor expanded in y around 0 70.9%
sub-neg70.9%
distribute-rgt-in70.9%
*-lft-identity70.9%
distribute-lft-neg-out70.9%
*-commutative70.9%
unsub-neg70.9%
Simplified70.9%
Taylor expanded in z around inf 70.9%
mul-1-neg70.9%
*-commutative70.9%
distribute-rgt-neg-in70.9%
Simplified70.9%
if -2.79999999999999983e30 < z < -3.2e-30Initial program 99.8%
add-cube-cbrt98.6%
pow398.6%
Applied egg-rr98.6%
Taylor expanded in y around inf 69.7%
*-commutative70.3%
Simplified69.7%
rem-cube-cbrt70.3%
*-commutative70.3%
associate-*r*70.5%
Applied egg-rr70.5%
if -3.2e-30 < z < 8.4000000000000004e-89 or 6.80000000000000037e-68 < z < 1.3000000000000001e-8Initial program 99.9%
Taylor expanded in z around 0 80.5%
if 8.4000000000000004e-89 < z < 6.80000000000000037e-68Initial program 100.0%
Taylor expanded in y around inf 84.7%
*-commutative84.7%
Simplified84.7%
Final simplification75.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (- z))) (t_1 (* x (* y z))))
(if (<= z -2.8e+30)
t_0
(if (<= z -6.2e-29)
t_1
(if (<= z 1.06e-88)
x
(if (<= z 4.8e-62) t_1 (if (<= z 1.3e-8) x t_0)))))))
double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -2.8e+30) {
tmp = t_0;
} else if (z <= -6.2e-29) {
tmp = t_1;
} else if (z <= 1.06e-88) {
tmp = x;
} else if (z <= 4.8e-62) {
tmp = t_1;
} else if (z <= 1.3e-8) {
tmp = x;
} 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 = x * -z
t_1 = x * (y * z)
if (z <= (-2.8d+30)) then
tmp = t_0
else if (z <= (-6.2d-29)) then
tmp = t_1
else if (z <= 1.06d-88) then
tmp = x
else if (z <= 4.8d-62) then
tmp = t_1
else if (z <= 1.3d-8) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * -z;
double t_1 = x * (y * z);
double tmp;
if (z <= -2.8e+30) {
tmp = t_0;
} else if (z <= -6.2e-29) {
tmp = t_1;
} else if (z <= 1.06e-88) {
tmp = x;
} else if (z <= 4.8e-62) {
tmp = t_1;
} else if (z <= 1.3e-8) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * -z t_1 = x * (y * z) tmp = 0 if z <= -2.8e+30: tmp = t_0 elif z <= -6.2e-29: tmp = t_1 elif z <= 1.06e-88: tmp = x elif z <= 4.8e-62: tmp = t_1 elif z <= 1.3e-8: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(-z)) t_1 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -2.8e+30) tmp = t_0; elseif (z <= -6.2e-29) tmp = t_1; elseif (z <= 1.06e-88) tmp = x; elseif (z <= 4.8e-62) tmp = t_1; elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * -z; t_1 = x * (y * z); tmp = 0.0; if (z <= -2.8e+30) tmp = t_0; elseif (z <= -6.2e-29) tmp = t_1; elseif (z <= 1.06e-88) tmp = x; elseif (z <= 4.8e-62) tmp = t_1; elseif (z <= 1.3e-8) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * (-z)), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.8e+30], t$95$0, If[LessEqual[z, -6.2e-29], t$95$1, If[LessEqual[z, 1.06e-88], x, If[LessEqual[z, 4.8e-62], t$95$1, If[LessEqual[z, 1.3e-8], x, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(-z\right)\\
t_1 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -2.8 \cdot 10^{+30}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.06 \cdot 10^{-88}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{-62}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-8}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -2.79999999999999983e30 or 1.3000000000000001e-8 < z Initial program 92.8%
Taylor expanded in y around 0 66.3%
sub-neg66.3%
distribute-rgt-in66.3%
*-lft-identity66.3%
distribute-lft-neg-out66.3%
*-commutative66.3%
unsub-neg66.3%
Simplified66.3%
Taylor expanded in z around inf 66.3%
mul-1-neg66.3%
*-commutative66.3%
distribute-rgt-neg-in66.3%
Simplified66.3%
if -2.79999999999999983e30 < z < -6.20000000000000052e-29 or 1.06e-88 < z < 4.79999999999999967e-62Initial program 99.9%
Taylor expanded in y around inf 75.5%
*-commutative75.5%
Simplified75.5%
if -6.20000000000000052e-29 < z < 1.06e-88 or 4.79999999999999967e-62 < z < 1.3000000000000001e-8Initial program 99.9%
Taylor expanded in z around 0 80.5%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.2e+94) (not (<= y 255000000000.0))) (* z (* x y)) (- x (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+94) || !(y <= 255000000000.0)) {
tmp = z * (x * y);
} 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 <= (-5.2d+94)) .or. (.not. (y <= 255000000000.0d0))) then
tmp = z * (x * y)
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 <= -5.2e+94) || !(y <= 255000000000.0)) {
tmp = z * (x * y);
} else {
tmp = x - (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.2e+94) or not (y <= 255000000000.0): tmp = z * (x * y) else: tmp = x - (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.2e+94) || !(y <= 255000000000.0)) tmp = Float64(z * Float64(x * y)); else tmp = Float64(x - Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.2e+94) || ~((y <= 255000000000.0))) tmp = z * (x * y); else tmp = x - (x * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e+94], N[Not[LessEqual[y, 255000000000.0]], $MachinePrecision]], N[(z * N[(x * y), $MachinePrecision]), $MachinePrecision], N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+94} \lor \neg \left(y \leq 255000000000\right):\\
\;\;\;\;z \cdot \left(x \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\
\end{array}
\end{array}
if y < -5.1999999999999998e94 or 2.55e11 < y Initial program 91.1%
add-cube-cbrt90.1%
pow390.2%
Applied egg-rr90.2%
Taylor expanded in y around inf 72.8%
*-commutative73.4%
Simplified72.8%
rem-cube-cbrt73.4%
*-commutative73.4%
associate-*r*78.4%
Applied egg-rr78.4%
if -5.1999999999999998e94 < y < 2.55e11Initial program 100.0%
Taylor expanded in y around 0 97.9%
sub-neg97.9%
distribute-rgt-in97.9%
*-lft-identity97.9%
distribute-lft-neg-out97.9%
*-commutative97.9%
unsub-neg97.9%
Simplified97.9%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -9e-8) (not (<= z 1.3e-8))) (* x (- z)) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9e-8) || !(z <= 1.3e-8)) {
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 <= (-9d-8)) .or. (.not. (z <= 1.3d-8))) 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 <= -9e-8) || !(z <= 1.3e-8)) {
tmp = x * -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9e-8) or not (z <= 1.3e-8): tmp = x * -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9e-8) || !(z <= 1.3e-8)) tmp = Float64(x * Float64(-z)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9e-8) || ~((z <= 1.3e-8))) tmp = x * -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9e-8], N[Not[LessEqual[z, 1.3e-8]], $MachinePrecision]], N[(x * (-z)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-8} \lor \neg \left(z \leq 1.3 \cdot 10^{-8}\right):\\
\;\;\;\;x \cdot \left(-z\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.99999999999999986e-8 or 1.3000000000000001e-8 < z Initial program 93.4%
Taylor expanded in y around 0 62.8%
sub-neg62.8%
distribute-rgt-in62.8%
*-lft-identity62.8%
distribute-lft-neg-out62.8%
*-commutative62.8%
unsub-neg62.8%
Simplified62.8%
Taylor expanded in z around inf 62.1%
mul-1-neg62.1%
*-commutative62.1%
distribute-rgt-neg-in62.1%
Simplified62.1%
if -8.99999999999999986e-8 < z < 1.3000000000000001e-8Initial program 99.9%
Taylor expanded in z around 0 75.3%
Final simplification68.6%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 96.6%
Taylor expanded in z around 0 38.8%
Final simplification38.8%
(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 2023293
(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))))