
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / 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((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (- (* x (log (/ x y))) z))
double code(double x, double y, double z) {
return (x * log((x / 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((x / y))) - z
end function
public static double code(double x, double y, double z) {
return (x * Math.log((x / y))) - z;
}
def code(x, y, z): return (x * math.log((x / y))) - z
function code(x, y, z) return Float64(Float64(x * log(Float64(x / y))) - z) end
function tmp = code(x, y, z) tmp = (x * log((x / y))) - z; end
code[x_, y_, z_] := N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \log \left(\frac{x}{y}\right) - z
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (+ (log (pow (cbrt y) -2.0)) (- (log (- x)) (log (- (cbrt y)))))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(pow(cbrt(y), -2.0)) + (log(-x) - log(-cbrt(y))))) - z;
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (Math.log(Math.pow(Math.cbrt(y), -2.0)) + (Math.log(-x) - Math.log(-Math.cbrt(y))))) - z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = Float64(Float64(x * Float64(log((cbrt(y) ^ -2.0)) + Float64(log(Float64(-x)) - log(Float64(-cbrt(y)))))) - z); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[N[Power[N[Power[y, 1/3], $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision] + N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-N[Power[y, 1/3], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left({\left(\sqrt[3]{y}\right)}^{-2}\right) + \left(\log \left(-x\right) - \log \left(-\sqrt[3]{y}\right)\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 73.5%
*-un-lft-identity73.5%
add-cube-cbrt73.5%
times-frac73.5%
log-prod89.1%
pow289.1%
metadata-eval89.1%
pow-flip89.1%
metadata-eval89.1%
metadata-eval89.1%
Applied egg-rr89.1%
frac-2neg89.1%
log-div99.5%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.4%
log-div99.5%
Applied egg-rr99.5%
sub-neg99.5%
distribute-rgt-in99.6%
Applied egg-rr99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 1e+306) (- t_0 z) (- z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = -z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = -z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = -z;
} else if (t_0 <= 1e+306) {
tmp = t_0 - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = -z elif t_0 <= 1e+306: tmp = t_0 - z else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(-z); elseif (t_0 <= 1e+306) tmp = Float64(t_0 - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = -z; elseif (t_0 <= 1e+306) tmp = t_0 - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], (-z), If[LessEqual[t$95$0, 1e+306], N[(t$95$0 - z), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_0 \leq 10^{+306}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 1.00000000000000002e306 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.6%
Taylor expanded in x around 0 53.9%
neg-mul-153.9%
Simplified53.9%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 1.00000000000000002e306Initial program 99.8%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (fma (+ (log (- x)) (log (/ -1.0 y))) x (- z)) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = fma((log(-x) + log((-1.0 / y))), x, -z);
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = fma(Float64(log(Float64(-x)) + log(Float64(-1.0 / y))), x, Float64(-z)); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(N[Log[(-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * x + (-z)), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\log \left(-x\right) + \log \left(\frac{-1}{y}\right), x, -z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 73.5%
*-commutative73.5%
add-sqr-sqrt0.0%
associate-*r*0.0%
fma-neg0.0%
Applied egg-rr0.0%
Taylor expanded in y around -inf 99.5%
fma-neg99.5%
neg-mul-199.5%
Simplified99.5%
if -4.999999999999985e-310 < y Initial program 78.4%
log-div99.5%
Applied egg-rr99.5%
sub-neg99.5%
distribute-rgt-in99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(if (<= x -1.05e+223)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1e-214)
(- (- z) (* x (log (/ y x))))
(if (<= x -1e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+223) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1e-214) {
tmp = -z - (x * log((y / x)));
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (log(x) - 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 (x <= (-1.05d+223)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1d-214)) then
tmp = -z - (x * log((y / x)))
else if (x <= (-1d-308)) then
tmp = -z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.05e+223) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1e-214) {
tmp = -z - (x * Math.log((y / x)));
} else if (x <= -1e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.05e+223: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1e-214: tmp = -z - (x * math.log((y / x))) elif x <= -1e-308: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.05e+223) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1e-214) tmp = Float64(Float64(-z) - Float64(x * log(Float64(y / x)))); elseif (x <= -1e-308) tmp = Float64(-z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.05e+223) tmp = x * (log(-x) - log(-y)); elseif (x <= -1e-214) tmp = -z - (x * log((y / x))); elseif (x <= -1e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.05e+223], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-214], N[((-z) - N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1e-308], (-z), N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.05 \cdot 10^{+223}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-214}:\\
\;\;\;\;\left(-z\right) - x \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.04999999999999995e223Initial program 40.3%
Taylor expanded in z around 0 40.3%
frac-2neg40.3%
log-div93.4%
Applied egg-rr93.4%
if -1.04999999999999995e223 < x < -9.99999999999999913e-215Initial program 85.7%
clear-num45.7%
neg-log47.4%
Applied egg-rr87.4%
if -9.99999999999999913e-215 < x < -9.9999999999999991e-309Initial program 55.6%
Taylor expanded in x around 0 97.1%
neg-mul-197.1%
Simplified97.1%
if -9.9999999999999991e-309 < x Initial program 78.4%
log-div99.5%
Applied egg-rr99.5%
Final simplification94.3%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = (x * (log(x) - 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 <= (-5d-310)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-310: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 73.5%
frac-2neg35.9%
log-div46.2%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.4%
log-div99.5%
Applied egg-rr99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y -5e-310) (- (* x (- (log (- x)) (log (- y)))) z) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (log(-x) - log(-y))) - z;
} else {
tmp = ((x * log(x)) - (x * 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 <= (-5d-310)) then
tmp = (x * (log(-x) - log(-y))) - z
else
tmp = ((x * log(x)) - (x * log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e-310) {
tmp = (x * (Math.log(-x) - Math.log(-y))) - z;
} else {
tmp = ((x * Math.log(x)) - (x * Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e-310: tmp = (x * (math.log(-x) - math.log(-y))) - z else: tmp = ((x * math.log(x)) - (x * math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e-310) tmp = Float64(Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))) - z); else tmp = Float64(Float64(Float64(x * log(x)) - Float64(x * log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e-310) tmp = (x * (log(-x) - log(-y))) - z; else tmp = ((x * log(x)) - (x * log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e-310], N[(N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(N[(x * N[Log[x], $MachinePrecision]), $MachinePrecision] - N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-310}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -4.999999999999985e-310Initial program 73.5%
frac-2neg35.9%
log-div46.2%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 78.4%
log-div99.5%
Applied egg-rr99.5%
sub-neg99.5%
distribute-rgt-in99.6%
Applied egg-rr99.6%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(if (<= z -1.1e+100)
(- z)
(if (<= z -1.4e+68)
(* x (log (/ x y)))
(if (<= z -5.5e-26)
(- z)
(if (<= z 2.3e-22) (* (- x) (log (/ y x))) (- z))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+100) {
tmp = -z;
} else if (z <= -1.4e+68) {
tmp = x * log((x / y));
} else if (z <= -5.5e-26) {
tmp = -z;
} else if (z <= 2.3e-22) {
tmp = -x * log((y / x));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.1d+100)) then
tmp = -z
else if (z <= (-1.4d+68)) then
tmp = x * log((x / y))
else if (z <= (-5.5d-26)) then
tmp = -z
else if (z <= 2.3d-22) then
tmp = -x * log((y / x))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+100) {
tmp = -z;
} else if (z <= -1.4e+68) {
tmp = x * Math.log((x / y));
} else if (z <= -5.5e-26) {
tmp = -z;
} else if (z <= 2.3e-22) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+100: tmp = -z elif z <= -1.4e+68: tmp = x * math.log((x / y)) elif z <= -5.5e-26: tmp = -z elif z <= 2.3e-22: tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+100) tmp = Float64(-z); elseif (z <= -1.4e+68) tmp = Float64(x * log(Float64(x / y))); elseif (z <= -5.5e-26) tmp = Float64(-z); elseif (z <= 2.3e-22) tmp = Float64(Float64(-x) * log(Float64(y / x))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e+100) tmp = -z; elseif (z <= -1.4e+68) tmp = x * log((x / y)); elseif (z <= -5.5e-26) tmp = -z; elseif (z <= 2.3e-22) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+100], (-z), If[LessEqual[z, -1.4e+68], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5.5e-26], (-z), If[LessEqual[z, 2.3e-22], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+100}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{+68}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{-26}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-22}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.1e100 or -1.4e68 < z < -5.5000000000000005e-26 or 2.2999999999999998e-22 < z Initial program 75.1%
Taylor expanded in x around 0 82.5%
neg-mul-182.5%
Simplified82.5%
if -1.1e100 < z < -1.4e68Initial program 83.9%
Taylor expanded in z around 0 83.9%
if -5.5000000000000005e-26 < z < 2.2999999999999998e-22Initial program 75.9%
Taylor expanded in z around 0 63.5%
clear-num63.5%
neg-log65.1%
Applied egg-rr65.1%
Final simplification74.9%
(FPCore (x y z)
:precision binary64
(if (<= z -1.1e+100)
(- z)
(if (or (<= z -1.1e+72) (and (not (<= z -5.2e-26)) (<= z 1.7e-22)))
(* x (log (/ x y)))
(- z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+100) {
tmp = -z;
} else if ((z <= -1.1e+72) || (!(z <= -5.2e-26) && (z <= 1.7e-22))) {
tmp = x * log((x / y));
} else {
tmp = -z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.1d+100)) then
tmp = -z
else if ((z <= (-1.1d+72)) .or. (.not. (z <= (-5.2d-26))) .and. (z <= 1.7d-22)) then
tmp = x * log((x / y))
else
tmp = -z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1e+100) {
tmp = -z;
} else if ((z <= -1.1e+72) || (!(z <= -5.2e-26) && (z <= 1.7e-22))) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1e+100: tmp = -z elif (z <= -1.1e+72) or (not (z <= -5.2e-26) and (z <= 1.7e-22)): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1e+100) tmp = Float64(-z); elseif ((z <= -1.1e+72) || (!(z <= -5.2e-26) && (z <= 1.7e-22))) tmp = Float64(x * log(Float64(x / y))); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1e+100) tmp = -z; elseif ((z <= -1.1e+72) || (~((z <= -5.2e-26)) && (z <= 1.7e-22))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1e+100], (-z), If[Or[LessEqual[z, -1.1e+72], And[N[Not[LessEqual[z, -5.2e-26]], $MachinePrecision], LessEqual[z, 1.7e-22]]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+100}:\\
\;\;\;\;-z\\
\mathbf{elif}\;z \leq -1.1 \cdot 10^{+72} \lor \neg \left(z \leq -5.2 \cdot 10^{-26}\right) \land z \leq 1.7 \cdot 10^{-22}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if z < -1.1e100 or -1.1e72 < z < -5.2000000000000002e-26 or 1.6999999999999999e-22 < z Initial program 75.1%
Taylor expanded in x around 0 82.5%
neg-mul-182.5%
Simplified82.5%
if -1.1e100 < z < -1.1e72 or -5.2000000000000002e-26 < z < 1.6999999999999999e-22Initial program 76.3%
Taylor expanded in z around 0 64.5%
Final simplification74.2%
(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 75.6%
Taylor expanded in x around 0 53.9%
neg-mul-153.9%
Simplified53.9%
Final simplification53.9%
(FPCore (x y z) :precision binary64 (if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * log((x / y))) - z;
} else {
tmp = (x * (log(x) - 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 < 7.595077799083773d-308) then
tmp = (x * log((x / y))) - z
else
tmp = (x * (log(x) - log(y))) - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y < 7.595077799083773e-308) {
tmp = (x * Math.log((x / y))) - z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y < 7.595077799083773e-308: tmp = (x * math.log((x / y))) - z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (y < 7.595077799083773e-308) tmp = Float64(Float64(x * log(Float64(x / y))) - z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y < 7.595077799083773e-308) tmp = (x * log((x / y))) - z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[y, 7.595077799083773e-308], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], N[(N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y < 7.595077799083773 \cdot 10^{-308}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
herbie shell --seed 2023224
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))