
(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 10 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
(let* ((t_0 (- x (* y (+ (log y) -1.0)))))
(if (<= z -9.6e+47)
(- x z)
(if (<= z -9.4e-107)
t_0
(if (<= z 8.5e-235)
(- y (* (log y) (+ y 0.5)))
(if (<= z 1.75e+152) t_0 (- x z)))))))
double code(double x, double y, double z) {
double t_0 = x - (y * (log(y) + -1.0));
double tmp;
if (z <= -9.6e+47) {
tmp = x - z;
} else if (z <= -9.4e-107) {
tmp = t_0;
} else if (z <= 8.5e-235) {
tmp = y - (log(y) * (y + 0.5));
} else if (z <= 1.75e+152) {
tmp = t_0;
} else {
tmp = x - 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 = x - (y * (log(y) + (-1.0d0)))
if (z <= (-9.6d+47)) then
tmp = x - z
else if (z <= (-9.4d-107)) then
tmp = t_0
else if (z <= 8.5d-235) then
tmp = y - (log(y) * (y + 0.5d0))
else if (z <= 1.75d+152) then
tmp = t_0
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x - (y * (Math.log(y) + -1.0));
double tmp;
if (z <= -9.6e+47) {
tmp = x - z;
} else if (z <= -9.4e-107) {
tmp = t_0;
} else if (z <= 8.5e-235) {
tmp = y - (Math.log(y) * (y + 0.5));
} else if (z <= 1.75e+152) {
tmp = t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = x - (y * (math.log(y) + -1.0)) tmp = 0 if z <= -9.6e+47: tmp = x - z elif z <= -9.4e-107: tmp = t_0 elif z <= 8.5e-235: tmp = y - (math.log(y) * (y + 0.5)) elif z <= 1.75e+152: tmp = t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(x - Float64(y * Float64(log(y) + -1.0))) tmp = 0.0 if (z <= -9.6e+47) tmp = Float64(x - z); elseif (z <= -9.4e-107) tmp = t_0; elseif (z <= 8.5e-235) tmp = Float64(y - Float64(log(y) * Float64(y + 0.5))); elseif (z <= 1.75e+152) tmp = t_0; else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x - (y * (log(y) + -1.0)); tmp = 0.0; if (z <= -9.6e+47) tmp = x - z; elseif (z <= -9.4e-107) tmp = t_0; elseif (z <= 8.5e-235) tmp = y - (log(y) * (y + 0.5)); elseif (z <= 1.75e+152) tmp = t_0; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x - N[(y * N[(N[Log[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.6e+47], N[(x - z), $MachinePrecision], If[LessEqual[z, -9.4e-107], t$95$0, If[LessEqual[z, 8.5e-235], N[(y - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.75e+152], t$95$0, N[(x - z), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x - y \cdot \left(\log y + -1\right)\\
\mathbf{if}\;z \leq -9.6 \cdot 10^{+47}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq -9.4 \cdot 10^{-107}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{-235}:\\
\;\;\;\;y - \log y \cdot \left(y + 0.5\right)\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -9.60000000000000075e47 or 1.74999999999999991e152 < z Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 84.9%
if -9.60000000000000075e47 < z < -9.39999999999999995e-107 or 8.49999999999999964e-235 < z < 1.74999999999999991e152Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around inf 79.0%
sub-neg79.0%
mul-1-neg79.0%
log-rec79.0%
remove-double-neg79.0%
metadata-eval79.0%
Simplified79.0%
if -9.39999999999999995e-107 < z < 8.49999999999999964e-235Initial program 99.8%
Taylor expanded in x around 0 74.0%
Taylor expanded in z around 0 74.0%
Final simplification80.0%
(FPCore (x y z)
:precision binary64
(if (<= x -27000000000000.0)
(- x z)
(if (<= x 1.4e-152)
(- (* y (- 1.0 (log y))) z)
(if (<= x 1.95e+51)
(- (* (log y) -0.5) z)
(- x (* y (+ (log y) -1.0)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -27000000000000.0) {
tmp = x - z;
} else if (x <= 1.4e-152) {
tmp = (y * (1.0 - log(y))) - z;
} else if (x <= 1.95e+51) {
tmp = (log(y) * -0.5) - z;
} else {
tmp = x - (y * (log(y) + -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 <= (-27000000000000.0d0)) then
tmp = x - z
else if (x <= 1.4d-152) then
tmp = (y * (1.0d0 - log(y))) - z
else if (x <= 1.95d+51) then
tmp = (log(y) * (-0.5d0)) - z
else
tmp = x - (y * (log(y) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -27000000000000.0) {
tmp = x - z;
} else if (x <= 1.4e-152) {
tmp = (y * (1.0 - Math.log(y))) - z;
} else if (x <= 1.95e+51) {
tmp = (Math.log(y) * -0.5) - z;
} else {
tmp = x - (y * (Math.log(y) + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -27000000000000.0: tmp = x - z elif x <= 1.4e-152: tmp = (y * (1.0 - math.log(y))) - z elif x <= 1.95e+51: tmp = (math.log(y) * -0.5) - z else: tmp = x - (y * (math.log(y) + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -27000000000000.0) tmp = Float64(x - z); elseif (x <= 1.4e-152) tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); elseif (x <= 1.95e+51) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = Float64(x - Float64(y * Float64(log(y) + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -27000000000000.0) tmp = x - z; elseif (x <= 1.4e-152) tmp = (y * (1.0 - log(y))) - z; elseif (x <= 1.95e+51) tmp = (log(y) * -0.5) - z; else tmp = x - (y * (log(y) + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -27000000000000.0], N[(x - z), $MachinePrecision], If[LessEqual[x, 1.4e-152], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 1.95e+51], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - N[(y * N[(N[Log[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -27000000000000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-152}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\mathbf{elif}\;x \leq 1.95 \cdot 10^{+51}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(\log y + -1\right)\\
\end{array}
\end{array}
if x < -2.7e13Initial program 100.0%
associate--l+99.9%
associate-+l-100.0%
Simplified100.0%
Taylor expanded in z around inf 87.9%
if -2.7e13 < x < 1.39999999999999992e-152Initial program 99.8%
Taylor expanded in y around inf 78.7%
Taylor expanded in y around 0 78.7%
if 1.39999999999999992e-152 < x < 1.94999999999999992e51Initial program 99.8%
Taylor expanded in x around 0 95.5%
Taylor expanded in y around 0 76.6%
*-commutative76.6%
Simplified76.6%
if 1.94999999999999992e51 < x Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in y around inf 87.5%
sub-neg87.5%
mul-1-neg87.5%
log-rec87.5%
remove-double-neg87.5%
metadata-eval87.5%
Simplified87.5%
Final simplification82.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.3e+48) (not (<= z 1.75e+151))) (- x z) (- x (* y (+ (log y) -1.0)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.3e+48) || !(z <= 1.75e+151)) {
tmp = x - z;
} else {
tmp = x - (y * (log(y) + -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 ((z <= (-3.3d+48)) .or. (.not. (z <= 1.75d+151))) then
tmp = x - z
else
tmp = x - (y * (log(y) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -3.3e+48) || !(z <= 1.75e+151)) {
tmp = x - z;
} else {
tmp = x - (y * (Math.log(y) + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.3e+48) or not (z <= 1.75e+151): tmp = x - z else: tmp = x - (y * (math.log(y) + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.3e+48) || !(z <= 1.75e+151)) tmp = Float64(x - z); else tmp = Float64(x - Float64(y * Float64(log(y) + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.3e+48) || ~((z <= 1.75e+151))) tmp = x - z; else tmp = x - (y * (log(y) + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.3e+48], N[Not[LessEqual[z, 1.75e+151]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(x - N[(y * N[(N[Log[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.3 \cdot 10^{+48} \lor \neg \left(z \leq 1.75 \cdot 10^{+151}\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(\log y + -1\right)\\
\end{array}
\end{array}
if z < -3.30000000000000023e48 or 1.7500000000000001e151 < z Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 84.9%
if -3.30000000000000023e48 < z < 1.7500000000000001e151Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in y around inf 72.6%
sub-neg72.6%
mul-1-neg72.6%
log-rec72.6%
remove-double-neg72.6%
metadata-eval72.6%
Simplified72.6%
Final simplification77.1%
(FPCore (x y z)
:precision binary64
(if (<= y 2.8e+27)
(- (- x (* (log y) 0.5)) z)
(if (<= y 3.2e+217)
(- (* y (- 1.0 (log y))) z)
(- x (* y (+ (log y) -1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e+27) {
tmp = (x - (log(y) * 0.5)) - z;
} else if (y <= 3.2e+217) {
tmp = (y * (1.0 - log(y))) - z;
} else {
tmp = x - (y * (log(y) + -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 (y <= 2.8d+27) then
tmp = (x - (log(y) * 0.5d0)) - z
else if (y <= 3.2d+217) then
tmp = (y * (1.0d0 - log(y))) - z
else
tmp = x - (y * (log(y) + (-1.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.8e+27) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else if (y <= 3.2e+217) {
tmp = (y * (1.0 - Math.log(y))) - z;
} else {
tmp = x - (y * (Math.log(y) + -1.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.8e+27: tmp = (x - (math.log(y) * 0.5)) - z elif y <= 3.2e+217: tmp = (y * (1.0 - math.log(y))) - z else: tmp = x - (y * (math.log(y) + -1.0)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.8e+27) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); elseif (y <= 3.2e+217) tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); else tmp = Float64(x - Float64(y * Float64(log(y) + -1.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.8e+27) tmp = (x - (log(y) * 0.5)) - z; elseif (y <= 3.2e+217) tmp = (y * (1.0 - log(y))) - z; else tmp = x - (y * (log(y) + -1.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.8e+27], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[y, 3.2e+217], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x - N[(y * N[(N[Log[y], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.8 \cdot 10^{+27}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+217}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(\log y + -1\right)\\
\end{array}
\end{array}
if y < 2.7999999999999999e27Initial program 100.0%
Taylor expanded in y around 0 96.8%
*-commutative96.8%
Simplified96.8%
if 2.7999999999999999e27 < y < 3.2000000000000001e217Initial program 99.7%
Taylor expanded in y around inf 84.7%
Taylor expanded in y around 0 84.7%
if 3.2000000000000001e217 < y Initial program 99.5%
associate--l+99.5%
associate-+l-99.6%
Simplified99.6%
Taylor expanded in y around inf 97.2%
sub-neg97.2%
mul-1-neg97.2%
log-rec97.2%
remove-double-neg97.2%
metadata-eval97.2%
Simplified97.2%
Final simplification93.5%
(FPCore (x y z) :precision binary64 (if (<= y 5.2e-7) (- (- x (* (log y) 0.5)) z) (+ x (- (- y z) (* y (log y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.2e-7) {
tmp = (x - (log(y) * 0.5)) - z;
} else {
tmp = x + ((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 <= 5.2d-7) then
tmp = (x - (log(y) * 0.5d0)) - z
else
tmp = x + ((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 <= 5.2e-7) {
tmp = (x - (Math.log(y) * 0.5)) - z;
} else {
tmp = x + ((y - z) - (y * Math.log(y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.2e-7: tmp = (x - (math.log(y) * 0.5)) - z else: tmp = x + ((y - z) - (y * math.log(y))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.2e-7) tmp = Float64(Float64(x - Float64(log(y) * 0.5)) - z); else tmp = Float64(x + Float64(Float64(y - z) - Float64(y * log(y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5.2e-7) tmp = (x - (log(y) * 0.5)) - z; else tmp = x + ((y - z) - (y * log(y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.2e-7], N[(N[(x - N[(N[Log[y], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x + N[(N[(y - z), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.2 \cdot 10^{-7}:\\
\;\;\;\;\left(x - \log y \cdot 0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;x + \left(\left(y - z\right) - y \cdot \log y\right)\\
\end{array}
\end{array}
if y < 5.19999999999999998e-7Initial program 100.0%
Taylor expanded in y around 0 99.2%
*-commutative99.2%
Simplified99.2%
if 5.19999999999999998e-7 < y Initial program 99.6%
associate--l+99.6%
associate-+l-99.7%
Simplified99.7%
Taylor expanded in y around inf 98.0%
mul-1-neg98.0%
distribute-rgt-neg-in98.0%
log-rec98.0%
remove-double-neg98.0%
Simplified98.0%
Final simplification98.6%
(FPCore (x y z) :precision binary64 (+ x (- (- y z) (* (log y) (+ y 0.5)))))
double code(double x, double y, double z) {
return x + ((y - z) - (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 = x + ((y - z) - (log(y) * (y + 0.5d0)))
end function
public static double code(double x, double y, double z) {
return x + ((y - z) - (Math.log(y) * (y + 0.5)));
}
def code(x, y, z): return x + ((y - z) - (math.log(y) * (y + 0.5)))
function code(x, y, z) return Float64(x + Float64(Float64(y - z) - Float64(log(y) * Float64(y + 0.5)))) end
function tmp = code(x, y, z) tmp = x + ((y - z) - (log(y) * (y + 0.5))); end
code[x_, y_, z_] := N[(x + N[(N[(y - z), $MachinePrecision] - N[(N[Log[y], $MachinePrecision] * N[(y + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \left(\left(y - z\right) - \log y \cdot \left(y + 0.5\right)\right)
\end{array}
Initial program 99.8%
associate--l+99.8%
associate-+l-99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -90.0) (not (<= x 650.0))) (- x z) (- (* (log y) -0.5) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -90.0) || !(x <= 650.0)) {
tmp = x - z;
} else {
tmp = (log(y) * -0.5) - 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 <= (-90.0d0)) .or. (.not. (x <= 650.0d0))) then
tmp = x - z
else
tmp = (log(y) * (-0.5d0)) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -90.0) || !(x <= 650.0)) {
tmp = x - z;
} else {
tmp = (Math.log(y) * -0.5) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -90.0) or not (x <= 650.0): tmp = x - z else: tmp = (math.log(y) * -0.5) - z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -90.0) || !(x <= 650.0)) tmp = Float64(x - z); else tmp = Float64(Float64(log(y) * -0.5) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -90.0) || ~((x <= 650.0))) tmp = x - z; else tmp = (log(y) * -0.5) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -90.0], N[Not[LessEqual[x, 650.0]], $MachinePrecision]], N[(x - z), $MachinePrecision], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -90 \lor \neg \left(x \leq 650\right):\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\end{array}
\end{array}
if x < -90 or 650 < x Initial program 99.9%
associate--l+99.9%
associate-+l-99.9%
Simplified99.9%
Taylor expanded in z around inf 84.2%
if -90 < x < 650Initial program 99.8%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 61.7%
*-commutative61.7%
Simplified61.7%
Final simplification72.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%
associate-+l-99.8%
Simplified99.8%
Taylor expanded in z around inf 59.3%
Final simplification59.3%
(FPCore (x y z) :precision binary64 (- z))
double code(double x, double y, double z) {
return -z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -z
end function
public static double code(double x, double y, double z) {
return -z;
}
def code(x, y, z): return -z
function code(x, y, z) return Float64(-z) end
function tmp = code(x, y, z) tmp = -z; end
code[x_, y_, z_] := (-z)
\begin{array}{l}
\\
-z
\end{array}
Initial program 99.8%
Taylor expanded in x around 0 70.8%
Taylor expanded in z around inf 30.4%
neg-mul-130.4%
Simplified30.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 2023268
(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))