
(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 12 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 (+ x (fma (log y) (- -0.5 y) (- y z))))
double code(double x, double y, double z) {
return x + fma(log(y), (-0.5 - y), (y - z));
}
function code(x, y, z) return Float64(x + fma(log(y), Float64(-0.5 - y), Float64(y - z))) end
code[x_, y_, z_] := N[(x + N[(N[Log[y], $MachinePrecision] * N[(-0.5 - y), $MachinePrecision] + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \mathsf{fma}\left(\log y, -0.5 - y, y - z\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.8e+63) (not (<= z 2.8e+54))) (- x z) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e+63) || !(z <= 2.8e+54)) {
tmp = x - z;
} else {
tmp = x + (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 ((z <= (-2.8d+63)) .or. (.not. (z <= 2.8d+54))) then
tmp = x - z
else
tmp = x + (y * (1.0d0 - log(y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.8e+63) || !(z <= 2.8e+54)) {
tmp = x - z;
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.8e+63) or not (z <= 2.8e+54): tmp = x - z else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.8e+63) || !(z <= 2.8e+54)) tmp = Float64(x - z); else tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.8e+63) || ~((z <= 2.8e+54))) tmp = x - z; else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.8e+63], N[Not[LessEqual[z, 2.8e+54]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.8 \cdot 10^{+63} \lor \neg \left(z \leq 2.8 \cdot 10^{+54}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if z < -2.79999999999999987e63 or 2.80000000000000015e54 < z Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 87.3%
metadata-eval87.3%
associate-*r*87.3%
mul-1-neg87.3%
log-rec87.3%
log-rec87.3%
mul-1-neg87.3%
associate-*r*87.3%
metadata-eval87.3%
*-commutative87.3%
Simplified87.3%
Taylor expanded in z around inf 87.3%
if -2.79999999999999987e63 < z < 2.80000000000000015e54Initial program 99.8%
associate--l+99.8%
sub-neg99.8%
associate-+l+99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 76.3%
log-rec76.3%
sub-neg76.3%
Simplified76.3%
Final simplification80.8%
(FPCore (x y z) :precision binary64 (if (<= y 2.35e+44) (- x (+ z (* (log y) 0.5))) (if (<= y 7.5e+117) (+ x (* y (- 1.0 (log y)))) (- y (+ z (* y (log y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.35e+44) {
tmp = x - (z + (log(y) * 0.5));
} else if (y <= 7.5e+117) {
tmp = x + (y * (1.0 - log(y)));
} 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 <= 2.35d+44) then
tmp = x - (z + (log(y) * 0.5d0))
else if (y <= 7.5d+117) then
tmp = x + (y * (1.0d0 - log(y)))
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 <= 2.35e+44) {
tmp = x - (z + (Math.log(y) * 0.5));
} else if (y <= 7.5e+117) {
tmp = x + (y * (1.0 - Math.log(y)));
} else {
tmp = y - (z + (y * Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.35e+44: tmp = x - (z + (math.log(y) * 0.5)) elif y <= 7.5e+117: tmp = x + (y * (1.0 - math.log(y))) else: tmp = y - (z + (y * math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.35e+44) tmp = Float64(x - Float64(z + Float64(log(y) * 0.5))); elseif (y <= 7.5e+117) tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); else tmp = Float64(y - Float64(z + Float64(y * log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.35e+44) tmp = x - (z + (log(y) * 0.5)); elseif (y <= 7.5e+117) tmp = x + (y * (1.0 - log(y))); else tmp = y - (z + (y * log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.35e+44], N[(x - N[(z + N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e+117], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y - N[(z + N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.35 \cdot 10^{+44}:\\
\;\;\;\;x - \left(z + \log y \cdot 0.5\right)\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+117}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\mathbf{else}:\\
\;\;\;\;y - \left(z + y \cdot \log y\right)\\
\end{array}
\end{array}
if y < 2.35000000000000009e44Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 96.6%
metadata-eval96.6%
associate-*r*96.6%
mul-1-neg96.6%
log-rec96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
Simplified96.6%
if 2.35000000000000009e44 < y < 7.5e117Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 81.6%
log-rec81.6%
sub-neg81.6%
Simplified81.6%
if 7.5e117 < y Initial program 99.6%
associate--l+99.6%
Simplified99.6%
add-cube-cbrt98.6%
pow398.6%
*-commutative98.6%
Applied egg-rr98.6%
Taylor expanded in y around inf 98.6%
mul-1-neg98.6%
distribute-rgt-neg-in98.6%
log-rec98.6%
remove-double-neg98.6%
Simplified98.6%
Taylor expanded in x around 0 87.8%
+-commutative87.8%
pow-base-187.8%
*-lft-identity87.8%
Simplified87.8%
Final simplification92.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (- 1.0 (log y)))))
(if (<= y 8.4e+43)
(- x (+ z (* (log y) 0.5)))
(if (<= y 9.5e+120) (+ x t_0) (- t_0 z)))))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - log(y));
double tmp;
if (y <= 8.4e+43) {
tmp = x - (z + (log(y) * 0.5));
} else if (y <= 9.5e+120) {
tmp = x + t_0;
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = y * (1.0d0 - log(y))
if (y <= 8.4d+43) then
tmp = x - (z + (log(y) * 0.5d0))
else if (y <= 9.5d+120) then
tmp = x + t_0
else
tmp = t_0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 - Math.log(y));
double tmp;
if (y <= 8.4e+43) {
tmp = x - (z + (Math.log(y) * 0.5));
} else if (y <= 9.5e+120) {
tmp = x + t_0;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - math.log(y)) tmp = 0 if y <= 8.4e+43: tmp = x - (z + (math.log(y) * 0.5)) elif y <= 9.5e+120: tmp = x + t_0 else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - log(y))) tmp = 0.0 if (y <= 8.4e+43) tmp = Float64(x - Float64(z + Float64(log(y) * 0.5))); elseif (y <= 9.5e+120) tmp = Float64(x + t_0); else tmp = Float64(t_0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - log(y)); tmp = 0.0; if (y <= 8.4e+43) tmp = x - (z + (log(y) * 0.5)); elseif (y <= 9.5e+120) tmp = x + t_0; else tmp = t_0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 8.4e+43], N[(x - N[(z + N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.5e+120], N[(x + t$95$0), $MachinePrecision], N[(t$95$0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \log y\right)\\
\mathbf{if}\;y \leq 8.4 \cdot 10^{+43}:\\
\;\;\;\;x - \left(z + \log y \cdot 0.5\right)\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+120}:\\
\;\;\;\;x + t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if y < 8.40000000000000007e43Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 96.6%
metadata-eval96.6%
associate-*r*96.6%
mul-1-neg96.6%
log-rec96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
Simplified96.6%
if 8.40000000000000007e43 < y < 9.5e120Initial program 99.7%
associate--l+99.7%
sub-neg99.7%
associate-+l+99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
fma-def99.9%
+-commutative99.9%
distribute-neg-in99.9%
unsub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 81.6%
log-rec81.6%
sub-neg81.6%
Simplified81.6%
if 9.5e120 < y Initial program 99.6%
associate--l+99.6%
Simplified99.6%
add-cube-cbrt98.6%
pow398.6%
*-commutative98.6%
Applied egg-rr98.6%
Taylor expanded in y around inf 98.6%
mul-1-neg98.6%
distribute-rgt-neg-in98.6%
log-rec98.6%
remove-double-neg98.6%
Simplified98.6%
Taylor expanded in x around 0 99.6%
associate--l+99.6%
+-commutative99.6%
pow-base-199.6%
*-lft-identity99.6%
associate--r+99.6%
*-commutative99.6%
cancel-sign-sub-inv99.6%
*-lft-identity99.6%
distribute-rgt-in99.7%
sub-neg99.7%
associate--l+99.7%
+-commutative99.7%
fma-udef99.7%
Simplified99.7%
Taylor expanded in y around inf 87.9%
log-rec87.9%
mul-1-neg87.9%
remove-double-neg87.9%
Simplified87.9%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (<= y 4.1e-7) (- x (+ z (* (log y) 0.5))) (+ (- y z) (- x (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e-7) {
tmp = x - (z + (log(y) * 0.5));
} 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 <= 4.1d-7) then
tmp = x - (z + (log(y) * 0.5d0))
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 <= 4.1e-7) {
tmp = x - (z + (Math.log(y) * 0.5));
} else {
tmp = (y - z) + (x - (y * Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.1e-7: tmp = x - (z + (math.log(y) * 0.5)) else: tmp = (y - z) + (x - (y * math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.1e-7) tmp = Float64(x - Float64(z + Float64(log(y) * 0.5))); 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 <= 4.1e-7) tmp = x - (z + (log(y) * 0.5)); else tmp = (y - z) + (x - (y * log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.1e-7], N[(x - N[(z + N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $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 4.1 \cdot 10^{-7}:\\
\;\;\;\;x - \left(z + \log y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) + \left(x - y \cdot \log y\right)\\
\end{array}
\end{array}
if y < 4.0999999999999999e-7Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 99.7%
metadata-eval99.7%
associate-*r*99.7%
mul-1-neg99.7%
log-rec99.7%
log-rec99.7%
mul-1-neg99.7%
associate-*r*99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
if 4.0999999999999999e-7 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
Taylor expanded in y around inf 98.9%
mul-1-neg98.9%
distribute-rgt-neg-in98.9%
log-rec98.9%
remove-double-neg98.9%
Simplified98.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (<= y 4.1e-7) (- x (+ z (* (log y) 0.5))) (- (+ x (* y (- 1.0 (log y)))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e-7) {
tmp = x - (z + (log(y) * 0.5));
} else {
tmp = (x + (y * (1.0 - log(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 (y <= 4.1d-7) then
tmp = x - (z + (log(y) * 0.5d0))
else
tmp = (x + (y * (1.0d0 - log(y)))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e-7) {
tmp = x - (z + (Math.log(y) * 0.5));
} else {
tmp = (x + (y * (1.0 - Math.log(y)))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.1e-7: tmp = x - (z + (math.log(y) * 0.5)) else: tmp = (x + (y * (1.0 - math.log(y)))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.1e-7) tmp = Float64(x - Float64(z + Float64(log(y) * 0.5))); else tmp = Float64(Float64(x + Float64(y * Float64(1.0 - log(y)))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.1e-7) tmp = x - (z + (log(y) * 0.5)); else tmp = (x + (y * (1.0 - log(y)))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.1e-7], N[(x - N[(z + N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{-7}:\\
\;\;\;\;x - \left(z + \log y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x + y \cdot \left(1 - \log y\right)\right) - z\\
\end{array}
\end{array}
if y < 4.0999999999999999e-7Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 99.7%
metadata-eval99.7%
associate-*r*99.7%
mul-1-neg99.7%
log-rec99.7%
log-rec99.7%
mul-1-neg99.7%
associate-*r*99.7%
metadata-eval99.7%
*-commutative99.7%
Simplified99.7%
if 4.0999999999999999e-7 < y Initial program 99.7%
associate--l+99.7%
Simplified99.7%
add-cube-cbrt99.0%
pow398.9%
*-commutative98.9%
Applied egg-rr98.9%
Taylor expanded in y around inf 98.1%
mul-1-neg98.1%
distribute-rgt-neg-in98.1%
log-rec98.1%
remove-double-neg98.1%
Simplified98.1%
Taylor expanded in x around 0 98.8%
associate--l+98.8%
+-commutative98.8%
pow-base-198.8%
*-lft-identity98.8%
associate--r+98.8%
*-commutative98.8%
cancel-sign-sub-inv98.8%
*-lft-identity98.8%
distribute-rgt-in99.0%
sub-neg99.0%
associate--l+99.0%
+-commutative99.0%
fma-udef99.0%
Simplified99.0%
fma-udef99.0%
Applied egg-rr99.0%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (+ (- y z) (- x (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
return (y - z) + (x - (log(y) * (y + 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 = (y - z) + (x - (log(y) * (y + 0.5d0)))
end function
public static double code(double x, double y, double z) {
return (y - z) + (x - (Math.log(y) * (y + 0.5)));
}
def code(x, y, z): return (y - z) + (x - (math.log(y) * (y + 0.5)))
function code(x, y, z) return Float64(Float64(y - z) + Float64(x - Float64(log(y) * Float64(y + 0.5)))) end
function tmp = code(x, y, z) tmp = (y - z) + (x - (log(y) * (y + 0.5))); end
code[x_, y_, z_] := N[(N[(y - z), $MachinePrecision] + N[(x - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y - z\right) + \left(x - \log y \cdot \left(y + 0.5\right)\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.35e+43) (- x (+ z (* (log y) 0.5))) (+ x (* y (- 1.0 (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.35e+43) {
tmp = x - (z + (log(y) * 0.5));
} else {
tmp = x + (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 <= 1.35d+43) then
tmp = x - (z + (log(y) * 0.5d0))
else
tmp = x + (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 <= 1.35e+43) {
tmp = x - (z + (Math.log(y) * 0.5));
} else {
tmp = x + (y * (1.0 - Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.35e+43: tmp = x - (z + (math.log(y) * 0.5)) else: tmp = x + (y * (1.0 - math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.35e+43) tmp = Float64(x - Float64(z + Float64(log(y) * 0.5))); else tmp = Float64(x + Float64(y * Float64(1.0 - log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.35e+43) tmp = x - (z + (log(y) * 0.5)); else tmp = x + (y * (1.0 - log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.35e+43], N[(x - N[(z + N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{+43}:\\
\;\;\;\;x - \left(z + \log y \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.3500000000000001e43Initial program 100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 96.6%
metadata-eval96.6%
associate-*r*96.6%
mul-1-neg96.6%
log-rec96.6%
log-rec96.6%
mul-1-neg96.6%
associate-*r*96.6%
metadata-eval96.6%
*-commutative96.6%
Simplified96.6%
if 1.3500000000000001e43 < y Initial program 99.6%
associate--l+99.6%
sub-neg99.6%
associate-+l+99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
fma-def99.8%
+-commutative99.8%
distribute-neg-in99.8%
unsub-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 81.2%
log-rec81.2%
sub-neg81.2%
Simplified81.2%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y 1.65e+191) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.65e+191) {
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 <= 1.65d+191) 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 <= 1.65e+191) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.65e+191: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.65e+191) 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 <= 1.65e+191) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.65e+191], 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 1.65 \cdot 10^{+191}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.6499999999999999e191Initial program 99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around 0 85.7%
metadata-eval85.7%
associate-*r*85.7%
mul-1-neg85.7%
log-rec85.7%
log-rec85.7%
mul-1-neg85.7%
associate-*r*85.7%
metadata-eval85.7%
*-commutative85.7%
Simplified85.7%
Taylor expanded in z around inf 70.8%
if 1.6499999999999999e191 < y Initial program 99.5%
associate--l+99.5%
Simplified99.5%
Taylor expanded in x around 0 93.8%
Taylor expanded in y around inf 84.1%
mul-1-neg84.1%
log-rec84.1%
remove-double-neg84.1%
Simplified84.1%
Final simplification73.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.35e+162) (not (<= z 1.4e+95))) (- z) x))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.35e+162) || !(z <= 1.4e+95)) {
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 ((z <= (-2.35d+162)) .or. (.not. (z <= 1.4d+95))) 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 ((z <= -2.35e+162) || !(z <= 1.4e+95)) {
tmp = -z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.35e+162) or not (z <= 1.4e+95): tmp = -z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.35e+162) || !(z <= 1.4e+95)) tmp = Float64(-z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.35e+162) || ~((z <= 1.4e+95))) tmp = -z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.35e+162], N[Not[LessEqual[z, 1.4e+95]], $MachinePrecision]], (-z), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.35 \cdot 10^{+162} \lor \neg \left(z \leq 1.4 \cdot 10^{+95}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.35000000000000001e162 or 1.3999999999999999e95 < z Initial program 99.9%
associate--l+99.9%
Simplified99.9%
add-cube-cbrt99.8%
pow399.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in z around inf 81.0%
neg-mul-181.0%
Simplified81.0%
if -2.35000000000000001e162 < z < 1.3999999999999999e95Initial program 99.8%
associate--l+99.8%
Simplified99.8%
Taylor expanded in x around inf 39.4%
Final simplification52.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%
Taylor expanded in y around 0 72.0%
metadata-eval72.0%
associate-*r*72.0%
mul-1-neg72.0%
log-rec72.0%
log-rec72.0%
mul-1-neg72.0%
associate-*r*72.0%
metadata-eval72.0%
*-commutative72.0%
Simplified72.0%
Taylor expanded in z around inf 60.0%
Final simplification60.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.0%
Final simplification30.0%
(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 2023336
(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))