
(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 (<= (* (- 1.0 y) z) -1e+308) (* z (* y x)) (+ x (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x + (x * (z * (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 (((1.0d0 - y) * z) <= (-1d+308)) then
tmp = z * (y * x)
else
tmp = x + (x * (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x + (x * (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -1e+308: tmp = z * (y * x) else: tmp = x + (x * (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -1e+308) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x + Float64(x * Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -1e+308) tmp = z * (y * x); else tmp = x + (x * (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -1e+308], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -1 \cdot 10^{+308}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -1e308Initial program 60.4%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6460.4%
Applied egg-rr60.4%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6499.8%
Simplified99.8%
if -1e308 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 99.5%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6499.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= (* (- 1.0 y) z) -1e+308) (* z (* y x)) (* x (+ 1.0 (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (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 (((1.0d0 - y) * z) <= (-1d+308)) then
tmp = z * (y * x)
else
tmp = x * (1.0d0 + (z * (y + (-1.0d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((1.0 - y) * z) <= -1e+308) {
tmp = z * (y * x);
} else {
tmp = x * (1.0 + (z * (y + -1.0)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((1.0 - y) * z) <= -1e+308: tmp = z * (y * x) else: tmp = x * (1.0 + (z * (y + -1.0))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(Float64(1.0 - y) * z) <= -1e+308) tmp = Float64(z * Float64(y * x)); else tmp = Float64(x * Float64(1.0 + Float64(z * Float64(y + -1.0)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((1.0 - y) * z) <= -1e+308) tmp = z * (y * x); else tmp = x * (1.0 + (z * (y + -1.0))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(N[(1.0 - y), $MachinePrecision] * z), $MachinePrecision], -1e+308], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 + N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - y\right) \cdot z \leq -1 \cdot 10^{+308}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 + z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) y) z) < -1e308Initial program 60.4%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6460.4%
Applied egg-rr60.4%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6499.8%
Simplified99.8%
if -1e308 < (*.f64 (-.f64 #s(literal 1 binary64) y) z) Initial program 99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -9.8e+33) (* z (* y x)) (if (<= y 0.82) (- x (* z x)) (* x (* z (+ y -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.8e+33) {
tmp = z * (y * x);
} else if (y <= 0.82) {
tmp = x - (z * x);
} else {
tmp = x * (z * (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 (y <= (-9.8d+33)) then
tmp = z * (y * x)
else if (y <= 0.82d0) then
tmp = x - (z * x)
else
tmp = x * (z * (y + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9.8e+33) {
tmp = z * (y * x);
} else if (y <= 0.82) {
tmp = x - (z * x);
} else {
tmp = x * (z * (y + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.8e+33: tmp = z * (y * x) elif y <= 0.82: tmp = x - (z * x) else: tmp = x * (z * (y + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.8e+33) tmp = Float64(z * Float64(y * x)); elseif (y <= 0.82) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(z * Float64(y + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.8e+33) tmp = z * (y * x); elseif (y <= 0.82) tmp = x - (z * x); else tmp = x * (z * (y + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.8e+33], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.82], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.8 \cdot 10^{+33}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 0.82:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(z \cdot \left(y + -1\right)\right)\\
\end{array}
\end{array}
if y < -9.80000000000000027e33Initial program 85.7%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6485.7%
Applied egg-rr85.7%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.9%
Simplified78.9%
if -9.80000000000000027e33 < y < 0.819999999999999951Initial program 100.0%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0
Simplified98.3%
if 0.819999999999999951 < y Initial program 98.4%
Taylor expanded in z around inf
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-lowering-+.f6481.8%
Simplified81.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (<= y -6.2e+32) (* z (* y x)) (if (<= y 12.5) (- x (* z x)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+32) {
tmp = z * (y * x);
} else if (y <= 12.5) {
tmp = x - (z * x);
} else {
tmp = 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 (y <= (-6.2d+32)) then
tmp = z * (y * x)
else if (y <= 12.5d0) then
tmp = x - (z * x)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+32) {
tmp = z * (y * x);
} else if (y <= 12.5) {
tmp = x - (z * x);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.2e+32: tmp = z * (y * x) elif y <= 12.5: tmp = x - (z * x) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.2e+32) tmp = Float64(z * Float64(y * x)); elseif (y <= 12.5) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.2e+32) tmp = z * (y * x); elseif (y <= 12.5) tmp = x - (z * x); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.2e+32], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 12.5], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+32}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 12.5:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -6.19999999999999986e32Initial program 85.7%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6485.7%
Applied egg-rr85.7%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.9%
Simplified78.9%
if -6.19999999999999986e32 < y < 12.5Initial program 100.0%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f64100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0
Simplified98.3%
if 12.5 < y Initial program 98.4%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6480.9%
Simplified80.9%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+31) (* z (* y x)) (if (<= y 190.0) (* x (- 1.0 z)) (* x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+31) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = 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 (y <= (-5.5d+31)) then
tmp = z * (y * x)
else if (y <= 190.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = x * (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+31) {
tmp = z * (y * x);
} else if (y <= 190.0) {
tmp = x * (1.0 - z);
} else {
tmp = x * (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+31: tmp = z * (y * x) elif y <= 190.0: tmp = x * (1.0 - z) else: tmp = x * (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+31) tmp = Float64(z * Float64(y * x)); elseif (y <= 190.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x * Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e+31) tmp = z * (y * x); elseif (y <= 190.0) tmp = x * (1.0 - z); else tmp = x * (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+31], N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 190.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+31}:\\
\;\;\;\;z \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;y \leq 190:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if y < -5.50000000000000002e31Initial program 85.7%
sub-negN/A
distribute-rgt-inN/A
fma-defineN/A
distribute-lft-neg-outN/A
fmm-undefN/A
*-lft-identityN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
--lowering--.f6485.7%
Applied egg-rr85.7%
Taylor expanded in y around inf
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-lowering-*.f6478.9%
Simplified78.9%
if -5.50000000000000002e31 < y < 190Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6498.2%
Simplified98.2%
if 190 < y Initial program 98.4%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6480.9%
Simplified80.9%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= y -2.05e+29) t_0 (if (<= y 165.0) (* x (- 1.0 z)) t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -2.05e+29) {
tmp = t_0;
} else if (y <= 165.0) {
tmp = x * (1.0 - z);
} 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 * (y * z)
if (y <= (-2.05d+29)) then
tmp = t_0
else if (y <= 165.0d0) then
tmp = x * (1.0d0 - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (y <= -2.05e+29) {
tmp = t_0;
} else if (y <= 165.0) {
tmp = x * (1.0 - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if y <= -2.05e+29: tmp = t_0 elif y <= 165.0: tmp = x * (1.0 - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (y <= -2.05e+29) tmp = t_0; elseif (y <= 165.0) tmp = Float64(x * Float64(1.0 - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * z); tmp = 0.0; if (y <= -2.05e+29) tmp = t_0; elseif (y <= 165.0) tmp = x * (1.0 - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.05e+29], t$95$0, If[LessEqual[y, 165.0], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \leq -2.05 \cdot 10^{+29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 165:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.0500000000000002e29 or 165 < y Initial program 92.7%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6475.3%
Simplified75.3%
if -2.0500000000000002e29 < y < 165Initial program 100.0%
Taylor expanded in y around 0
*-lowering-*.f64N/A
--lowering--.f6498.2%
Simplified98.2%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (* y z)))) (if (<= z -3.35e-25) t_0 (if (<= z 8.2e-80) x t_0))))
double code(double x, double y, double z) {
double t_0 = x * (y * z);
double tmp;
if (z <= -3.35e-25) {
tmp = t_0;
} else if (z <= 8.2e-80) {
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 * (y * z)
if (z <= (-3.35d-25)) then
tmp = t_0
else if (z <= 8.2d-80) 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 * (y * z);
double tmp;
if (z <= -3.35e-25) {
tmp = t_0;
} else if (z <= 8.2e-80) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y * z) tmp = 0 if z <= -3.35e-25: tmp = t_0 elif z <= 8.2e-80: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y * z)) tmp = 0.0 if (z <= -3.35e-25) tmp = t_0; elseif (z <= 8.2e-80) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y * z); tmp = 0.0; if (z <= -3.35e-25) tmp = t_0; elseif (z <= 8.2e-80) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.35e-25], t$95$0, If[LessEqual[z, 8.2e-80], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -3.35 \cdot 10^{-25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{-80}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -3.35000000000000016e-25 or 8.1999999999999999e-80 < z Initial program 94.1%
Taylor expanded in y around inf
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6451.8%
Simplified51.8%
if -3.35000000000000016e-25 < z < 8.1999999999999999e-80Initial program 99.9%
Taylor expanded in z around 0
Simplified83.2%
Final simplification65.2%
(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
Simplified38.5%
(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 2024158
(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))))