
(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 9 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 (+ (- 1.0 z) (log z)) y (* x 0.5)))
double code(double x, double y, double z) {
return fma(((1.0 - z) + log(z)), y, (x * 0.5));
}
function code(x, y, z) return fma(Float64(Float64(1.0 - z) + log(z)), y, Float64(x * 0.5)) end
code[x_, y_, z_] := N[(N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] * y + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(1 - z\right) + \log z, y, x \cdot 0.5\right)
\end{array}
Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
Applied egg-rr99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ 1.0 (log z)))) (t_1 (- (* x 0.5) (* z y))))
(if (<= z 1.7e-247)
(+ y (* (log z) y))
(if (<= z 4.1e-221)
t_1
(if (<= z 2.7e-159)
t_0
(if (<= z 2.3e-131)
(* x (- 0.5 (* y (/ z x))))
(if (<= z 2.3e-17) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 + log(z));
double t_1 = (x * 0.5) - (z * y);
double tmp;
if (z <= 1.7e-247) {
tmp = y + (log(z) * y);
} else if (z <= 4.1e-221) {
tmp = t_1;
} else if (z <= 2.7e-159) {
tmp = t_0;
} else if (z <= 2.3e-131) {
tmp = x * (0.5 - (y * (z / x)));
} else if (z <= 2.3e-17) {
tmp = t_0;
} 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 = y * (1.0d0 + log(z))
t_1 = (x * 0.5d0) - (z * y)
if (z <= 1.7d-247) then
tmp = y + (log(z) * y)
else if (z <= 4.1d-221) then
tmp = t_1
else if (z <= 2.7d-159) then
tmp = t_0
else if (z <= 2.3d-131) then
tmp = x * (0.5d0 - (y * (z / x)))
else if (z <= 2.3d-17) then
tmp = t_0
else
tmp = t_1
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 t_1 = (x * 0.5) - (z * y);
double tmp;
if (z <= 1.7e-247) {
tmp = y + (Math.log(z) * y);
} else if (z <= 4.1e-221) {
tmp = t_1;
} else if (z <= 2.7e-159) {
tmp = t_0;
} else if (z <= 2.3e-131) {
tmp = x * (0.5 - (y * (z / x)));
} else if (z <= 2.3e-17) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 + math.log(z)) t_1 = (x * 0.5) - (z * y) tmp = 0 if z <= 1.7e-247: tmp = y + (math.log(z) * y) elif z <= 4.1e-221: tmp = t_1 elif z <= 2.7e-159: tmp = t_0 elif z <= 2.3e-131: tmp = x * (0.5 - (y * (z / x))) elif z <= 2.3e-17: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 + log(z))) t_1 = Float64(Float64(x * 0.5) - Float64(z * y)) tmp = 0.0 if (z <= 1.7e-247) tmp = Float64(y + Float64(log(z) * y)); elseif (z <= 4.1e-221) tmp = t_1; elseif (z <= 2.7e-159) tmp = t_0; elseif (z <= 2.3e-131) tmp = Float64(x * Float64(0.5 - Float64(y * Float64(z / x)))); elseif (z <= 2.3e-17) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 + log(z)); t_1 = (x * 0.5) - (z * y); tmp = 0.0; if (z <= 1.7e-247) tmp = y + (log(z) * y); elseif (z <= 4.1e-221) tmp = t_1; elseif (z <= 2.7e-159) tmp = t_0; elseif (z <= 2.3e-131) tmp = x * (0.5 - (y * (z / x))); elseif (z <= 2.3e-17) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.7e-247], N[(y + N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.1e-221], t$95$1, If[LessEqual[z, 2.7e-159], t$95$0, If[LessEqual[z, 2.3e-131], N[(x * N[(0.5 - N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.3e-17], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
t_1 := x \cdot 0.5 - z \cdot y\\
\mathbf{if}\;z \leq 1.7 \cdot 10^{-247}:\\
\;\;\;\;y + \log z \cdot y\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{-221}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-131}:\\
\;\;\;\;x \cdot \left(0.5 - y \cdot \frac{z}{x}\right)\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < 1.7000000000000001e-247Initial program 99.5%
+-commutative99.5%
*-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 59.3%
associate--l+59.3%
distribute-lft-in59.3%
*-rgt-identity59.3%
Simplified59.3%
Taylor expanded in z around 0 59.3%
if 1.7000000000000001e-247 < z < 4.09999999999999981e-221 or 2.30000000000000009e-17 < z Initial program 99.9%
Taylor expanded in z around inf 94.4%
mul-1-neg94.4%
distribute-rgt-neg-in94.4%
Simplified94.4%
if 4.09999999999999981e-221 < z < 2.7e-159 or 2.30000000000000022e-131 < z < 2.30000000000000009e-17Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 64.9%
associate--l+64.9%
distribute-lft-in64.8%
*-rgt-identity64.8%
Simplified64.8%
Taylor expanded in z around 0 64.8%
Taylor expanded in y around 0 64.9%
if 2.7e-159 < z < 2.30000000000000022e-131Initial program 99.8%
distribute-lft-in99.8%
associate-+r+99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 93.1%
associate-/l*93.2%
associate-/l*93.2%
distribute-lft-out93.7%
Simplified93.7%
Taylor expanded in z around inf 74.7%
mul-1-neg74.7%
associate-/l*74.7%
distribute-rgt-neg-in74.7%
distribute-frac-neg74.7%
Simplified74.7%
Final simplification81.6%
(FPCore (x y z) :precision binary64 (if (or (<= (* x 0.5) -1e-50) (not (<= (* x 0.5) 1e-49))) (- (* x 0.5) (* z y)) (* y (- (+ 1.0 (log z)) z))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -1e-50) || !((x * 0.5) <= 1e-49)) {
tmp = (x * 0.5) - (z * y);
} 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) <= (-1d-50)) .or. (.not. ((x * 0.5d0) <= 1d-49))) then
tmp = (x * 0.5d0) - (z * y)
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) <= -1e-50) || !((x * 0.5) <= 1e-49)) {
tmp = (x * 0.5) - (z * y);
} else {
tmp = y * ((1.0 + Math.log(z)) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -1e-50) or not ((x * 0.5) <= 1e-49): tmp = (x * 0.5) - (z * y) else: tmp = y * ((1.0 + math.log(z)) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((Float64(x * 0.5) <= -1e-50) || !(Float64(x * 0.5) <= 1e-49)) tmp = Float64(Float64(x * 0.5) - Float64(z * y)); 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) <= -1e-50) || ~(((x * 0.5) <= 1e-49))) tmp = (x * 0.5) - (z * y); 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], -1e-50], N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 1e-49]], $MachinePrecision]], N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $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 -1 \cdot 10^{-50} \lor \neg \left(x \cdot 0.5 \leq 10^{-49}\right):\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\
\end{array}
\end{array}
if (*.f64 x #s(literal 1/2 binary64)) < -1.00000000000000001e-50 or 9.99999999999999936e-50 < (*.f64 x #s(literal 1/2 binary64)) Initial program 99.9%
Taylor expanded in z around inf 86.6%
mul-1-neg86.6%
distribute-rgt-neg-in86.6%
Simplified86.6%
if -1.00000000000000001e-50 < (*.f64 x #s(literal 1/2 binary64)) < 9.99999999999999936e-50Initial program 99.7%
Taylor expanded in x around 0 90.3%
Final simplification88.3%
(FPCore (x y z) :precision binary64 (if (or (<= z 5.4e-248) (and (not (<= z 4.6e-222)) (<= z 1e-17))) (* y (+ 1.0 (log z))) (- (* x 0.5) (* z y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 5.4e-248) || (!(z <= 4.6e-222) && (z <= 1e-17))) {
tmp = y * (1.0 + log(z));
} else {
tmp = (x * 0.5) - (z * y);
}
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 <= 5.4d-248) .or. (.not. (z <= 4.6d-222)) .and. (z <= 1d-17)) then
tmp = y * (1.0d0 + log(z))
else
tmp = (x * 0.5d0) - (z * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= 5.4e-248) || (!(z <= 4.6e-222) && (z <= 1e-17))) {
tmp = y * (1.0 + Math.log(z));
} else {
tmp = (x * 0.5) - (z * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 5.4e-248) or (not (z <= 4.6e-222) and (z <= 1e-17)): tmp = y * (1.0 + math.log(z)) else: tmp = (x * 0.5) - (z * y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 5.4e-248) || (!(z <= 4.6e-222) && (z <= 1e-17))) tmp = Float64(y * Float64(1.0 + log(z))); else tmp = Float64(Float64(x * 0.5) - Float64(z * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 5.4e-248) || (~((z <= 4.6e-222)) && (z <= 1e-17))) tmp = y * (1.0 + log(z)); else tmp = (x * 0.5) - (z * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 5.4e-248], And[N[Not[LessEqual[z, 4.6e-222]], $MachinePrecision], LessEqual[z, 1e-17]]], N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.4 \cdot 10^{-248} \lor \neg \left(z \leq 4.6 \cdot 10^{-222}\right) \land z \leq 10^{-17}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - z \cdot y\\
\end{array}
\end{array}
if z < 5.4000000000000002e-248 or 4.6000000000000003e-222 < z < 1.00000000000000007e-17Initial program 99.7%
+-commutative99.7%
*-commutative99.7%
fma-define99.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 59.0%
associate--l+59.0%
distribute-lft-in58.9%
*-rgt-identity58.9%
Simplified58.9%
Taylor expanded in z around 0 58.9%
Taylor expanded in y around 0 59.0%
if 5.4000000000000002e-248 < z < 4.6000000000000003e-222 or 1.00000000000000007e-17 < z Initial program 99.9%
Taylor expanded in z around inf 94.4%
mul-1-neg94.4%
distribute-rgt-neg-in94.4%
Simplified94.4%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (- (* x 0.5) (* z y))))
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) - (z * y);
}
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) - (z * y)
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) - (z * y);
}
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) - (z * y) 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(z * y)); 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) - (z * y); 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[(z * y), $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 - z \cdot y\\
\end{array}
\end{array}
if z < 0.28000000000000003Initial program 99.7%
Taylor expanded in z around 0 98.8%
if 0.28000000000000003 < z Initial program 100.0%
Taylor expanded in z around inf 98.7%
mul-1-neg98.7%
distribute-rgt-neg-in98.7%
Simplified98.7%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* (+ (- 1.0 z) (log z)) y)))
double code(double x, double y, double z) {
return (x * 0.5) + (((1.0 - z) + log(z)) * y);
}
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) + (((1.0d0 - z) + log(z)) * y)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (((1.0 - z) + Math.log(z)) * y);
}
def code(x, y, z): return (x * 0.5) + (((1.0 - z) + math.log(z)) * y)
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(Float64(Float64(1.0 - z) + log(z)) * y)) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (((1.0 - z) + log(z)) * y); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(N[(N[(1.0 - z), $MachinePrecision] + N[Log[z], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + \left(\left(1 - z\right) + \log z\right) \cdot y
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= z 3.1e+28) (* x 0.5) (* z (- y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 3.1e+28) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
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 <= 3.1d+28) then
tmp = x * 0.5d0
else
tmp = z * -y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 3.1e+28) {
tmp = x * 0.5;
} else {
tmp = z * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 3.1e+28: tmp = x * 0.5 else: tmp = z * -y return tmp
function code(x, y, z) tmp = 0.0 if (z <= 3.1e+28) tmp = Float64(x * 0.5); else tmp = Float64(z * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 3.1e+28) tmp = x * 0.5; else tmp = z * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 3.1e+28], N[(x * 0.5), $MachinePrecision], N[(z * (-y)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.1 \cdot 10^{+28}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-y\right)\\
\end{array}
\end{array}
if z < 3.1000000000000001e28Initial program 99.7%
Taylor expanded in x around inf 47.2%
if 3.1000000000000001e28 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
fma-define100.0%
Applied egg-rr100.0%
Taylor expanded in z around inf 75.5%
mul-1-neg75.5%
distribute-rgt-neg-in75.5%
Simplified75.5%
Final simplification59.4%
(FPCore (x y z) :precision binary64 (- (* x 0.5) (* z y)))
double code(double x, double y, double z) {
return (x * 0.5) - (z * y);
}
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) - (z * y)
end function
public static double code(double x, double y, double z) {
return (x * 0.5) - (z * y);
}
def code(x, y, z): return (x * 0.5) - (z * y)
function code(x, y, z) return Float64(Float64(x * 0.5) - Float64(z * y)) end
function tmp = code(x, y, z) tmp = (x * 0.5) - (z * y); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] - N[(z * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 - z \cdot y
\end{array}
Initial program 99.8%
Taylor expanded in z around inf 72.1%
mul-1-neg72.1%
distribute-rgt-neg-in72.1%
Simplified72.1%
Final simplification72.1%
(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 37.3%
Final simplification37.3%
(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 2024097
(FPCore (x y z)
:name "System.Random.MWC.Distributions:gamma from mwc-random-0.13.3.2"
:precision binary64
:alt
(- (+ y (* 0.5 x)) (* y (- z (log z))))
(+ (* x 0.5) (* y (+ (- 1.0 z) (log z)))))