
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(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 * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(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 * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
(FPCore (x y z) :precision binary64 (fma y (+ (- 1.0 z) (log z)) (* x 0.5)))
double code(double x, double y, double z) {
return fma(y, ((1.0 - z) + log(z)), (x * 0.5));
}
function code(x, y, z) return fma(y, Float64(Float64(1.0 - z) + log(z)), Float64(x * 0.5)) end
code[x_, y_, z_] := N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, \left(1 - z\right) + \log z, x \cdot 0.5\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x 0.5) (* y z))))
(if (<= z 7.8e-254)
t_0
(if (<= z 1.9e-158)
(* y (+ 1.0 (log z)))
(if (<= z 1.12e-83)
t_0
(if (<= z 1.02e-72) (+ y (* y (log z))) (fma y (- z) (* x 0.5))))))))
double code(double x, double y, double z) {
double t_0 = (x * 0.5) - (y * z);
double tmp;
if (z <= 7.8e-254) {
tmp = t_0;
} else if (z <= 1.9e-158) {
tmp = y * (1.0 + log(z));
} else if (z <= 1.12e-83) {
tmp = t_0;
} else if (z <= 1.02e-72) {
tmp = y + (y * log(z));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(Float64(x * 0.5) - Float64(y * z)) tmp = 0.0 if (z <= 7.8e-254) tmp = t_0; elseif (z <= 1.9e-158) tmp = Float64(y * Float64(1.0 + log(z))); elseif (z <= 1.12e-83) tmp = t_0; elseif (z <= 1.02e-72) tmp = Float64(y + Float64(y * log(z))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 7.8e-254], t$95$0, If[LessEqual[z, 1.9e-158], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.12e-83], t$95$0, If[LessEqual[z, 1.02e-72], N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot 0.5 - y \cdot z\\
\mathbf{if}\;z \leq 7.8 \cdot 10^{-254}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-158}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-83}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-72}:\\
\;\;\;\;y + y \cdot \log z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 7.8e-254 or 1.8999999999999999e-158 < z < 1.11999999999999993e-83Initial program 99.8%
Taylor expanded in z around inf 68.3%
mul-1-neg68.3%
*-commutative68.3%
distribute-rgt-neg-in68.3%
Simplified68.3%
fma-def68.3%
distribute-rgt-neg-out68.3%
add-sqr-sqrt19.0%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod49.2%
add-sqr-sqrt67.8%
fma-neg67.8%
*-commutative67.8%
add-sqr-sqrt49.2%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod19.0%
add-sqr-sqrt68.3%
Applied egg-rr68.3%
if 7.8e-254 < z < 1.8999999999999999e-158Initial program 99.7%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 66.0%
Taylor expanded in y around 0 66.2%
Taylor expanded in z around 0 66.2%
if 1.11999999999999993e-83 < z < 1.02e-72Initial program 99.0%
distribute-lft-in99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 99.2%
Taylor expanded in z around 0 99.2%
if 1.02e-72 < z Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 93.7%
mul-1-neg93.7%
Simplified93.7%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(if (or (<= z 6.2e-253)
(and (not (<= z 1.9e-158)) (or (<= z 2.1e-83) (not (<= z 9.5e-73)))))
(- (* x 0.5) (* y z))
(* y (+ 1.0 (log z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 6.2e-253) || (!(z <= 1.9e-158) && ((z <= 2.1e-83) || !(z <= 9.5e-73)))) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * (1.0 + log(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 <= 6.2d-253) .or. (.not. (z <= 1.9d-158)) .and. (z <= 2.1d-83) .or. (.not. (z <= 9.5d-73))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y * (1.0d0 + log(z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 6.2e-253) || (!(z <= 1.9e-158) && ((z <= 2.1e-83) || !(z <= 9.5e-73)))) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * (1.0 + Math.log(z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 6.2e-253) or (not (z <= 1.9e-158) and ((z <= 2.1e-83) or not (z <= 9.5e-73))): tmp = (x * 0.5) - (y * z) else: tmp = y * (1.0 + math.log(z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 6.2e-253) || (!(z <= 1.9e-158) && ((z <= 2.1e-83) || !(z <= 9.5e-73)))) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y * Float64(1.0 + log(z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 6.2e-253) || (~((z <= 1.9e-158)) && ((z <= 2.1e-83) || ~((z <= 9.5e-73))))) tmp = (x * 0.5) - (y * z); else tmp = y * (1.0 + log(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 6.2e-253], And[N[Not[LessEqual[z, 1.9e-158]], $MachinePrecision], Or[LessEqual[z, 2.1e-83], N[Not[LessEqual[z, 9.5e-73]], $MachinePrecision]]]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 6.2 \cdot 10^{-253} \lor \neg \left(z \leq 1.9 \cdot 10^{-158}\right) \land \left(z \leq 2.1 \cdot 10^{-83} \lor \neg \left(z \leq 9.5 \cdot 10^{-73}\right)\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\end{array}
\end{array}
if z < 6.19999999999999991e-253 or 1.8999999999999999e-158 < z < 2.0999999999999999e-83 or 9.50000000000000005e-73 < z Initial program 99.9%
Taylor expanded in z around inf 88.6%
mul-1-neg88.6%
*-commutative88.6%
distribute-rgt-neg-in88.6%
Simplified88.6%
fma-def88.6%
distribute-rgt-neg-out88.6%
add-sqr-sqrt45.3%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod20.0%
add-sqr-sqrt39.7%
fma-neg39.7%
*-commutative39.7%
add-sqr-sqrt20.0%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod45.3%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
if 6.19999999999999991e-253 < z < 1.8999999999999999e-158 or 2.0999999999999999e-83 < z < 9.50000000000000005e-73Initial program 99.6%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 69.8%
Taylor expanded in y around 0 69.9%
Taylor expanded in z around 0 69.9%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* x 0.5) (* y z))))
(if (<= z 1.16e-254)
t_0
(if (<= z 1.3e-158)
(* y (+ 1.0 (log z)))
(if (or (<= z 1.02e-82) (not (<= z 2.35e-73)))
t_0
(+ y (* y (log z))))))))
double code(double x, double y, double z) {
double t_0 = (x * 0.5) - (y * z);
double tmp;
if (z <= 1.16e-254) {
tmp = t_0;
} else if (z <= 1.3e-158) {
tmp = y * (1.0 + log(z));
} else if ((z <= 1.02e-82) || !(z <= 2.35e-73)) {
tmp = t_0;
} else {
tmp = y + (y * log(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) :: t_0
real(8) :: tmp
t_0 = (x * 0.5d0) - (y * z)
if (z <= 1.16d-254) then
tmp = t_0
else if (z <= 1.3d-158) then
tmp = y * (1.0d0 + log(z))
else if ((z <= 1.02d-82) .or. (.not. (z <= 2.35d-73))) then
tmp = t_0
else
tmp = y + (y * log(z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x * 0.5) - (y * z);
double tmp;
if (z <= 1.16e-254) {
tmp = t_0;
} else if (z <= 1.3e-158) {
tmp = y * (1.0 + Math.log(z));
} else if ((z <= 1.02e-82) || !(z <= 2.35e-73)) {
tmp = t_0;
} else {
tmp = y + (y * Math.log(z));
}
return tmp;
}
def code(x, y, z): t_0 = (x * 0.5) - (y * z) tmp = 0 if z <= 1.16e-254: tmp = t_0 elif z <= 1.3e-158: tmp = y * (1.0 + math.log(z)) elif (z <= 1.02e-82) or not (z <= 2.35e-73): tmp = t_0 else: tmp = y + (y * math.log(z)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 0.5) - Float64(y * z)) tmp = 0.0 if (z <= 1.16e-254) tmp = t_0; elseif (z <= 1.3e-158) tmp = Float64(y * Float64(1.0 + log(z))); elseif ((z <= 1.02e-82) || !(z <= 2.35e-73)) tmp = t_0; else tmp = Float64(y + Float64(y * log(z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 0.5) - (y * z); tmp = 0.0; if (z <= 1.16e-254) tmp = t_0; elseif (z <= 1.3e-158) tmp = y * (1.0 + log(z)); elseif ((z <= 1.02e-82) || ~((z <= 2.35e-73))) tmp = t_0; else tmp = y + (y * log(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.16e-254], t$95$0, If[LessEqual[z, 1.3e-158], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.02e-82], N[Not[LessEqual[z, 2.35e-73]], $MachinePrecision]], t$95$0, N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot 0.5 - y \cdot z\\
\mathbf{if}\;z \leq 1.16 \cdot 10^{-254}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.3 \cdot 10^{-158}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{elif}\;z \leq 1.02 \cdot 10^{-82} \lor \neg \left(z \leq 2.35 \cdot 10^{-73}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y + y \cdot \log z\\
\end{array}
\end{array}
if z < 1.16000000000000003e-254 or 1.3e-158 < z < 1.02000000000000007e-82 or 2.34999999999999997e-73 < z Initial program 99.9%
Taylor expanded in z around inf 88.6%
mul-1-neg88.6%
*-commutative88.6%
distribute-rgt-neg-in88.6%
Simplified88.6%
fma-def88.6%
distribute-rgt-neg-out88.6%
add-sqr-sqrt45.3%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod20.0%
add-sqr-sqrt39.7%
fma-neg39.7%
*-commutative39.7%
add-sqr-sqrt20.0%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod45.3%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
if 1.16000000000000003e-254 < z < 1.3e-158Initial program 99.7%
distribute-lft-in99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 66.0%
Taylor expanded in y around 0 66.2%
Taylor expanded in z around 0 66.2%
if 1.02000000000000007e-82 < z < 2.34999999999999997e-73Initial program 99.0%
distribute-lft-in99.2%
Applied egg-rr99.2%
Taylor expanded in x around 0 99.2%
Taylor expanded in z around 0 99.2%
Final simplification84.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.4e+38) (not (<= y 2.5e+23))) (* y (- (+ 1.0 (log z)) z)) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.4e+38) || !(y <= 2.5e+23)) {
tmp = y * ((1.0 + log(z)) - z);
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -2.4e+38) || !(y <= 2.5e+23)) tmp = Float64(y * Float64(Float64(1.0 + log(z)) - z)); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.4e+38], N[Not[LessEqual[y, 2.5e+23]], $MachinePrecision]], N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+38} \lor \neg \left(y \leq 2.5 \cdot 10^{+23}\right):\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -2.40000000000000017e38 or 2.5e23 < y Initial program 99.8%
distribute-lft-in99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 87.2%
Taylor expanded in y around 0 87.3%
if -2.40000000000000017e38 < y < 2.5e23Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 89.5%
mul-1-neg89.5%
Simplified89.5%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= z 0.00065) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.00065) {
tmp = (x * 0.5) + (y * (1.0 + log(z)));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 0.00065) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(1.0 + log(z)))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 0.00065], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.00065:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 6.4999999999999997e-4Initial program 99.8%
Taylor expanded in z around 0 99.0%
if 6.4999999999999997e-4 < z Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 99.3%
mul-1-neg99.3%
Simplified99.3%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + log(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 * 0.5d0) + (y * ((1.0d0 - z) + log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 - z) + Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 - z) + math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 - z) + log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 - z) + log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 - z\right) + \log z\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (- (+ 1.0 (log z)) z))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 + log(z)) - 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 * 0.5d0) + (y * ((1.0d0 + log(z)) - z))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 + Math.log(z)) - z));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 + math.log(z)) - z))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 + log(z)) - z))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 + log(z)) - z)); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 + \log z\right) - z\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+r-99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z 1e+29) (and (not (<= z 1.45e+82)) (<= z 4.6e+116))) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 1e+29) || (!(z <= 1.45e+82) && (z <= 4.6e+116))) {
tmp = x * 0.5;
} else {
tmp = 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 <= 1d+29) .or. (.not. (z <= 1.45d+82)) .and. (z <= 4.6d+116)) then
tmp = x * 0.5d0
else
tmp = y * -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 1e+29) || (!(z <= 1.45e+82) && (z <= 4.6e+116))) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 1e+29) or (not (z <= 1.45e+82) and (z <= 4.6e+116)): tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 1e+29) || (!(z <= 1.45e+82) && (z <= 4.6e+116))) tmp = Float64(x * 0.5); else tmp = Float64(y * Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 1e+29) || (~((z <= 1.45e+82)) && (z <= 4.6e+116))) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 1e+29], And[N[Not[LessEqual[z, 1.45e+82]], $MachinePrecision], LessEqual[z, 4.6e+116]]], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+29} \lor \neg \left(z \leq 1.45 \cdot 10^{+82}\right) \land z \leq 4.6 \cdot 10^{+116}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 9.99999999999999914e28 or 1.4500000000000001e82 < z < 4.5999999999999999e116Initial program 99.8%
Taylor expanded in x around inf 52.4%
if 9.99999999999999914e28 < z < 1.4500000000000001e82 or 4.5999999999999999e116 < z Initial program 100.0%
distribute-lft-in100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in z around inf 80.0%
mul-1-neg80.0%
distribute-rgt-neg-out80.0%
Simplified80.0%
Final simplification64.7%
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* y z)))
double code(double x, double y, double z) {
return (x * 0.5) - (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 * 0.5d0) - (y * z)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) - (y * z);
}
def code(x, y, z): return (x * 0.5) - (y * z)
function code(x, y, z) return Float64(Float64(x * 0.5) - Float64(y * z)) end
function tmp = code(x, y, z) tmp = (x * 0.5) - (y * z); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 - y \cdot z
\end{array}
Initial program 99.9%
Taylor expanded in z around inf 76.9%
mul-1-neg76.9%
*-commutative76.9%
distribute-rgt-neg-in76.9%
Simplified76.9%
fma-def76.9%
distribute-rgt-neg-out76.9%
add-sqr-sqrt39.6%
sqrt-unprod50.2%
sqr-neg50.2%
sqrt-unprod18.8%
add-sqr-sqrt37.8%
fma-neg37.8%
*-commutative37.8%
add-sqr-sqrt18.8%
sqrt-unprod50.2%
sqr-neg50.2%
sqrt-unprod39.6%
add-sqr-sqrt76.9%
Applied egg-rr76.9%
Final simplification76.9%
(FPCore (x y z) :precision binary64 (* x 0.5))
double code(double x, double y, double z) {
return x * 0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * 0.5d0
end function
public static double code(double x, double y, double z) {
return x * 0.5;
}
def code(x, y, z): return x * 0.5
function code(x, y, z) return Float64(x * 0.5) end
function tmp = code(x, y, z) tmp = x * 0.5; end
code[x_, y_, z_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5
\end{array}
Initial program 99.9%
Taylor expanded in x around inf 39.0%
Final simplification39.0%
(FPCore (x y z) :precision binary64 (- (+ y (* 0.5 x)) (* y (- z (log z)))))
double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - log(z)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (0.5d0 * x)) - (y * (z - log(z)))
end function
public static double code(double x, double y, double z) {
return (y + (0.5 * x)) - (y * (z - Math.log(z)));
}
def code(x, y, z): return (y + (0.5 * x)) - (y * (z - math.log(z)))
function code(x, y, z) return Float64(Float64(y + Float64(0.5 * x)) - Float64(y * Float64(z - log(z)))) end
function tmp = code(x, y, z) tmp = (y + (0.5 * x)) - (y * (z - log(z))); end
code[x_, y_, z_] := N[(N[(y + N[(0.5 * x), $MachinePrecision]), $MachinePrecision] - N[(y * N[(z - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + 0.5 \cdot x\right) - y \cdot \left(z - \log z\right)
\end{array}
herbie shell --seed 2024023
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(- (+ y (* 0.5 x)) (* y (- z (log z))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))