
(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 (+ (* x 0.5) (+ (* y (- 1.0 z)) (* y (log z)))))
double code(double x, double y, double z) {
return (x * 0.5) + ((y * (1.0 - z)) + (y * 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)) + (y * log(z)))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + ((y * (1.0 - z)) + (y * Math.log(z)));
}
def code(x, y, z): return (x * 0.5) + ((y * (1.0 - z)) + (y * math.log(z)))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(Float64(y * Float64(1.0 - z)) + Float64(y * log(z)))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + ((y * (1.0 - z)) + (y * log(z))); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision] + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + \left(y \cdot \left(1 - z\right) + y \cdot \log z\right)
\end{array}
Initial program 99.8%
distribute-lft-in99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -5.0) (not (<= (* x 0.5) 5e-94))) (- (* x 0.5) (* y z)) (* y (- (+ 1.0 (log z)) z))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5.0) || !((x * 0.5) <= 5e-94)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((1.0 + log(z)) - 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) <= (-5.0d0)) .or. (.not. ((x * 0.5d0) <= 5d-94))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y * ((1.0d0 + log(z)) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5.0) || !((x * 0.5) <= 5e-94)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((1.0 + Math.log(z)) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -5.0) or not ((x * 0.5) <= 5e-94): tmp = (x * 0.5) - (y * z) else: tmp = y * ((1.0 + math.log(z)) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * 0.5) <= -5.0) || !(Float64(x * 0.5) <= 5e-94)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y * Float64(Float64(1.0 + log(z)) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * 0.5) <= -5.0) || ~(((x * 0.5) <= 5e-94))) tmp = (x * 0.5) - (y * z); else tmp = y * ((1.0 + log(z)) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -5.0], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-94]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-94}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -5 or 4.9999999999999995e-94 < (*.f64 x 1/2) Initial program 100.0%
Taylor expanded in z around inf 88.0%
mul-1-neg88.0%
distribute-rgt-neg-out88.0%
Simplified88.0%
if -5 < (*.f64 x 1/2) < 4.9999999999999995e-94Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-def99.7%
sub-neg99.7%
associate-+l+99.7%
+-commutative99.7%
sub-neg99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 92.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -5.0) (not (<= (* x 0.5) 5e-94))) (- (* x 0.5) (* y z)) (+ y (* y (- (log z) z)))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5.0) || !((x * 0.5) <= 5e-94)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y + (y * (log(z) - 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) <= (-5.0d0)) .or. (.not. ((x * 0.5d0) <= 5d-94))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y + (y * (log(z) - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5.0) || !((x * 0.5) <= 5e-94)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y + (y * (Math.log(z) - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -5.0) or not ((x * 0.5) <= 5e-94): tmp = (x * 0.5) - (y * z) else: tmp = y + (y * (math.log(z) - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * 0.5) <= -5.0) || !(Float64(x * 0.5) <= 5e-94)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y + Float64(y * Float64(log(z) - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * 0.5) <= -5.0) || ~(((x * 0.5) <= 5e-94))) tmp = (x * 0.5) - (y * z); else tmp = y + (y * (log(z) - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -5.0], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-94]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y + N[(y * N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-94}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y + y \cdot \left(\log z - z\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -5 or 4.9999999999999995e-94 < (*.f64 x 1/2) Initial program 100.0%
Taylor expanded in z around inf 88.0%
mul-1-neg88.0%
distribute-rgt-neg-out88.0%
Simplified88.0%
if -5 < (*.f64 x 1/2) < 4.9999999999999995e-94Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
associate-+r+99.7%
fma-def99.7%
+-commutative99.7%
unsub-neg99.7%
Simplified99.7%
Taylor expanded in x around 0 92.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= z 7.4e-150) (and (not (<= z 1.2e-106)) (<= z 6e-12))) (* y (+ 1.0 (log z))) (- (* x 0.5) (* y z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 7.4e-150) || (!(z <= 1.2e-106) && (z <= 6e-12))) {
tmp = y * (1.0 + log(z));
} 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) :: tmp
if ((z <= 7.4d-150) .or. (.not. (z <= 1.2d-106)) .and. (z <= 6d-12)) then
tmp = y * (1.0d0 + log(z))
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 7.4e-150) || (!(z <= 1.2e-106) && (z <= 6e-12))) {
tmp = y * (1.0 + Math.log(z));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 7.4e-150) or (not (z <= 1.2e-106) and (z <= 6e-12)): tmp = y * (1.0 + math.log(z)) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 7.4e-150) || (!(z <= 1.2e-106) && (z <= 6e-12))) tmp = Float64(y * Float64(1.0 + log(z))); else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 7.4e-150) || (~((z <= 1.2e-106)) && (z <= 6e-12))) tmp = y * (1.0 + log(z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 7.4e-150], And[N[Not[LessEqual[z, 1.2e-106]], $MachinePrecision], LessEqual[z, 6e-12]]], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.4 \cdot 10^{-150} \lor \neg \left(z \leq 1.2 \cdot 10^{-106}\right) \land z \leq 6 \cdot 10^{-12}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 7.40000000000000002e-150 or 1.1999999999999999e-106 < z < 6.0000000000000003e-12Initial program 99.7%
Taylor expanded in z around 0 99.5%
Taylor expanded in x around 0 66.5%
if 7.40000000000000002e-150 < z < 1.1999999999999999e-106 or 6.0000000000000003e-12 < z Initial program 100.0%
Taylor expanded in z around inf 93.3%
mul-1-neg93.3%
distribute-rgt-neg-out93.3%
Simplified93.3%
Final simplification82.5%
(FPCore (x y z)
:precision binary64
(if (<= z 1.55e-152)
(* y (+ 1.0 (log z)))
(if (or (<= z 1.35e-106) (not (<= z 2.2e-11)))
(- (* x 0.5) (* y z))
(+ y (* y (log z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.55e-152) {
tmp = y * (1.0 + log(z));
} else if ((z <= 1.35e-106) || !(z <= 2.2e-11)) {
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) :: tmp
if (z <= 1.55d-152) then
tmp = y * (1.0d0 + log(z))
else if ((z <= 1.35d-106) .or. (.not. (z <= 2.2d-11))) 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 tmp;
if (z <= 1.55e-152) {
tmp = y * (1.0 + Math.log(z));
} else if ((z <= 1.35e-106) || !(z <= 2.2e-11)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y + (y * Math.log(z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.55e-152: tmp = y * (1.0 + math.log(z)) elif (z <= 1.35e-106) or not (z <= 2.2e-11): tmp = (x * 0.5) - (y * z) else: tmp = y + (y * math.log(z)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.55e-152) tmp = Float64(y * Float64(1.0 + log(z))); elseif ((z <= 1.35e-106) || !(z <= 2.2e-11)) 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) tmp = 0.0; if (z <= 1.55e-152) tmp = y * (1.0 + log(z)); elseif ((z <= 1.35e-106) || ~((z <= 2.2e-11))) tmp = (x * 0.5) - (y * z); else tmp = y + (y * log(z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.55e-152], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.35e-106], N[Not[LessEqual[z, 2.2e-11]], $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}
\mathbf{if}\;z \leq 1.55 \cdot 10^{-152}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{-106} \lor \neg \left(z \leq 2.2 \cdot 10^{-11}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y + y \cdot \log z\\
\end{array}
\end{array}
if z < 1.5499999999999999e-152Initial program 99.7%
Taylor expanded in z around 0 99.7%
Taylor expanded in x around 0 65.0%
if 1.5499999999999999e-152 < z < 1.35000000000000011e-106 or 2.2000000000000002e-11 < z Initial program 100.0%
Taylor expanded in z around inf 93.3%
mul-1-neg93.3%
distribute-rgt-neg-out93.3%
Simplified93.3%
if 1.35000000000000011e-106 < z < 2.2000000000000002e-11Initial program 99.6%
distribute-lft-in99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 69.3%
Taylor expanded in z around 0 69.0%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (- (* x 0.5) (* y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 0.28) {
tmp = (x * 0.5) + (y * (1.0 + log(z)));
} 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) :: tmp
if (z <= 0.28d0) then
tmp = (x * 0.5d0) + (y * (1.0d0 + log(z)))
else
tmp = (x * 0.5d0) - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 0.28) {
tmp = (x * 0.5) + (y * (1.0 + Math.log(z)));
} else {
tmp = (x * 0.5) - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 0.28: tmp = (x * 0.5) + (y * (1.0 + math.log(z))) else: tmp = (x * 0.5) - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 0.28) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(1.0 + log(z)))); else tmp = Float64(Float64(x * 0.5) - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 0.28) tmp = (x * 0.5) + (y * (1.0 + log(z))); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 0.28], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 0.28:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 0.28000000000000003Initial program 99.7%
Taylor expanded in z around 0 99.0%
if 0.28000000000000003 < z Initial program 100.0%
Taylor expanded in z around inf 99.3%
mul-1-neg99.3%
distribute-rgt-neg-out99.3%
Simplified99.3%
Final simplification99.2%
(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.8%
Final simplification99.8%
(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.8%
Taylor expanded in z around inf 70.7%
mul-1-neg70.7%
distribute-rgt-neg-out70.7%
Simplified70.7%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (if (<= z 4.6e+16) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 4.6e+16) {
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.6d+16) 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.6e+16) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 4.6e+16: tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 4.6e+16) 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.6e+16) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 4.6e+16], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.6 \cdot 10^{+16}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 4.6e16Initial program 99.7%
Taylor expanded in x around inf 41.8%
if 4.6e16 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
fma-def100.0%
sub-neg100.0%
associate-+l+100.0%
+-commutative100.0%
sub-neg100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 76.1%
mul-1-neg76.1%
*-commutative76.1%
distribute-rgt-neg-in76.1%
Simplified76.1%
Final simplification58.3%
(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.8%
Taylor expanded in x around inf 33.8%
Final simplification33.8%
(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 2023224
(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)))))