
(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.8%
+-commutative99.8%
fma-def99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ (log z) 1.0))) (t_1 (fma y (- z) (* x 0.5))))
(if (<= (* x 0.5) -5e-306)
t_1
(if (<= (* x 0.5) 5e-239)
t_0
(if (<= (* x 0.5) 2e-163)
(- (* x 0.5) (* y z))
(if (<= (* x 0.5) 2e-87) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = y * (log(z) + 1.0);
double t_1 = fma(y, -z, (x * 0.5));
double tmp;
if ((x * 0.5) <= -5e-306) {
tmp = t_1;
} else if ((x * 0.5) <= 5e-239) {
tmp = t_0;
} else if ((x * 0.5) <= 2e-163) {
tmp = (x * 0.5) - (y * z);
} else if ((x * 0.5) <= 2e-87) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * Float64(log(z) + 1.0)) t_1 = fma(y, Float64(-z), Float64(x * 0.5)) tmp = 0.0 if (Float64(x * 0.5) <= -5e-306) tmp = t_1; elseif (Float64(x * 0.5) <= 5e-239) tmp = t_0; elseif (Float64(x * 0.5) <= 2e-163) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); elseif (Float64(x * 0.5) <= 2e-87) tmp = t_0; else tmp = t_1; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(N[Log[z], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-306], t$95$1, If[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-239], t$95$0, If[LessEqual[N[(x * 0.5), $MachinePrecision], 2e-163], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 2e-87], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(\log z + 1\right)\\
t_1 := \mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-306}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \cdot 0.5 \leq 5 \cdot 10^{-239}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \cdot 0.5 \leq 2 \cdot 10^{-163}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{elif}\;x \cdot 0.5 \leq 2 \cdot 10^{-87}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.99999999999999998e-306 or 2.00000000000000004e-87 < (*.f64 x 1/2) Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 82.1%
mul-1-neg82.1%
Simplified82.1%
if -4.99999999999999998e-306 < (*.f64 x 1/2) < 5e-239 or 1.99999999999999985e-163 < (*.f64 x 1/2) < 2.00000000000000004e-87Initial program 99.4%
Taylor expanded in z around 0 78.9%
Taylor expanded in x around 0 71.7%
if 5e-239 < (*.f64 x 1/2) < 1.99999999999999985e-163Initial program 100.0%
Taylor expanded in z around inf 80.9%
mul-1-neg80.9%
distribute-rgt-neg-in80.9%
Simplified80.9%
distribute-rgt-neg-out80.9%
unsub-neg80.9%
add-sqr-sqrt80.7%
sqrt-unprod65.7%
sqr-neg65.7%
sqrt-unprod0.0%
add-sqr-sqrt25.8%
*-commutative25.8%
add-sqr-sqrt0.0%
sqrt-unprod65.7%
sqr-neg65.7%
sqrt-unprod80.7%
add-sqr-sqrt80.9%
Applied egg-rr80.9%
Final simplification80.8%
(FPCore (x y z)
:precision binary64
(if (or (<= (* x 0.5) -5e-306)
(not
(or (<= (* x 0.5) 5e-239)
(and (not (<= (* x 0.5) 2e-163)) (<= (* x 0.5) 2e-87)))))
(- (* x 0.5) (* y z))
(* y (+ (log z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (((x * 0.5) <= -5e-306) || !(((x * 0.5) <= 5e-239) || (!((x * 0.5) <= 2e-163) && ((x * 0.5) <= 2e-87)))) {
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 (((x * 0.5d0) <= (-5d-306)) .or. (.not. ((x * 0.5d0) <= 5d-239) .or. (.not. ((x * 0.5d0) <= 2d-163)) .and. ((x * 0.5d0) <= 2d-87))) 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 (((x * 0.5) <= -5e-306) || !(((x * 0.5) <= 5e-239) || (!((x * 0.5) <= 2e-163) && ((x * 0.5) <= 2e-87)))) {
tmp = (x * 0.5) - (y * z);
} else {
tmp = y * (Math.log(z) + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if ((x * 0.5) <= -5e-306) or not (((x * 0.5) <= 5e-239) or (not ((x * 0.5) <= 2e-163) and ((x * 0.5) <= 2e-87))): 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 ((Float64(x * 0.5) <= -5e-306) || !((Float64(x * 0.5) <= 5e-239) || (!(Float64(x * 0.5) <= 2e-163) && (Float64(x * 0.5) <= 2e-87)))) 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 (((x * 0.5) <= -5e-306) || ~((((x * 0.5) <= 5e-239) || (~(((x * 0.5) <= 2e-163)) && ((x * 0.5) <= 2e-87))))) 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[N[(x * 0.5), $MachinePrecision], -5e-306], N[Not[Or[LessEqual[N[(x * 0.5), $MachinePrecision], 5e-239], And[N[Not[LessEqual[N[(x * 0.5), $MachinePrecision], 2e-163]], $MachinePrecision], LessEqual[N[(x * 0.5), $MachinePrecision], 2e-87]]]], $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}\;x \cdot 0.5 \leq -5 \cdot 10^{-306} \lor \neg \left(x \cdot 0.5 \leq 5 \cdot 10^{-239} \lor \neg \left(x \cdot 0.5 \leq 2 \cdot 10^{-163}\right) \land x \cdot 0.5 \leq 2 \cdot 10^{-87}\right):\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(\log z + 1\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.99999999999999998e-306 or 5e-239 < (*.f64 x 1/2) < 1.99999999999999985e-163 or 2.00000000000000004e-87 < (*.f64 x 1/2) Initial program 99.9%
Taylor expanded in z around inf 82.0%
mul-1-neg82.0%
distribute-rgt-neg-in82.0%
Simplified82.0%
distribute-rgt-neg-out82.0%
unsub-neg82.0%
add-sqr-sqrt81.8%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod0.0%
add-sqr-sqrt50.3%
*-commutative50.3%
add-sqr-sqrt0.0%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod81.8%
add-sqr-sqrt82.0%
Applied egg-rr82.0%
if -4.99999999999999998e-306 < (*.f64 x 1/2) < 5e-239 or 1.99999999999999985e-163 < (*.f64 x 1/2) < 2.00000000000000004e-87Initial program 99.4%
Taylor expanded in z around 0 78.9%
Taylor expanded in x around 0 71.7%
Final simplification80.8%
(FPCore (x y z)
:precision binary64
(if (<= (* x 0.5) -5e-41)
(- (* x 0.5) (* y z))
(if (<= (* x 0.5) 2e-87)
(- y (* y (- z (log z))))
(fma y (- z) (* x 0.5)))))
double code(double x, double y, double z) {
double tmp;
if ((x * 0.5) <= -5e-41) {
tmp = (x * 0.5) - (y * z);
} else if ((x * 0.5) <= 2e-87) {
tmp = y - (y * (z - log(z)));
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (Float64(x * 0.5) <= -5e-41) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); elseif (Float64(x * 0.5) <= 2e-87) tmp = Float64(y - Float64(y * Float64(z - log(z)))); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[LessEqual[N[(x * 0.5), $MachinePrecision], -5e-41], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * 0.5), $MachinePrecision], 2e-87], N[(y - N[(y * N[(z - N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 0.5 \leq -5 \cdot 10^{-41}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{elif}\;x \cdot 0.5 \leq 2 \cdot 10^{-87}:\\
\;\;\;\;y - y \cdot \left(z - \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 x 1/2) < -4.9999999999999996e-41Initial program 99.9%
Taylor expanded in z around inf 87.2%
mul-1-neg87.2%
distribute-rgt-neg-in87.2%
Simplified87.2%
distribute-rgt-neg-out87.2%
unsub-neg87.2%
add-sqr-sqrt87.1%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod0.0%
add-sqr-sqrt65.2%
*-commutative65.2%
add-sqr-sqrt0.0%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod87.1%
add-sqr-sqrt87.2%
Applied egg-rr87.2%
if -4.9999999999999996e-41 < (*.f64 x 1/2) < 2.00000000000000004e-87Initial program 99.7%
associate-+l-99.7%
Applied egg-rr99.7%
sub-neg99.7%
distribute-rgt-in99.7%
*-un-lft-identity99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 86.8%
if 2.00000000000000004e-87 < (*.f64 x 1/2) Initial program 99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in z around inf 90.3%
mul-1-neg90.3%
Simplified90.3%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (* 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 <= 0.28) {
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 <= 0.28) 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, 0.28], 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 0.28:\\
\;\;\;\;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 < 0.28000000000000003Initial program 99.7%
Taylor expanded in z around 0 99.4%
if 0.28000000000000003 < z Initial program 99.9%
+-commutative99.9%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 98.6%
mul-1-neg98.6%
Simplified98.6%
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.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (+ (* x 0.5) (* y (+ (- (log z) z) 1.0))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((log(z) - z) + 1.0));
}
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 * ((log(z) - z) + 1.0d0))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((Math.log(z) - z) + 1.0));
}
def code(x, y, z): return (x * 0.5) + (y * ((math.log(z) - z) + 1.0))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(log(z) - z) + 1.0))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((log(z) - z) + 1.0)); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(N[Log[z], $MachinePrecision] - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(\log z - z\right) + 1\right)
\end{array}
Initial program 99.8%
associate-+l-99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z 720000000000.0) (and (not (<= z 5.8e+95)) (<= z 1.46e+110))) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 720000000000.0) || (!(z <= 5.8e+95) && (z <= 1.46e+110))) {
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 <= 720000000000.0d0) .or. (.not. (z <= 5.8d+95)) .and. (z <= 1.46d+110)) 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 <= 720000000000.0) || (!(z <= 5.8e+95) && (z <= 1.46e+110))) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 720000000000.0) or (not (z <= 5.8e+95) and (z <= 1.46e+110)): tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 720000000000.0) || (!(z <= 5.8e+95) && (z <= 1.46e+110))) 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 <= 720000000000.0) || (~((z <= 5.8e+95)) && (z <= 1.46e+110))) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 720000000000.0], And[N[Not[LessEqual[z, 5.8e+95]], $MachinePrecision], LessEqual[z, 1.46e+110]]], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 720000000000 \lor \neg \left(z \leq 5.8 \cdot 10^{+95}\right) \land z \leq 1.46 \cdot 10^{+110}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 7.2e11 or 5.80000000000000027e95 < z < 1.46e110Initial program 99.7%
Taylor expanded in x around inf 54.9%
if 7.2e11 < z < 5.80000000000000027e95 or 1.46e110 < z Initial program 100.0%
Taylor expanded in z around inf 99.6%
mul-1-neg99.6%
distribute-rgt-neg-in99.6%
Simplified99.6%
distribute-rgt-neg-out99.6%
unsub-neg99.6%
add-sqr-sqrt99.3%
sqrt-unprod68.6%
sqr-neg68.6%
sqrt-unprod0.0%
add-sqr-sqrt32.7%
*-commutative32.7%
add-sqr-sqrt0.0%
sqrt-unprod68.6%
sqr-neg68.6%
sqrt-unprod99.3%
add-sqr-sqrt99.6%
Applied egg-rr99.6%
Taylor expanded in x around 0 67.6%
associate-*r*67.6%
neg-mul-167.6%
*-commutative67.6%
Simplified67.6%
Final simplification60.4%
(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 75.3%
mul-1-neg75.3%
distribute-rgt-neg-in75.3%
Simplified75.3%
distribute-rgt-neg-out75.3%
unsub-neg75.3%
add-sqr-sqrt75.2%
sqrt-unprod61.8%
sqr-neg61.8%
sqrt-unprod0.0%
add-sqr-sqrt45.0%
*-commutative45.0%
add-sqr-sqrt0.0%
sqrt-unprod61.8%
sqr-neg61.8%
sqrt-unprod75.2%
add-sqr-sqrt75.3%
Applied egg-rr75.3%
Final simplification75.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 45.9%
Final simplification45.9%
(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 2024033
(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)))))