
(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 10 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 (* y (+ 1.0 (log z)))))
(if (<= z 3.9e-199)
t_0
(if (<= z 9.2e-175)
(* x 0.5)
(if (or (<= z 6.6e-86) (and (not (<= z 1.7e-66)) (<= z 2e-37)))
t_0
(- (* x 0.5) (* y z)))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 + log(z));
double tmp;
if (z <= 3.9e-199) {
tmp = t_0;
} else if (z <= 9.2e-175) {
tmp = x * 0.5;
} else if ((z <= 6.6e-86) || (!(z <= 1.7e-66) && (z <= 2e-37))) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 + log(z))
if (z <= 3.9d-199) then
tmp = t_0
else if (z <= 9.2d-175) then
tmp = x * 0.5d0
else if ((z <= 6.6d-86) .or. (.not. (z <= 1.7d-66)) .and. (z <= 2d-37)) then
tmp = t_0
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 + Math.log(z));
double tmp;
if (z <= 3.9e-199) {
tmp = t_0;
} else if (z <= 9.2e-175) {
tmp = x * 0.5;
} else if ((z <= 6.6e-86) || (!(z <= 1.7e-66) && (z <= 2e-37))) {
tmp = t_0;
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 + math.log(z)) tmp = 0 if z <= 3.9e-199: tmp = t_0 elif z <= 9.2e-175: tmp = x * 0.5 elif (z <= 6.6e-86) or (not (z <= 1.7e-66) and (z <= 2e-37)): tmp = t_0 else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 + log(z))) tmp = 0.0 if (z <= 3.9e-199) tmp = t_0; elseif (z <= 9.2e-175) tmp = Float64(x * 0.5); elseif ((z <= 6.6e-86) || (!(z <= 1.7e-66) && (z <= 2e-37))) tmp = t_0; else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 + log(z)); tmp = 0.0; if (z <= 3.9e-199) tmp = t_0; elseif (z <= 9.2e-175) tmp = x * 0.5; elseif ((z <= 6.6e-86) || (~((z <= 1.7e-66)) && (z <= 2e-37))) tmp = t_0; else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 3.9e-199], t$95$0, If[LessEqual[z, 9.2e-175], N[(x * 0.5), $MachinePrecision], If[Or[LessEqual[z, 6.6e-86], And[N[Not[LessEqual[z, 1.7e-66]], $MachinePrecision], LessEqual[z, 2e-37]]], t$95$0, N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
\mathbf{if}\;z \leq 3.9 \cdot 10^{-199}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-175}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 6.6 \cdot 10^{-86} \lor \neg \left(z \leq 1.7 \cdot 10^{-66}\right) \land z \leq 2 \cdot 10^{-37}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 3.9000000000000001e-199 or 9.2e-175 < z < 6.59999999999999974e-86 or 1.69999999999999999e-66 < z < 2.00000000000000013e-37Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
distribute-rgt-in99.6%
*-lft-identity99.6%
associate-+r+99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
distribute-lft-neg-out99.6%
unsub-neg99.6%
fma-def99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in y around -inf 62.4%
Taylor expanded in z around 0 62.4%
if 3.9000000000000001e-199 < z < 9.2e-175Initial program 100.0%
Taylor expanded in x around inf 80.5%
if 6.59999999999999974e-86 < z < 1.69999999999999999e-66 or 2.00000000000000013e-37 < z Initial program 100.0%
Taylor expanded in z around inf 94.4%
associate-*r*94.4%
neg-mul-194.4%
Simplified94.4%
Final simplification80.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ 1.0 (log z)))))
(if (<= z 2e-199)
t_0
(if (<= z 6e-176)
(* x 0.5)
(if (<= z 8.5e-86)
t_0
(if (or (<= z 2.5e-66) (not (<= z 7.2e-39)))
(- (* x 0.5) (* y z))
(+ y (* y (log z)))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 + log(z));
double tmp;
if (z <= 2e-199) {
tmp = t_0;
} else if (z <= 6e-176) {
tmp = x * 0.5;
} else if (z <= 8.5e-86) {
tmp = t_0;
} else if ((z <= 2.5e-66) || !(z <= 7.2e-39)) {
tmp = (x * 0.5) - (y * z);
} 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 = y * (1.0d0 + log(z))
if (z <= 2d-199) then
tmp = t_0
else if (z <= 6d-176) then
tmp = x * 0.5d0
else if (z <= 8.5d-86) then
tmp = t_0
else if ((z <= 2.5d-66) .or. (.not. (z <= 7.2d-39))) then
tmp = (x * 0.5d0) - (y * z)
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 = y * (1.0 + Math.log(z));
double tmp;
if (z <= 2e-199) {
tmp = t_0;
} else if (z <= 6e-176) {
tmp = x * 0.5;
} else if (z <= 8.5e-86) {
tmp = t_0;
} else if ((z <= 2.5e-66) || !(z <= 7.2e-39)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y + (y * Math.log(z));
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 + math.log(z)) tmp = 0 if z <= 2e-199: tmp = t_0 elif z <= 6e-176: tmp = x * 0.5 elif z <= 8.5e-86: tmp = t_0 elif (z <= 2.5e-66) or not (z <= 7.2e-39): tmp = (x * 0.5) - (y * z) else: tmp = y + (y * math.log(z)) return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 + log(z))) tmp = 0.0 if (z <= 2e-199) tmp = t_0; elseif (z <= 6e-176) tmp = Float64(x * 0.5); elseif (z <= 8.5e-86) tmp = t_0; elseif ((z <= 2.5e-66) || !(z <= 7.2e-39)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y + Float64(y * log(z))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 + log(z)); tmp = 0.0; if (z <= 2e-199) tmp = t_0; elseif (z <= 6e-176) tmp = x * 0.5; elseif (z <= 8.5e-86) tmp = t_0; elseif ((z <= 2.5e-66) || ~((z <= 7.2e-39))) tmp = (x * 0.5) - (y * z); else tmp = y + (y * log(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 2e-199], t$95$0, If[LessEqual[z, 6e-176], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 8.5e-86], t$95$0, If[Or[LessEqual[z, 2.5e-66], N[Not[LessEqual[z, 7.2e-39]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
\mathbf{if}\;z \leq 2 \cdot 10^{-199}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 6 \cdot 10^{-176}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-86}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-66} \lor \neg \left(z \leq 7.2 \cdot 10^{-39}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y + y \cdot \log z\\
\end{array}
\end{array}
if z < 1.99999999999999996e-199 or 6e-176 < z < 8.499999999999999e-86Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
distribute-rgt-in99.6%
*-lft-identity99.6%
associate-+r+99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
distribute-lft-neg-out99.6%
unsub-neg99.6%
fma-def99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in y around -inf 61.3%
Taylor expanded in z around 0 61.3%
if 1.99999999999999996e-199 < z < 6e-176Initial program 100.0%
Taylor expanded in x around inf 80.5%
if 8.499999999999999e-86 < z < 2.49999999999999981e-66 or 7.2000000000000001e-39 < z Initial program 100.0%
Taylor expanded in z around inf 94.4%
associate-*r*94.4%
neg-mul-194.4%
Simplified94.4%
if 2.49999999999999981e-66 < z < 7.2000000000000001e-39Initial program 99.6%
Taylor expanded in z around 0 99.6%
+-commutative99.6%
*-commutative99.6%
*-commutative99.6%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+l+99.7%
fma-def99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 70.1%
Final simplification80.9%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -2e+23) (not (<= (* x 0.5) 5e-93))) (- (* x 0.5) (* y z)) (* y (+ (- 1.0 z) (log z)))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -2e+23) || !((x * 0.5) <= 5e-93)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((1.0 - z) + 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 (((x * 0.5d0) <= (-2d+23)) .or. (.not. ((x * 0.5d0) <= 5d-93))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y * ((1.0d0 - z) + log(z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -2e+23) || !((x * 0.5) <= 5e-93)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((1.0 - z) + Math.log(z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -2e+23) or not ((x * 0.5) <= 5e-93): tmp = (x * 0.5) - (y * z) else: tmp = y * ((1.0 - z) + math.log(z)) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * 0.5) <= -2e+23) || !(Float64(x * 0.5) <= 5e-93)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y * Float64(Float64(1.0 - z) + log(z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * 0.5) <= -2e+23) || ~(((x * 0.5) <= 5e-93))) tmp = (x * 0.5) - (y * z); else tmp = y * ((1.0 - z) + log(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -2e+23], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-93]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -2 \cdot 10^{+23} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-93}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\left(1 - z\right) + \log z\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -1.9999999999999998e23 or 4.99999999999999994e-93 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 84.1%
associate-*r*84.1%
neg-mul-184.1%
Simplified84.1%
if -1.9999999999999998e23 < (*.f64 x 1/2) < 4.99999999999999994e-93Initial program 99.8%
sub-neg99.8%
associate-+l+99.8%
distribute-rgt-in99.7%
*-lft-identity99.7%
associate-+r+99.7%
neg-sub099.7%
associate-+l-99.7%
neg-sub099.7%
distribute-lft-neg-out99.7%
unsub-neg99.7%
fma-def99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in y around -inf 90.7%
Taylor expanded in z around 0 90.7%
+-commutative90.7%
+-commutative90.7%
associate-+r+90.7%
mul-1-neg90.7%
sub-neg90.7%
Simplified90.7%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (<= z 3.7e-6) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (- (fma x 0.5 y) (* y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.7e-6) {
tmp = (x * 0.5) + (y * (1.0 + log(z)));
} else {
tmp = fma(x, 0.5, y) - (y * z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 3.7e-6) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(1.0 + log(z)))); else tmp = Float64(fma(x, 0.5, y) - Float64(y * z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 3.7e-6], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5 + y), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.7 \cdot 10^{-6}:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, 0.5, y\right) - y \cdot z\\
\end{array}
\end{array}
if z < 3.7000000000000002e-6Initial program 99.8%
Taylor expanded in z around 0 99.6%
if 3.7000000000000002e-6 < z Initial program 100.0%
sub-neg100.0%
associate-+l+100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+r+100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
distribute-lft-neg-out100.0%
unsub-neg100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in z around inf 97.3%
Final simplification98.5%
(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 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 71.7%
associate-*r*71.7%
neg-mul-171.7%
Simplified71.7%
Final simplification71.7%
(FPCore (x y z) :precision binary64 (if (<= z 4.8e+14) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 4.8e+14) {
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 <= 4.8d+14) 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 <= 4.8e+14) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 4.8e+14: tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 4.8e+14) 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 <= 4.8e+14) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 4.8e+14], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.8 \cdot 10^{+14}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 4.8e14Initial program 99.8%
Taylor expanded in x around inf 47.6%
if 4.8e14 < z Initial program 100.0%
sub-neg100.0%
associate-+l+100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+r+100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
distribute-lft-neg-out100.0%
unsub-neg100.0%
fma-def100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in y around -inf 73.2%
Taylor expanded in z around inf 73.2%
associate-*r*73.2%
neg-mul-173.2%
Simplified73.2%
Final simplification58.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.5%
Final simplification39.5%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 99.9%
sub-neg99.9%
associate-+l+99.9%
distribute-rgt-in99.8%
*-lft-identity99.8%
associate-+r+99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
distribute-lft-neg-out99.8%
unsub-neg99.8%
fma-def99.8%
*-commutative99.8%
Simplified99.8%
add-cube-cbrt99.0%
pow399.0%
Applied egg-rr99.0%
Taylor expanded in y around inf 2.0%
Final simplification2.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 2023268
(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)))))