
(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 12 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(Float64(x * 0.5) + 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[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5 + y \cdot \left(1 - z\right)\right) + y \cdot \log z
\end{array}
Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
fma-udef99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+r+99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -5e-49) (not (<= (* x 0.5) 1e-24))) (- (* x 0.5) (* y z)) (* y (- (+ (log z) 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5e-49) || !((x * 0.5) <= 1e-24)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((log(z) + 1.0) - 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) <= (-5d-49)) .or. (.not. ((x * 0.5d0) <= 1d-24))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y * ((log(z) + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5e-49) || !((x * 0.5) <= 1e-24)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * ((Math.log(z) + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -5e-49) or not ((x * 0.5) <= 1e-24): tmp = (x * 0.5) - (y * z) else: tmp = y * ((math.log(z) + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * 0.5) <= -5e-49) || !(Float64(x * 0.5) <= 1e-24)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y * Float64(Float64(log(z) + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (((x * 0.5) <= -5e-49) || ~(((x * 0.5) <= 1e-24))) tmp = (x * 0.5) - (y * z); else tmp = y * ((log(z) + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-49], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 1e-24]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-49} \lor \neg \left(x \cdot 0.5 \leq 10^{-24}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\left(\log z + 1\right) - z\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.9999999999999999e-49 or 9.99999999999999924e-25 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 88.6%
associate-*r*88.6%
neg-mul-188.6%
Simplified88.6%
if -4.9999999999999999e-49 < (*.f64 x 1/2) < 9.99999999999999924e-25Initial program 99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+r+99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 95.2%
Final simplification91.6%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -5e-49) (not (<= (* x 0.5) 1e-24))) (- (* x 0.5) (* y z)) (+ y (* y (- (log z) z)))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5e-49) || !((x * 0.5) <= 1e-24)) {
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) <= (-5d-49)) .or. (.not. ((x * 0.5d0) <= 1d-24))) 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) <= -5e-49) || !((x * 0.5) <= 1e-24)) {
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) <= -5e-49) or not ((x * 0.5) <= 1e-24): 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) <= -5e-49) || !(Float64(x * 0.5) <= 1e-24)) 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) <= -5e-49) || ~(((x * 0.5) <= 1e-24))) 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], -5e-49], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 1e-24]], $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 \cdot 10^{-49} \lor \neg \left(x \cdot 0.5 \leq 10^{-24}\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) < -4.9999999999999999e-49 or 9.99999999999999924e-25 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 88.6%
associate-*r*88.6%
neg-mul-188.6%
Simplified88.6%
if -4.9999999999999999e-49 < (*.f64 x 1/2) < 9.99999999999999924e-25Initial program 99.8%
sub-neg99.8%
associate-+l+99.8%
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%
Taylor expanded in x around 0 95.3%
Final simplification91.6%
(FPCore (x y z) :precision binary64 (if (<= z 1.15e-5) (+ (* x 0.5) (* y (+ (log z) 1.0))) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.15e-5) {
tmp = (x * 0.5) + (y * (log(z) + 1.0));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 1.15e-5) tmp = Float64(Float64(x * 0.5) + Float64(y * Float64(log(z) + 1.0))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 1.15e-5], N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.15 \cdot 10^{-5}:\\
\;\;\;\;x \cdot 0.5 + y \cdot \left(\log z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 1.15e-5Initial program 99.8%
Taylor expanded in z around 0 99.0%
if 1.15e-5 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification99.0%
(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 (if (<= z 7.5e-201) (- (* x 0.5) (* y z)) (if (<= z 5.2e-10) (* y (+ (log z) 1.0)) (fma y (- z) (* x 0.5)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 7.5e-201) {
tmp = (x * 0.5) - (y * z);
} else if (z <= 5.2e-10) {
tmp = y * (log(z) + 1.0);
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= 7.5e-201) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); elseif (z <= 5.2e-10) tmp = Float64(y * Float64(log(z) + 1.0)); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, 7.5e-201], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.2e-10], N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.5 \cdot 10^{-201}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-10}:\\
\;\;\;\;y \cdot \left(\log z + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 7.49999999999999987e-201Initial program 99.8%
Taylor expanded in z around inf 58.5%
associate-*r*58.5%
neg-mul-158.5%
Simplified58.5%
if 7.49999999999999987e-201 < z < 5.19999999999999962e-10Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
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 x around 0 62.0%
Taylor expanded in z around 0 60.8%
associate-*r*60.8%
neg-mul-160.8%
cancel-sign-sub60.8%
Simplified60.8%
*-un-lft-identity60.8%
*-commutative60.8%
distribute-rgt-in60.8%
*-commutative60.8%
Applied egg-rr60.8%
if 5.19999999999999962e-10 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.9%
mul-1-neg98.9%
Simplified98.9%
Final simplification79.7%
(FPCore (x y z) :precision binary64 (if (or (<= z 4.6e-201) (not (<= z 2.3e-9))) (- (* x 0.5) (* y z)) (* y (+ (log z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 4.6e-201) || !(z <= 2.3e-9)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * (log(z) + 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 ((z <= 4.6d-201) .or. (.not. (z <= 2.3d-9))) then
tmp = (x * 0.5d0) - (y * z)
else
tmp = y * (log(z) + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 4.6e-201) || !(z <= 2.3e-9)) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * (Math.log(z) + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 4.6e-201) or not (z <= 2.3e-9): tmp = (x * 0.5) - (y * z) else: tmp = y * (math.log(z) + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 4.6e-201) || !(z <= 2.3e-9)) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); else tmp = Float64(y * Float64(log(z) + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 4.6e-201) || ~((z <= 2.3e-9))) tmp = (x * 0.5) - (y * z); else tmp = y * (log(z) + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 4.6e-201], N[Not[LessEqual[z, 2.3e-9]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.6 \cdot 10^{-201} \lor \neg \left(z \leq 2.3 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\log z + 1\right)\\
\end{array}
\end{array}
if z < 4.59999999999999971e-201 or 2.2999999999999999e-9 < z Initial program 99.9%
Taylor expanded in z around inf 87.5%
associate-*r*87.5%
neg-mul-187.5%
Simplified87.5%
if 4.59999999999999971e-201 < z < 2.2999999999999999e-9Initial program 99.7%
sub-neg99.7%
associate-+l+99.7%
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 x around 0 62.0%
Taylor expanded in z around 0 60.8%
associate-*r*60.8%
neg-mul-160.8%
cancel-sign-sub60.8%
Simplified60.8%
*-un-lft-identity60.8%
*-commutative60.8%
distribute-rgt-in60.8%
*-commutative60.8%
Applied egg-rr60.8%
Final simplification79.7%
(FPCore (x y z) :precision binary64 (if (<= z 430000.0) (* x 0.5) (- y (* y z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 430000.0) {
tmp = x * 0.5;
} else {
tmp = y - (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 <= 430000.0d0) then
tmp = x * 0.5d0
else
tmp = y - (y * z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 430000.0) {
tmp = x * 0.5;
} else {
tmp = y - (y * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 430000.0: tmp = x * 0.5 else: tmp = y - (y * z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 430000.0) tmp = Float64(x * 0.5); else tmp = Float64(y - Float64(y * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 430000.0) tmp = x * 0.5; else tmp = y - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 430000.0], N[(x * 0.5), $MachinePrecision], N[(y - N[(y * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 430000:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot z\\
\end{array}
\end{array}
if z < 4.3e5Initial program 99.7%
Taylor expanded in x around inf 48.7%
if 4.3e5 < 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 x around 0 79.9%
Taylor expanded in z around inf 79.4%
Final simplification63.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.9%
Taylor expanded in z around inf 74.4%
associate-*r*74.4%
neg-mul-174.4%
Simplified74.4%
Final simplification74.4%
(FPCore (x y z) :precision binary64 (if (<= z 350000.0) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= 350000.0) {
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 <= 350000.0d0) 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 <= 350000.0) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 350000.0: tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= 350000.0) 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 <= 350000.0) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 350000.0], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 350000:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 3.5e5Initial program 99.7%
Taylor expanded in x around inf 48.7%
if 3.5e5 < z Initial program 100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
fma-udef100.0%
+-commutative100.0%
distribute-lft-in100.0%
associate-+r+100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 79.4%
mul-1-neg79.4%
distribute-rgt-neg-in79.4%
Simplified79.4%
Final simplification63.8%
(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 35.4%
Final simplification35.4%
(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.9%
*-lft-identity99.9%
associate-+r+99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
distribute-lft-neg-out99.9%
unsub-neg99.9%
fma-def99.9%
*-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 66.8%
Taylor expanded in z around inf 40.2%
Taylor expanded in z around 0 1.7%
Final simplification1.7%
(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 2023287
(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)))))