
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + 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 - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (+ (- x (* (+ y 0.5) (log y))) y) z))
double code(double x, double y, double z) {
return ((x - ((y + 0.5) * log(y))) + 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 - ((y + 0.5d0) * log(y))) + y) - z
end function
public static double code(double x, double y, double z) {
return ((x - ((y + 0.5) * Math.log(y))) + y) - z;
}
def code(x, y, z): return ((x - ((y + 0.5) * math.log(y))) + y) - z
function code(x, y, z) return Float64(Float64(Float64(x - Float64(Float64(y + 0.5) * log(y))) + y) - z) end
function tmp = code(x, y, z) tmp = ((x - ((y + 0.5) * log(y))) + y) - z; end
code[x_, y_, z_] := N[(N[(N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x - \left(y + 0.5\right) \cdot \log y\right) + y\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (fma (log y) (- -0.5 y) (+ y (- x z))))
double code(double x, double y, double z) {
return fma(log(y), (-0.5 - y), (y + (x - z)));
}
function code(x, y, z) return fma(log(y), Float64(-0.5 - y), Float64(y + Float64(x - z))) end
code[x_, y_, z_] := N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y + N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\log y, -0.5 - y, y + \left(x - z\right)\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
+-commutative99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.8%
neg-sub099.8%
+-commutative99.8%
associate--r+99.8%
metadata-eval99.8%
associate-+r-99.8%
+-commutative99.8%
associate-+r-99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* (log y) 0.5))))
(if (<= y 3.7e-249)
t_0
(if (<= y 4.3e-173)
(- x z)
(if (<= y 3.8e-146)
t_0
(if (<= y 4.6e+24) (- (+ y x) z) (- (+ y x) (* y (log y)))))))))
double code(double x, double y, double z) {
double t_0 = x - (log(y) * 0.5);
double tmp;
if (y <= 3.7e-249) {
tmp = t_0;
} else if (y <= 4.3e-173) {
tmp = x - z;
} else if (y <= 3.8e-146) {
tmp = t_0;
} else if (y <= 4.6e+24) {
tmp = (y + x) - z;
} else {
tmp = (y + x) - (y * log(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) :: t_0
real(8) :: tmp
t_0 = x - (log(y) * 0.5d0)
if (y <= 3.7d-249) then
tmp = t_0
else if (y <= 4.3d-173) then
tmp = x - z
else if (y <= 3.8d-146) then
tmp = t_0
else if (y <= 4.6d+24) then
tmp = (y + x) - z
else
tmp = (y + x) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (Math.log(y) * 0.5);
double tmp;
if (y <= 3.7e-249) {
tmp = t_0;
} else if (y <= 4.3e-173) {
tmp = x - z;
} else if (y <= 3.8e-146) {
tmp = t_0;
} else if (y <= 4.6e+24) {
tmp = (y + x) - z;
} else {
tmp = (y + x) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x - (math.log(y) * 0.5) tmp = 0 if y <= 3.7e-249: tmp = t_0 elif y <= 4.3e-173: tmp = x - z elif y <= 3.8e-146: tmp = t_0 elif y <= 4.6e+24: tmp = (y + x) - z else: tmp = (y + x) - (y * math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x - Float64(log(y) * 0.5)) tmp = 0.0 if (y <= 3.7e-249) tmp = t_0; elseif (y <= 4.3e-173) tmp = Float64(x - z); elseif (y <= 3.8e-146) tmp = t_0; elseif (y <= 4.6e+24) tmp = Float64(Float64(y + x) - z); else tmp = Float64(Float64(y + x) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (log(y) * 0.5); tmp = 0.0; if (y <= 3.7e-249) tmp = t_0; elseif (y <= 4.3e-173) tmp = x - z; elseif (y <= 3.8e-146) tmp = t_0; elseif (y <= 4.6e+24) tmp = (y + x) - z; else tmp = (y + x) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.7e-249], t$95$0, If[LessEqual[y, 4.3e-173], N[(x - z), $MachinePrecision], If[LessEqual[y, 3.8e-146], t$95$0, If[LessEqual[y, 4.6e+24], N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + x), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \log y \cdot 0.5\\
\mathbf{if}\;y \leq 3.7 \cdot 10^{-249}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-173}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-146}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+24}:\\
\;\;\;\;\left(y + x\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 3.69999999999999977e-249 or 4.3000000000000003e-173 < y < 3.79999999999999994e-146Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around 0 80.5%
Taylor expanded in y around 0 80.5%
if 3.69999999999999977e-249 < y < 4.3000000000000003e-173Initial program 100.0%
associate--l+100.0%
Simplified100.0%
add-cube-cbrt99.6%
pow399.7%
Applied egg-rr99.7%
Taylor expanded in y around inf 83.1%
Taylor expanded in y around 0 83.1%
if 3.79999999999999994e-146 < y < 4.5999999999999998e24Initial program 100.0%
associate--l+100.0%
Simplified100.0%
add-cube-cbrt99.8%
pow399.8%
Applied egg-rr99.8%
Taylor expanded in y around inf 86.7%
if 4.5999999999999998e24 < y Initial program 99.6%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
mul-1-neg99.7%
distribute-rgt-neg-in99.7%
log-rec99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 80.6%
Final simplification82.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- x (* (log y) 0.5))))
(if (<= y 3.7e-249)
t_0
(if (<= y 2.7e-173)
(- x z)
(if (<= y 1.75e-146)
t_0
(if (<= y 4.8e+92) (- x z) (* y (- 1.0 (log y)))))))))
double code(double x, double y, double z) {
double t_0 = x - (log(y) * 0.5);
double tmp;
if (y <= 3.7e-249) {
tmp = t_0;
} else if (y <= 2.7e-173) {
tmp = x - z;
} else if (y <= 1.75e-146) {
tmp = t_0;
} else if (y <= 4.8e+92) {
tmp = x - z;
} else {
tmp = y * (1.0 - log(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) :: t_0
real(8) :: tmp
t_0 = x - (log(y) * 0.5d0)
if (y <= 3.7d-249) then
tmp = t_0
else if (y <= 2.7d-173) then
tmp = x - z
else if (y <= 1.75d-146) then
tmp = t_0
else if (y <= 4.8d+92) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (Math.log(y) * 0.5);
double tmp;
if (y <= 3.7e-249) {
tmp = t_0;
} else if (y <= 2.7e-173) {
tmp = x - z;
} else if (y <= 1.75e-146) {
tmp = t_0;
} else if (y <= 4.8e+92) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): t_0 = x - (math.log(y) * 0.5) tmp = 0 if y <= 3.7e-249: tmp = t_0 elif y <= 2.7e-173: tmp = x - z elif y <= 1.75e-146: tmp = t_0 elif y <= 4.8e+92: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) t_0 = Float64(x - Float64(log(y) * 0.5)) tmp = 0.0 if (y <= 3.7e-249) tmp = t_0; elseif (y <= 2.7e-173) tmp = Float64(x - z); elseif (y <= 1.75e-146) tmp = t_0; elseif (y <= 4.8e+92) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (log(y) * 0.5); tmp = 0.0; if (y <= 3.7e-249) tmp = t_0; elseif (y <= 2.7e-173) tmp = x - z; elseif (y <= 1.75e-146) tmp = t_0; elseif (y <= 4.8e+92) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.7e-249], t$95$0, If[LessEqual[y, 2.7e-173], N[(x - z), $MachinePrecision], If[LessEqual[y, 1.75e-146], t$95$0, If[LessEqual[y, 4.8e+92], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - \log y \cdot 0.5\\
\mathbf{if}\;y \leq 3.7 \cdot 10^{-249}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-173}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{-146}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+92}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 3.69999999999999977e-249 or 2.7e-173 < y < 1.7500000000000001e-146Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around 0 80.5%
Taylor expanded in y around 0 80.5%
if 3.69999999999999977e-249 < y < 2.7e-173 or 1.7500000000000001e-146 < y < 4.80000000000000009e92Initial program 100.0%
associate--l+100.0%
Simplified100.0%
add-cube-cbrt99.6%
pow399.6%
Applied egg-rr99.6%
Taylor expanded in y around inf 79.1%
Taylor expanded in y around 0 79.2%
if 4.80000000000000009e92 < y Initial program 99.5%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 76.7%
*-commutative76.7%
log-rec76.7%
cancel-sign-sub76.7%
*-commutative76.7%
neg-mul-176.7%
sub-neg76.7%
Simplified76.7%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (if (<= y 7e-14) (- (+ x (* (log y) -0.5)) z) (+ (- y z) (- x (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e-14) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y - z) + (x - (y * log(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 (y <= 7d-14) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y - z) + (x - (y * log(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7e-14) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y - z) + (x - (y * Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e-14: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y - z) + (x - (y * math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e-14) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y - z) + Float64(x - Float64(y * log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7e-14) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y - z) + (x - (y * log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e-14], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - z), $MachinePrecision] + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) + \left(x - y \cdot \log y\right)\\
\end{array}
\end{array}
if y < 7.0000000000000005e-14Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
+-commutative100.0%
associate-+l+100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 99.8%
if 7.0000000000000005e-14 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 99.3%
mul-1-neg99.3%
distribute-rgt-neg-in99.3%
log-rec99.3%
remove-double-neg99.3%
Simplified99.3%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (+ (- x (* (log y) (+ y 0.5))) (- y z)))
double code(double x, double y, double z) {
return (x - (log(y) * (y + 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 - (log(y) * (y + 0.5d0))) + (y - z)
end function
public static double code(double x, double y, double z) {
return (x - (Math.log(y) * (y + 0.5))) + (y - z);
}
def code(x, y, z): return (x - (math.log(y) * (y + 0.5))) + (y - z)
function code(x, y, z) return Float64(Float64(x - Float64(log(y) * Float64(y + 0.5))) + Float64(y - z)) end
function tmp = code(x, y, z) tmp = (x - (log(y) * (y + 0.5))) + (y - z); end
code[x_, y_, z_] := N[(N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x - \log y \cdot \left(y + 0.5\right)\right) + \left(y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.45e+28) (- (+ x (* (log y) -0.5)) z) (- (+ y x) (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e+28) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y + x) - (y * log(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 (y <= 1.45d+28) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y + x) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.45e+28) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y + x) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.45e+28: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y + x) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.45e+28) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y + x) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.45e+28) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y + x) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.45e+28], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + x), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{+28}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y + x\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 1.4500000000000001e28Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
+-commutative100.0%
associate-+l+100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 99.2%
if 1.4500000000000001e28 < y Initial program 99.6%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 99.7%
mul-1-neg99.7%
distribute-rgt-neg-in99.7%
log-rec99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in z around 0 80.6%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= y 1.38e+54) (- (+ x (* (log y) -0.5)) z) (- (- y z) (* y (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.38e+54) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (y * log(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 (y <= 1.38d+54) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y - z) - (y * log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.38e+54) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y - z) - (y * Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.38e+54: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y - z) - (y * math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.38e+54) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y - z) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.38e+54) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y - z) - (y * log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.38e+54], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.38 \cdot 10^{+54}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 1.38e54Initial program 100.0%
associate--l+100.0%
sub-neg100.0%
+-commutative100.0%
associate-+l+100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
fma-def100.0%
neg-sub0100.0%
+-commutative100.0%
associate--r+100.0%
metadata-eval100.0%
associate-+r-100.0%
+-commutative100.0%
associate-+r-100.0%
Simplified100.0%
Taylor expanded in y around 0 95.0%
if 1.38e54 < y Initial program 99.6%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 86.3%
*-commutative86.3%
log-rec86.3%
distribute-lft-neg-in86.3%
distribute-rgt-neg-in86.3%
Simplified86.3%
Taylor expanded in y around 0 86.4%
neg-mul-186.4%
log-rec86.4%
distribute-lft-in86.3%
*-rgt-identity86.3%
log-rec86.3%
distribute-rgt-neg-in86.3%
unsub-neg86.3%
associate--l+86.3%
+-commutative86.3%
mul-1-neg86.3%
sub-neg86.3%
Simplified86.3%
Final simplification91.2%
(FPCore (x y z) :precision binary64 (if (<= y 4.8e+92) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e+92) {
tmp = x - z;
} else {
tmp = y * (1.0 - log(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 (y <= 4.8d+92) then
tmp = x - z
else
tmp = y * (1.0d0 - log(y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.8e+92) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.8e+92: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.8e+92) tmp = Float64(x - z); else tmp = Float64(y * Float64(1.0 - log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.8e+92) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.8e+92], N[(x - z), $MachinePrecision], N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{+92}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 4.80000000000000009e92Initial program 100.0%
associate--l+100.0%
Simplified100.0%
add-cube-cbrt99.5%
pow399.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 74.0%
Taylor expanded in y around 0 74.0%
if 4.80000000000000009e92 < y Initial program 99.5%
associate--l+99.6%
Simplified99.6%
Taylor expanded in y around inf 76.7%
*-commutative76.7%
log-rec76.7%
cancel-sign-sub76.7%
*-commutative76.7%
neg-mul-176.7%
sub-neg76.7%
Simplified76.7%
Final simplification75.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.1e+43) x (if (<= x 2.1e+92) (- z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+43) {
tmp = x;
} else if (x <= 2.1e+92) {
tmp = -z;
} else {
tmp = x;
}
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 <= (-2.1d+43)) then
tmp = x
else if (x <= 2.1d+92) then
tmp = -z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.1e+43) {
tmp = x;
} else if (x <= 2.1e+92) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.1e+43: tmp = x elif x <= 2.1e+92: tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.1e+43) tmp = x; elseif (x <= 2.1e+92) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.1e+43) tmp = x; elseif (x <= 2.1e+92) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.1e+43], x, If[LessEqual[x, 2.1e+92], (-z), x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+43}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+92}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.10000000000000002e43 or 2.09999999999999986e92 < x Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in x around inf 68.0%
if -2.10000000000000002e43 < x < 2.09999999999999986e92Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in z around inf 37.3%
mul-1-neg37.3%
Simplified37.3%
Final simplification49.4%
(FPCore (x y z) :precision binary64 (- x z))
double code(double x, double y, double z) {
return x - 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 - z
end function
public static double code(double x, double y, double z) {
return x - z;
}
def code(x, y, z): return x - z
function code(x, y, z) return Float64(x - z) end
function tmp = code(x, y, z) tmp = x - z; end
code[x_, y_, z_] := N[(x - z), $MachinePrecision]
\begin{array}{l}
\\
x - z
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
add-cube-cbrt99.1%
pow399.2%
Applied egg-rr99.2%
Taylor expanded in y around inf 55.3%
Taylor expanded in y around 0 56.0%
Final simplification56.0%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in x around inf 30.4%
Final simplification30.4%
(FPCore (x y z) :precision binary64 (- (- (+ y x) z) (* (+ y 0.5) (log y))))
double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * log(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 + x) - z) - ((y + 0.5d0) * log(y))
end function
public static double code(double x, double y, double z) {
return ((y + x) - z) - ((y + 0.5) * Math.log(y));
}
def code(x, y, z): return ((y + x) - z) - ((y + 0.5) * math.log(y))
function code(x, y, z) return Float64(Float64(Float64(y + x) - z) - Float64(Float64(y + 0.5) * log(y))) end
function tmp = code(x, y, z) tmp = ((y + x) - z) - ((y + 0.5) * log(y)); end
code[x_, y_, z_] := N[(N[(N[(y + x), $MachinePrecision] - z), $MachinePrecision] - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(y + x\right) - z\right) - \left(y + 0.5\right) \cdot \log y
\end{array}
herbie shell --seed 2023224
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(- (- (+ y x) z) (* (+ y 0.5) (log y)))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))