
(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 14 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 (- y (* (+ y 0.5) (log y)))) z))
double code(double x, double y, double z) {
return (x + (y - ((y + 0.5) * log(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 - ((y + 0.5d0) * log(y)))) - z
end function
public static double code(double x, double y, double z) {
return (x + (y - ((y + 0.5) * Math.log(y)))) - z;
}
def code(x, y, z): return (x + (y - ((y + 0.5) * math.log(y)))) - z
function code(x, y, z) return Float64(Float64(x + Float64(y - Float64(Float64(y + 0.5) * log(y)))) - z) end
function tmp = code(x, y, z) tmp = (x + (y - ((y + 0.5) * log(y)))) - z; end
code[x_, y_, z_] := N[(N[(x + N[(y - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(x + \left(y - \left(y + 0.5\right) \cdot \log y\right)\right) - z
\end{array}
Initial program 99.8%
associate-+l-N/A
--lowering--.f64N/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
log-lowering-log.f6499.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (+ y 0.5) (log y))))
(if (<= z -1400000.0)
(- x z)
(if (<= z 3.3e-119) (- x t_0) (if (<= z 3.4e+34) (- y t_0) (- x z))))))
double code(double x, double y, double z) {
double t_0 = (y + 0.5) * log(y);
double tmp;
if (z <= -1400000.0) {
tmp = x - z;
} else if (z <= 3.3e-119) {
tmp = x - t_0;
} else if (z <= 3.4e+34) {
tmp = y - 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 = (y + 0.5d0) * log(y)
if (z <= (-1400000.0d0)) then
tmp = x - z
else if (z <= 3.3d-119) then
tmp = x - t_0
else if (z <= 3.4d+34) then
tmp = y - 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 = (y + 0.5) * Math.log(y);
double tmp;
if (z <= -1400000.0) {
tmp = x - z;
} else if (z <= 3.3e-119) {
tmp = x - t_0;
} else if (z <= 3.4e+34) {
tmp = y - t_0;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): t_0 = (y + 0.5) * math.log(y) tmp = 0 if z <= -1400000.0: tmp = x - z elif z <= 3.3e-119: tmp = x - t_0 elif z <= 3.4e+34: tmp = y - t_0 else: tmp = x - z return tmp
function code(x, y, z) t_0 = Float64(Float64(y + 0.5) * log(y)) tmp = 0.0 if (z <= -1400000.0) tmp = Float64(x - z); elseif (z <= 3.3e-119) tmp = Float64(x - t_0); elseif (z <= 3.4e+34) tmp = Float64(y - t_0); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y + 0.5) * log(y); tmp = 0.0; if (z <= -1400000.0) tmp = x - z; elseif (z <= 3.3e-119) tmp = x - t_0; elseif (z <= 3.4e+34) tmp = y - t_0; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1400000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, 3.3e-119], N[(x - t$95$0), $MachinePrecision], If[LessEqual[z, 3.4e+34], N[(y - t$95$0), $MachinePrecision], N[(x - z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y + 0.5\right) \cdot \log y\\
\mathbf{if}\;z \leq -1400000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-119}:\\
\;\;\;\;x - t\_0\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+34}:\\
\;\;\;\;y - t\_0\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -1.4e6 or 3.3999999999999999e34 < z Initial program 99.8%
Taylor expanded in x around inf
Simplified79.3%
if -1.4e6 < z < 3.30000000000000008e-119Initial program 99.8%
associate--l+N/A
+-commutativeN/A
associate-+r-N/A
+-commutativeN/A
--lowering--.f64N/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
log-lowering-log.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
Simplified74.4%
if 3.30000000000000008e-119 < z < 3.3999999999999999e34Initial program 99.8%
associate--l+N/A
+-commutativeN/A
associate-+r-N/A
+-commutativeN/A
--lowering--.f64N/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
log-lowering-log.f6499.7%
Simplified99.7%
Taylor expanded in y around inf
Simplified75.6%
(FPCore (x y z) :precision binary64 (if (<= x -6.8e+78) (- x z) (if (<= x 4e+113) (- (* y (- 1.0 (log y))) z) (- x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e+78) {
tmp = x - z;
} else if (x <= 4e+113) {
tmp = (y * (1.0 - log(y))) - z;
} 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) :: tmp
if (x <= (-6.8d+78)) then
tmp = x - z
else if (x <= 4d+113) then
tmp = (y * (1.0d0 - log(y))) - z
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e+78) {
tmp = x - z;
} else if (x <= 4e+113) {
tmp = (y * (1.0 - Math.log(y))) - z;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.8e+78: tmp = x - z elif x <= 4e+113: tmp = (y * (1.0 - math.log(y))) - z else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.8e+78) tmp = Float64(x - z); elseif (x <= 4e+113) tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -6.8e+78) tmp = x - z; elseif (x <= 4e+113) tmp = (y * (1.0 - log(y))) - z; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.8e+78], N[(x - z), $MachinePrecision], If[LessEqual[x, 4e+113], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.8 \cdot 10^{+78}:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+113}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -6.80000000000000014e78 or 4e113 < x Initial program 99.9%
Taylor expanded in x around inf
Simplified84.7%
if -6.80000000000000014e78 < x < 4e113Initial program 99.8%
Taylor expanded in y around inf
mul-1-negN/A
log-recN/A
remove-double-negN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
log-lowering-log.f6474.3%
Simplified74.3%
(FPCore (x y z) :precision binary64 (if (<= z -1820000.0) (- x z) (if (<= z 1.65e+15) (- x (* (+ y 0.5) (log y))) (- x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1820000.0) {
tmp = x - z;
} else if (z <= 1.65e+15) {
tmp = x - ((y + 0.5) * log(y));
} 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) :: tmp
if (z <= (-1820000.0d0)) then
tmp = x - z
else if (z <= 1.65d+15) then
tmp = x - ((y + 0.5d0) * log(y))
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1820000.0) {
tmp = x - z;
} else if (z <= 1.65e+15) {
tmp = x - ((y + 0.5) * Math.log(y));
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1820000.0: tmp = x - z elif z <= 1.65e+15: tmp = x - ((y + 0.5) * math.log(y)) else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1820000.0) tmp = Float64(x - z); elseif (z <= 1.65e+15) tmp = Float64(x - Float64(Float64(y + 0.5) * log(y))); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1820000.0) tmp = x - z; elseif (z <= 1.65e+15) tmp = x - ((y + 0.5) * log(y)); else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1820000.0], N[(x - z), $MachinePrecision], If[LessEqual[z, 1.65e+15], N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1820000:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+15}:\\
\;\;\;\;x - \left(y + 0.5\right) \cdot \log y\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -1.82e6 or 1.65e15 < z Initial program 99.8%
Taylor expanded in x around inf
Simplified78.2%
if -1.82e6 < z < 1.65e15Initial program 99.8%
associate--l+N/A
+-commutativeN/A
associate-+r-N/A
+-commutativeN/A
--lowering--.f64N/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
log-lowering-log.f6499.8%
Simplified99.8%
Taylor expanded in x around inf
Simplified71.7%
(FPCore (x y z) :precision binary64 (if (<= x -122.0) (- x z) (if (<= x 5.3e+35) (- (* (log y) -0.5) z) (- x z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -122.0) {
tmp = x - z;
} else if (x <= 5.3e+35) {
tmp = (log(y) * -0.5) - z;
} 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) :: tmp
if (x <= (-122.0d0)) then
tmp = x - z
else if (x <= 5.3d+35) then
tmp = (log(y) * (-0.5d0)) - z
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -122.0) {
tmp = x - z;
} else if (x <= 5.3e+35) {
tmp = (Math.log(y) * -0.5) - z;
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -122.0: tmp = x - z elif x <= 5.3e+35: tmp = (math.log(y) * -0.5) - z else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -122.0) tmp = Float64(x - z); elseif (x <= 5.3e+35) tmp = Float64(Float64(log(y) * -0.5) - z); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -122.0) tmp = x - z; elseif (x <= 5.3e+35) tmp = (log(y) * -0.5) - z; else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -122.0], N[(x - z), $MachinePrecision], If[LessEqual[x, 5.3e+35], N[(N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision] - z), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -122:\\
\;\;\;\;x - z\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+35}:\\
\;\;\;\;\log y \cdot -0.5 - z\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if x < -122 or 5.30000000000000009e35 < x Initial program 99.9%
Taylor expanded in x around inf
Simplified74.3%
if -122 < x < 5.30000000000000009e35Initial program 99.8%
Taylor expanded in y around 0
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
log-lowering-log.f6467.8%
Simplified67.8%
Taylor expanded in x around 0
--lowering--.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
log-lowering-log.f6467.1%
Simplified67.1%
(FPCore (x y z) :precision binary64 (if (<= z -260.0) (- x z) (if (<= z 200.0) (+ x (* (log y) -0.5)) (- x z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -260.0) {
tmp = x - z;
} else if (z <= 200.0) {
tmp = x + (log(y) * -0.5);
} 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) :: tmp
if (z <= (-260.0d0)) then
tmp = x - z
else if (z <= 200.0d0) then
tmp = x + (log(y) * (-0.5d0))
else
tmp = x - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -260.0) {
tmp = x - z;
} else if (z <= 200.0) {
tmp = x + (Math.log(y) * -0.5);
} else {
tmp = x - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -260.0: tmp = x - z elif z <= 200.0: tmp = x + (math.log(y) * -0.5) else: tmp = x - z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -260.0) tmp = Float64(x - z); elseif (z <= 200.0) tmp = Float64(x + Float64(log(y) * -0.5)); else tmp = Float64(x - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -260.0) tmp = x - z; elseif (z <= 200.0) tmp = x + (log(y) * -0.5); else tmp = x - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -260.0], N[(x - z), $MachinePrecision], If[LessEqual[z, 200.0], N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(x - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -260:\\
\;\;\;\;x - z\\
\mathbf{elif}\;z \leq 200:\\
\;\;\;\;x + \log y \cdot -0.5\\
\mathbf{else}:\\
\;\;\;\;x - z\\
\end{array}
\end{array}
if z < -260 or 200 < z Initial program 99.8%
Taylor expanded in x around inf
Simplified76.6%
if -260 < z < 200Initial program 99.8%
Taylor expanded in y around 0
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
log-lowering-log.f6463.2%
Simplified63.2%
Taylor expanded in z around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
log-lowering-log.f6462.7%
Simplified62.7%
(FPCore (x y z) :precision binary64 (if (<= y 8e-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 <= 8e-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 <= 8d-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 <= 8e-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 <= 8e-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 <= 8e-7) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(x + Float64(y - z)) - Float64(y * log(y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8e-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, 8e-7], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x + N[(y - z), $MachinePrecision]), $MachinePrecision] - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-7}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x + \left(y - z\right)\right) - y \cdot \log y\\
\end{array}
\end{array}
if y < 7.9999999999999996e-7Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
log-lowering-log.f6499.9%
Simplified99.9%
if 7.9999999999999996e-7 < y Initial program 99.6%
associate--l+N/A
+-commutativeN/A
associate-+r-N/A
+-commutativeN/A
--lowering--.f64N/A
remove-double-negN/A
sub-negN/A
--lowering--.f64N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
+-commutativeN/A
sub-negN/A
--lowering--.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
log-lowering-log.f6499.7%
Simplified99.7%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
*-lowering-*.f64N/A
log-lowering-log.f6499.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y 8e-7) (- (+ x (* (log y) -0.5)) z) (- (+ y (- x (* y (log y)))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 8e-7) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (y + (x - (y * 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 <= 8d-7) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (y + (x - (y * log(y)))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8e-7) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y + (x - (y * Math.log(y)))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8e-7: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y + (x - (y * math.log(y)))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8e-7) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y + Float64(x - Float64(y * log(y)))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8e-7) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y + (x - (y * log(y)))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8e-7], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y + N[(x - N[(y * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-7}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(y + \left(x - y \cdot \log y\right)\right) - z\\
\end{array}
\end{array}
if y < 7.9999999999999996e-7Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
log-lowering-log.f6499.9%
Simplified99.9%
if 7.9999999999999996e-7 < y Initial program 99.6%
Taylor expanded in y around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
log-recN/A
remove-double-negN/A
*-lowering-*.f64N/A
log-lowering-log.f6499.5%
Simplified99.5%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y 6.2e+35) (- (+ x (* (log y) -0.5)) z) (- (* y (- 1.0 (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.2e+35) {
tmp = (x + (log(y) * -0.5)) - z;
} else {
tmp = (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 <= 6.2d+35) then
tmp = (x + (log(y) * (-0.5d0))) - z
else
tmp = (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 <= 6.2e+35) {
tmp = (x + (Math.log(y) * -0.5)) - z;
} else {
tmp = (y * (1.0 - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.2e+35: tmp = (x + (math.log(y) * -0.5)) - z else: tmp = (y * (1.0 - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.2e+35) tmp = Float64(Float64(x + Float64(log(y) * -0.5)) - z); else tmp = Float64(Float64(y * Float64(1.0 - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.2e+35) tmp = (x + (log(y) * -0.5)) - z; else tmp = (y * (1.0 - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.2e+35], N[(N[(x + N[(N[Log[y], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(y * N[(1.0 - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.2 \cdot 10^{+35}:\\
\;\;\;\;\left(x + \log y \cdot -0.5\right) - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right) - z\\
\end{array}
\end{array}
if y < 6.19999999999999973e35Initial program 100.0%
Taylor expanded in y around 0
sub-negN/A
+-lowering-+.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-lowering-*.f64N/A
log-lowering-log.f6498.0%
Simplified98.0%
if 6.19999999999999973e35 < y Initial program 99.6%
Taylor expanded in y around inf
mul-1-negN/A
log-recN/A
remove-double-negN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
log-lowering-log.f6479.4%
Simplified79.4%
(FPCore (x y z) :precision binary64 (- (+ y (- x (* (+ y 0.5) (log y)))) z))
double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * log(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 = (y + (x - ((y + 0.5d0) * log(y)))) - z
end function
public static double code(double x, double y, double z) {
return (y + (x - ((y + 0.5) * Math.log(y)))) - z;
}
def code(x, y, z): return (y + (x - ((y + 0.5) * math.log(y)))) - z
function code(x, y, z) return Float64(Float64(y + Float64(x - Float64(Float64(y + 0.5) * log(y)))) - z) end
function tmp = code(x, y, z) tmp = (y + (x - ((y + 0.5) * log(y)))) - z; end
code[x_, y_, z_] := N[(N[(y + N[(x - N[(N[(y + 0.5), $MachinePrecision] * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \left(x - \left(y + 0.5\right) \cdot \log y\right)\right) - z
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 1.86e+124) (- x z) (* y (- 1.0 (log y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.86e+124) {
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.86d+124) 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.86e+124) {
tmp = x - z;
} else {
tmp = y * (1.0 - Math.log(y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.86e+124: tmp = x - z else: tmp = y * (1.0 - math.log(y)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.86e+124) 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.86e+124) tmp = x - z; else tmp = y * (1.0 - log(y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.86e+124], 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.86 \cdot 10^{+124}:\\
\;\;\;\;x - z\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \log y\right)\\
\end{array}
\end{array}
if y < 1.8599999999999999e124Initial program 99.9%
Taylor expanded in x around inf
Simplified67.1%
if 1.8599999999999999e124 < y Initial program 99.5%
Taylor expanded in y around inf
mul-1-negN/A
log-recN/A
remove-double-negN/A
*-lowering-*.f64N/A
--lowering--.f64N/A
log-lowering-log.f6468.5%
Simplified68.5%
(FPCore (x y z) :precision binary64 (if (<= x -7e+74) x (if (<= x 1.25e+66) (- 0.0 z) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e+74) {
tmp = x;
} else if (x <= 1.25e+66) {
tmp = 0.0 - 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 <= (-7d+74)) then
tmp = x
else if (x <= 1.25d+66) then
tmp = 0.0d0 - z
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -7e+74) {
tmp = x;
} else if (x <= 1.25e+66) {
tmp = 0.0 - z;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7e+74: tmp = x elif x <= 1.25e+66: tmp = 0.0 - z else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7e+74) tmp = x; elseif (x <= 1.25e+66) tmp = Float64(0.0 - z); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7e+74) tmp = x; elseif (x <= 1.25e+66) tmp = 0.0 - z; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7e+74], x, If[LessEqual[x, 1.25e+66], N[(0.0 - z), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+74}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.25 \cdot 10^{+66}:\\
\;\;\;\;0 - z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.00000000000000029e74 or 1.24999999999999998e66 < x Initial program 99.8%
Taylor expanded in x around inf
Simplified66.3%
if -7.00000000000000029e74 < x < 1.24999999999999998e66Initial program 99.8%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6441.9%
Simplified41.9%
sub0-negN/A
neg-lowering-neg.f6441.9%
Applied egg-rr41.9%
Final simplification50.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%
Taylor expanded in x around inf
Simplified55.5%
(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%
Taylor expanded in x around inf
Simplified26.3%
(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 2024158
(FPCore (x y z)
:name "Numeric.SpecFunctions:stirlingError from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (- (- (+ y x) z) (* (+ y 1/2) (log y))))
(- (+ (- x (* (+ y 0.5) (log y))) y) z))