
(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-define99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (+ 1.0 (log z)))))
(if (<= z 5.4e-295)
(* x 0.5)
(if (<= z 2.9e-280)
t_0
(if (<= z 3.5e-216)
(- (* x 0.5) (* y z))
(if (<= z 1.55e-96) t_0 (fma y (- z) (* x 0.5))))))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 + log(z));
double tmp;
if (z <= 5.4e-295) {
tmp = x * 0.5;
} else if (z <= 2.9e-280) {
tmp = t_0;
} else if (z <= 3.5e-216) {
tmp = (x * 0.5) - (y * z);
} else if (z <= 1.55e-96) {
tmp = t_0;
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) t_0 = Float64(y * Float64(1.0 + log(z))) tmp = 0.0 if (z <= 5.4e-295) tmp = Float64(x * 0.5); elseif (z <= 2.9e-280) tmp = t_0; elseif (z <= 3.5e-216) tmp = Float64(Float64(x * 0.5) - Float64(y * z)); elseif (z <= 1.55e-96) tmp = t_0; else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 5.4e-295], N[(x * 0.5), $MachinePrecision], If[LessEqual[z, 2.9e-280], t$95$0, If[LessEqual[z, 3.5e-216], N[(N[(x * 0.5), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.55e-96], t$95$0, N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 + \log z\right)\\
\mathbf{if}\;z \leq 5.4 \cdot 10^{-295}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-280}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-216}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-96}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 5.4000000000000002e-295Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 5.4000000000000002e-295 < z < 2.9e-280 or 3.49999999999999982e-216 < z < 1.55e-96Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt53.4%
associate-*r*53.4%
fma-define53.4%
Applied egg-rr53.4%
Taylor expanded in y around -inf 0.0%
*-commutative0.0%
associate-*r*0.0%
+-commutative0.0%
associate-+r-0.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt70.3%
*-commutative70.3%
neg-mul-170.3%
*-commutative70.3%
sub-neg70.3%
associate-+l+70.3%
+-commutative70.3%
distribute-lft-in70.3%
neg-mul-170.3%
remove-double-neg70.3%
neg-mul-170.3%
+-commutative70.3%
distribute-neg-in70.3%
metadata-eval70.3%
Simplified70.3%
Taylor expanded in z around 0 70.3%
if 2.9e-280 < z < 3.49999999999999982e-216Initial program 99.8%
Taylor expanded in z around inf 61.4%
mul-1-neg61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
Simplified61.4%
distribute-rgt-neg-out61.4%
unsub-neg61.4%
*-commutative61.4%
Applied egg-rr61.4%
if 1.55e-96 < z Initial program 99.9%
+-commutative99.9%
fma-define99.9%
Simplified99.9%
Taylor expanded in z around inf 87.5%
mul-1-neg87.5%
Simplified87.5%
Final simplification81.7%
(FPCore (x y z)
:precision binary64
(if (<= z 8.8e-296)
(* x 0.5)
(if (or (<= z 7.2e-280) (and (not (<= z 2e-216)) (<= z 1.6e-96)))
(* y (+ 1.0 (log z)))
(- (* x 0.5) (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.8e-296) {
tmp = x * 0.5;
} else if ((z <= 7.2e-280) || (!(z <= 2e-216) && (z <= 1.6e-96))) {
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 <= 8.8d-296) then
tmp = x * 0.5d0
else if ((z <= 7.2d-280) .or. (.not. (z <= 2d-216)) .and. (z <= 1.6d-96)) 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 <= 8.8e-296) {
tmp = x * 0.5;
} else if ((z <= 7.2e-280) || (!(z <= 2e-216) && (z <= 1.6e-96))) {
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 <= 8.8e-296: tmp = x * 0.5 elif (z <= 7.2e-280) or (not (z <= 2e-216) and (z <= 1.6e-96)): 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 <= 8.8e-296) tmp = Float64(x * 0.5); elseif ((z <= 7.2e-280) || (!(z <= 2e-216) && (z <= 1.6e-96))) 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 <= 8.8e-296) tmp = x * 0.5; elseif ((z <= 7.2e-280) || (~((z <= 2e-216)) && (z <= 1.6e-96))) tmp = y * (1.0 + log(z)); else tmp = (x * 0.5) - (y * z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 8.8e-296], N[(x * 0.5), $MachinePrecision], If[Or[LessEqual[z, 7.2e-280], And[N[Not[LessEqual[z, 2e-216]], $MachinePrecision], LessEqual[z, 1.6e-96]]], 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 8.8 \cdot 10^{-296}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{-280} \lor \neg \left(z \leq 2 \cdot 10^{-216}\right) \land z \leq 1.6 \cdot 10^{-96}:\\
\;\;\;\;y \cdot \left(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot 0.5 - y \cdot z\\
\end{array}
\end{array}
if z < 8.80000000000000048e-296Initial program 100.0%
Taylor expanded in x around inf 100.0%
if 8.80000000000000048e-296 < z < 7.19999999999999989e-280 or 2.0000000000000001e-216 < z < 1.60000000000000006e-96Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt53.4%
associate-*r*53.4%
fma-define53.4%
Applied egg-rr53.4%
Taylor expanded in y around -inf 0.0%
*-commutative0.0%
associate-*r*0.0%
+-commutative0.0%
associate-+r-0.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt70.3%
*-commutative70.3%
neg-mul-170.3%
*-commutative70.3%
sub-neg70.3%
associate-+l+70.3%
+-commutative70.3%
distribute-lft-in70.3%
neg-mul-170.3%
remove-double-neg70.3%
neg-mul-170.3%
+-commutative70.3%
distribute-neg-in70.3%
metadata-eval70.3%
Simplified70.3%
Taylor expanded in z around 0 70.3%
if 7.19999999999999989e-280 < z < 2.0000000000000001e-216 or 1.60000000000000006e-96 < z Initial program 99.9%
Taylor expanded in z around inf 84.2%
mul-1-neg84.2%
*-commutative84.2%
distribute-rgt-neg-in84.2%
Simplified84.2%
distribute-rgt-neg-out84.2%
unsub-neg84.2%
*-commutative84.2%
Applied egg-rr84.2%
Final simplification81.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.8e+105) (not (<= y 2.4e+55))) (* y (- (+ 1.0 (log z)) z)) (fma y (- z) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.8e+105) || !(y <= 2.4e+55)) {
tmp = y * ((1.0 + log(z)) - z);
} else {
tmp = fma(y, -z, (x * 0.5));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if ((y <= -6.8e+105) || !(y <= 2.4e+55)) tmp = Float64(y * Float64(Float64(1.0 + log(z)) - z)); else tmp = fma(y, Float64(-z), Float64(x * 0.5)); end return tmp end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.8e+105], N[Not[LessEqual[y, 2.4e+55]], $MachinePrecision]], N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision], N[(y * (-z) + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{+105} \lor \neg \left(y \leq 2.4 \cdot 10^{+55}\right):\\
\;\;\;\;y \cdot \left(\left(1 + \log z\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if y < -6.7999999999999999e105 or 2.3999999999999999e55 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-cube-cbrt98.5%
associate-*r*98.5%
fma-define98.5%
pow298.5%
Applied egg-rr98.5%
Taylor expanded in y around inf 93.6%
if -6.7999999999999999e105 < y < 2.3999999999999999e55Initial program 99.9%
+-commutative99.9%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 86.4%
mul-1-neg86.4%
Simplified86.4%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= z 0.28) (+ (* x 0.5) (* y (+ 1.0 (log z)))) (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 * (1.0 + log(z)));
} 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(1.0 + log(z)))); 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[(1.0 + N[Log[z], $MachinePrecision]), $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(1 + \log z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, -z, x \cdot 0.5\right)\\
\end{array}
\end{array}
if z < 0.28000000000000003Initial program 99.8%
Taylor expanded in z around 0 98.6%
if 0.28000000000000003 < z Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in z around inf 99.5%
mul-1-neg99.5%
Simplified99.5%
Final simplification99.1%
(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 (- (+ 1.0 (log z)) z))))
double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 + log(z)) - 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 + log(z)) - z))
end function
public static double code(double x, double y, double z) {
return (x * 0.5) + (y * ((1.0 + Math.log(z)) - z));
}
def code(x, y, z): return (x * 0.5) + (y * ((1.0 + math.log(z)) - z))
function code(x, y, z) return Float64(Float64(x * 0.5) + Float64(y * Float64(Float64(1.0 + log(z)) - z))) end
function tmp = code(x, y, z) tmp = (x * 0.5) + (y * ((1.0 + log(z)) - z)); end
code[x_, y_, z_] := N[(N[(x * 0.5), $MachinePrecision] + N[(y * N[(N[(1.0 + N[Log[z], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot 0.5 + y \cdot \left(\left(1 + \log z\right) - z\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-+r-99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z 1.7e+33) (and (not (<= z 6e+73)) (<= z 1.45e+96))) (* x 0.5) (* y (- z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 1.7e+33) || (!(z <= 6e+73) && (z <= 1.45e+96))) {
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 <= 1.7d+33) .or. (.not. (z <= 6d+73)) .and. (z <= 1.45d+96)) 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 <= 1.7e+33) || (!(z <= 6e+73) && (z <= 1.45e+96))) {
tmp = x * 0.5;
} else {
tmp = y * -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 1.7e+33) or (not (z <= 6e+73) and (z <= 1.45e+96)): tmp = x * 0.5 else: tmp = y * -z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 1.7e+33) || (!(z <= 6e+73) && (z <= 1.45e+96))) 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 <= 1.7e+33) || (~((z <= 6e+73)) && (z <= 1.45e+96))) tmp = x * 0.5; else tmp = y * -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 1.7e+33], And[N[Not[LessEqual[z, 6e+73]], $MachinePrecision], LessEqual[z, 1.45e+96]]], N[(x * 0.5), $MachinePrecision], N[(y * (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.7 \cdot 10^{+33} \lor \neg \left(z \leq 6 \cdot 10^{+73}\right) \land z \leq 1.45 \cdot 10^{+96}:\\
\;\;\;\;x \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(-z\right)\\
\end{array}
\end{array}
if z < 1.7e33 or 6.00000000000000021e73 < z < 1.44999999999999989e96Initial program 99.8%
Taylor expanded in x around inf 49.9%
if 1.7e33 < z < 6.00000000000000021e73 or 1.44999999999999989e96 < z Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
add-sqr-sqrt50.2%
associate-*r*50.2%
fma-define50.2%
Applied egg-rr50.2%
Taylor expanded in y around -inf 0.0%
*-commutative0.0%
associate-*r*0.0%
+-commutative0.0%
associate-+r-0.0%
associate-*l*0.0%
unpow20.0%
rem-square-sqrt75.9%
*-commutative75.9%
neg-mul-175.9%
*-commutative75.9%
sub-neg75.9%
associate-+l+75.9%
+-commutative75.9%
distribute-lft-in75.9%
neg-mul-175.9%
remove-double-neg75.9%
neg-mul-175.9%
+-commutative75.9%
distribute-neg-in75.9%
metadata-eval75.9%
Simplified75.9%
Taylor expanded in z around inf 75.9%
Final simplification60.7%
(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 73.9%
mul-1-neg73.9%
*-commutative73.9%
distribute-rgt-neg-in73.9%
Simplified73.9%
distribute-rgt-neg-out73.9%
unsub-neg73.9%
*-commutative73.9%
Applied egg-rr73.9%
Final simplification73.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.4%
Final simplification39.4%
(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 2024035
(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)))))