
(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 12 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 (- (* x (* 3.0 (log (/ (cbrt x) (cbrt y))))) z))
double code(double x, double y, double z) {
return (x * (3.0 * log((cbrt(x) / cbrt(y))))) - z;
}
public static double code(double x, double y, double z) {
return (x * (3.0 * Math.log((Math.cbrt(x) / Math.cbrt(y))))) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(3.0 * log(Float64(cbrt(x) / cbrt(y))))) - z) end
code[x_, y_, z_] := N[(N[(x * N[(3.0 * N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(3 \cdot \log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right)\right) - z
\end{array}
Initial program 79.3%
add-cube-cbrt79.3%
log-prod79.3%
pow279.3%
Applied egg-rr79.3%
log-pow79.3%
distribute-lft1-in79.3%
metadata-eval79.3%
Simplified79.3%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+302))) (- z) (- t_0 z))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 5e+302)) {
tmp = -z;
} else {
tmp = t_0 - 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) || !(t_0 <= 5e+302)) {
tmp = -z;
} else {
tmp = t_0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 5e+302): tmp = -z else: tmp = t_0 - z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 5e+302)) tmp = Float64(-z); else tmp = Float64(t_0 - 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) || ~((t_0 <= 5e+302))) tmp = -z; else tmp = t_0 - 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[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 5e+302]], $MachinePrecision]], (-z), N[(t$95$0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{+302}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5e302 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.7%
remove-double-neg4.7%
sub0-neg4.7%
associate--r-4.7%
neg-sub04.7%
distribute-rgt-neg-in4.7%
neg-sub04.7%
log-div42.4%
associate-+l-42.4%
neg-sub042.4%
+-commutative42.4%
sub-neg42.4%
log-div7.6%
fma-udef7.6%
Simplified7.6%
Taylor expanded in x around 0 44.2%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e302Initial program 99.3%
Final simplification87.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (log (/ x y)))))
(if (<= t_0 (- INFINITY))
(* x (- (log (- x)) (log (- y))))
(if (<= t_0 5e+302) (- 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 = x * (log(-x) - log(-y));
} else if (t_0 <= 5e+302) {
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 = x * (Math.log(-x) - Math.log(-y));
} else if (t_0 <= 5e+302) {
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 = x * (math.log(-x) - math.log(-y)) elif t_0 <= 5e+302: 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(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (t_0 <= 5e+302) 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 = x * (log(-x) - log(-y)); elseif (t_0 <= 5e+302) 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)], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+302], 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:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 5.3%
Taylor expanded in z around 0 5.3%
frac-2neg5.3%
log-div57.8%
Applied egg-rr57.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e302Initial program 99.3%
if 5e302 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 4.2%
remove-double-neg4.2%
sub0-neg4.2%
associate--r-4.2%
neg-sub04.2%
distribute-rgt-neg-in4.2%
neg-sub04.2%
log-div47.7%
associate-+l-47.7%
neg-sub047.7%
+-commutative47.7%
sub-neg47.7%
log-div5.7%
fma-udef5.7%
Simplified5.7%
Taylor expanded in x around 0 53.1%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= y -2e-310) (- (fma x (- (log (- y)) (log (- x))) z)) (- (* x (* 2.0 (log (/ (sqrt x) (sqrt y))))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-310) {
tmp = -fma(x, (log(-y) - log(-x)), z);
} else {
tmp = (x * (2.0 * log((sqrt(x) / sqrt(y))))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2e-310) tmp = Float64(-fma(x, Float64(log(Float64(-y)) - log(Float64(-x))), z)); else tmp = Float64(Float64(x * Float64(2.0 * log(Float64(sqrt(x) / sqrt(y))))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2e-310], (-N[(x * N[(N[Log[(-y)], $MachinePrecision] - N[Log[(-x)], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]), N[(N[(x * N[(2.0 * N[Log[N[(N[Sqrt[x], $MachinePrecision] / N[Sqrt[y], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(-y\right) - \log \left(-x\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\frac{\sqrt{x}}{\sqrt{y}}\right)\right) - z\\
\end{array}
\end{array}
if y < -1.999999999999994e-310Initial program 78.4%
remove-double-neg78.4%
sub0-neg78.4%
associate--r-78.4%
neg-sub078.4%
distribute-rgt-neg-in78.4%
neg-sub078.4%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div77.5%
fma-udef77.5%
Simplified77.5%
frac-2neg77.5%
log-div99.5%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 80.5%
add-sqr-sqrt80.5%
log-prod80.5%
Applied egg-rr80.5%
count-280.5%
Simplified80.5%
sqrt-div99.8%
div-inv99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y -2e-310) (- (fma x (- (log (- y)) (log (- x))) z)) (- (- (* x (log x)) (* x (log y))) z)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-310) {
tmp = -fma(x, (log(-y) - log(-x)), z);
} else {
tmp = ((x * log(x)) - (x * log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2e-310) tmp = Float64(-fma(x, Float64(log(Float64(-y)) - log(Float64(-x))), 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, -2e-310], (-N[(x * N[(N[Log[(-y)], $MachinePrecision] - N[Log[(-x)], $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 -2 \cdot 10^{-310}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(-y\right) - \log \left(-x\right), z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \log x - x \cdot \log y\right) - z\\
\end{array}
\end{array}
if y < -1.999999999999994e-310Initial program 78.4%
remove-double-neg78.4%
sub0-neg78.4%
associate--r-78.4%
neg-sub078.4%
distribute-rgt-neg-in78.4%
neg-sub078.4%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div77.5%
fma-udef77.5%
Simplified77.5%
frac-2neg77.5%
log-div99.5%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 80.5%
add-cbrt-cube54.0%
pow354.0%
Applied egg-rr54.0%
rem-cbrt-cube80.5%
add-cube-cbrt80.5%
pow380.5%
exp-to-pow80.4%
add-log-exp80.4%
*-commutative80.4%
associate-*r*80.4%
Applied egg-rr80.4%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
cbrt-div80.4%
associate-*r*80.4%
add-log-exp80.4%
*-commutative80.4%
exp-to-pow80.5%
pow380.5%
add-cube-cbrt80.5%
diff-log99.3%
sub-neg99.3%
distribute-rgt-in99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(if (<= x -9.6e+160)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.15e-129)
(- (* x (log (/ x y))) z)
(if (<= x -5e-308) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.6e+160) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.15e-129) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-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 <= (-9.6d+160)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.15d-129)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-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 <= -9.6e+160) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.15e-129) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-308) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9.6e+160: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.15e-129: tmp = (x * math.log((x / y))) - z elif x <= -5e-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 <= -9.6e+160) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.15e-129) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-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 <= -9.6e+160) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.15e-129) tmp = (x * log((x / y))) - z; elseif (x <= -5e-308) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9.6e+160], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.15e-129], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-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 -9.6 \cdot 10^{+160}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.15 \cdot 10^{-129}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-308}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -9.6000000000000006e160Initial program 59.2%
Taylor expanded in z around 0 52.2%
frac-2neg52.2%
log-div91.4%
Applied egg-rr91.4%
if -9.6000000000000006e160 < x < -1.15e-129Initial program 96.9%
if -1.15e-129 < x < -4.99999999999999955e-308Initial program 62.4%
remove-double-neg62.4%
sub0-neg62.4%
associate--r-62.4%
neg-sub062.4%
distribute-rgt-neg-in62.4%
neg-sub062.4%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div61.2%
fma-udef61.2%
Simplified61.2%
Taylor expanded in x around 0 85.7%
if -4.99999999999999955e-308 < x Initial program 80.5%
log-div99.3%
Applied egg-rr99.3%
Final simplification95.6%
(FPCore (x y z)
:precision binary64
(if (<= x -6.6e+160)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.42e-130)
(- (* x (* 2.0 (log (sqrt (/ x y))))) z)
(if (<= x -5e-310) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.6e+160) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.42e-130) {
tmp = (x * (2.0 * log(sqrt((x / y))))) - z;
} else if (x <= -5e-310) {
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 <= (-6.6d+160)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.42d-130)) then
tmp = (x * (2.0d0 * log(sqrt((x / y))))) - z
else if (x <= (-5d-310)) 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 <= -6.6e+160) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.42e-130) {
tmp = (x * (2.0 * Math.log(Math.sqrt((x / y))))) - z;
} else if (x <= -5e-310) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -6.6e+160: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.42e-130: tmp = (x * (2.0 * math.log(math.sqrt((x / y))))) - z elif x <= -5e-310: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -6.6e+160) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.42e-130) tmp = Float64(Float64(x * Float64(2.0 * log(sqrt(Float64(x / y))))) - z); elseif (x <= -5e-310) 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 <= -6.6e+160) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.42e-130) tmp = (x * (2.0 * log(sqrt((x / y))))) - z; elseif (x <= -5e-310) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -6.6e+160], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.42e-130], N[(N[(x * N[(2.0 * N[Log[N[Sqrt[N[(x / y), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-310], (-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 -6.6 \cdot 10^{+160}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.42 \cdot 10^{-130}:\\
\;\;\;\;x \cdot \left(2 \cdot \log \left(\sqrt{\frac{x}{y}}\right)\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -6.5999999999999994e160Initial program 59.2%
Taylor expanded in z around 0 52.2%
frac-2neg52.2%
log-div91.4%
Applied egg-rr91.4%
if -6.5999999999999994e160 < x < -1.4199999999999999e-130Initial program 96.9%
add-sqr-sqrt96.9%
log-prod96.9%
Applied egg-rr96.9%
count-296.9%
Simplified96.9%
if -1.4199999999999999e-130 < x < -4.999999999999985e-310Initial program 62.4%
remove-double-neg62.4%
sub0-neg62.4%
associate--r-62.4%
neg-sub062.4%
distribute-rgt-neg-in62.4%
neg-sub062.4%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div61.2%
fma-udef61.2%
Simplified61.2%
Taylor expanded in x around 0 85.7%
if -4.999999999999985e-310 < x Initial program 80.5%
log-div99.3%
Applied egg-rr99.3%
Final simplification95.6%
(FPCore (x y z) :precision binary64 (if (<= y -2e-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 <= -2e-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 <= (-2d-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 <= -2e-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 <= -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 78.4%
frac-2neg40.8%
log-div52.7%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 80.5%
log-div99.3%
Applied egg-rr99.3%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (<= y -2e-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 <= -2e-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 <= (-2d-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 <= -2e-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 <= -2e-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 <= -2e-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 <= -2e-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, -2e-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 -2 \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 < -1.999999999999994e-310Initial program 78.4%
frac-2neg40.8%
log-div52.7%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 80.5%
add-cbrt-cube54.0%
pow354.0%
Applied egg-rr54.0%
rem-cbrt-cube80.5%
add-cube-cbrt80.5%
pow380.5%
exp-to-pow80.4%
add-log-exp80.4%
*-commutative80.4%
associate-*r*80.4%
Applied egg-rr80.4%
cbrt-div99.7%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.7%
*-rgt-identity99.7%
Simplified99.7%
cbrt-div80.4%
associate-*r*80.4%
add-log-exp80.4%
*-commutative80.4%
exp-to-pow80.5%
pow380.5%
add-cube-cbrt80.5%
diff-log99.3%
sub-neg99.3%
distribute-rgt-in99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.5e+15) (not (<= z 7.2e+25))) (- z) (* (- x) (log (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e+15) || !(z <= 7.2e+25)) {
tmp = -z;
} else {
tmp = -x * log((y / 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 <= (-5.5d+15)) .or. (.not. (z <= 7.2d+25))) then
tmp = -z
else
tmp = -x * log((y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.5e+15) || !(z <= 7.2e+25)) {
tmp = -z;
} else {
tmp = -x * Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.5e+15) or not (z <= 7.2e+25): tmp = -z else: tmp = -x * math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.5e+15) || !(z <= 7.2e+25)) tmp = Float64(-z); else tmp = Float64(Float64(-x) * log(Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.5e+15) || ~((z <= 7.2e+25))) tmp = -z; else tmp = -x * log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.5e+15], N[Not[LessEqual[z, 7.2e+25]], $MachinePrecision]], (-z), N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+15} \lor \neg \left(z \leq 7.2 \cdot 10^{+25}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\end{array}
\end{array}
if z < -5.5e15 or 7.20000000000000031e25 < z Initial program 83.1%
remove-double-neg83.1%
sub0-neg83.1%
associate--r-83.1%
neg-sub083.1%
distribute-rgt-neg-in83.1%
neg-sub083.1%
log-div39.8%
associate-+l-39.8%
neg-sub039.8%
+-commutative39.8%
sub-neg39.8%
log-div81.0%
fma-udef81.0%
Simplified81.0%
Taylor expanded in x around 0 80.8%
if -5.5e15 < z < 7.20000000000000031e25Initial program 76.6%
remove-double-neg76.6%
sub0-neg76.6%
associate--r-76.6%
neg-sub076.6%
distribute-rgt-neg-in76.6%
neg-sub076.6%
log-div48.8%
associate-+l-48.8%
neg-sub048.8%
+-commutative48.8%
sub-neg48.8%
log-div76.6%
fma-udef76.6%
Simplified76.6%
Taylor expanded in x around inf 38.3%
log-rec38.3%
neg-mul-138.3%
neg-mul-138.3%
sub-neg38.3%
log-div61.1%
Simplified61.1%
Final simplification69.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.5e+15) (not (<= z 4.5e+27))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+15) || !(z <= 4.5e+27)) {
tmp = -z;
} else {
tmp = x * log((x / 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 <= (-6.5d+15)) .or. (.not. (z <= 4.5d+27))) then
tmp = -z
else
tmp = x * log((x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -6.5e+15) || !(z <= 4.5e+27)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.5e+15) or not (z <= 4.5e+27): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.5e+15) || !(z <= 4.5e+27)) tmp = Float64(-z); else tmp = Float64(x * log(Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -6.5e+15) || ~((z <= 4.5e+27))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.5e+15], N[Not[LessEqual[z, 4.5e+27]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+15} \lor \neg \left(z \leq 4.5 \cdot 10^{+27}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -6.5e15 or 4.4999999999999999e27 < z Initial program 83.1%
remove-double-neg83.1%
sub0-neg83.1%
associate--r-83.1%
neg-sub083.1%
distribute-rgt-neg-in83.1%
neg-sub083.1%
log-div39.8%
associate-+l-39.8%
neg-sub039.8%
+-commutative39.8%
sub-neg39.8%
log-div81.0%
fma-udef81.0%
Simplified81.0%
Taylor expanded in x around 0 80.8%
if -6.5e15 < z < 4.4999999999999999e27Initial program 76.6%
Taylor expanded in z around 0 61.1%
Final simplification69.4%
(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 79.3%
remove-double-neg79.3%
sub0-neg79.3%
associate--r-79.3%
neg-sub079.3%
distribute-rgt-neg-in79.3%
neg-sub079.3%
log-div45.0%
associate-+l-45.0%
neg-sub045.0%
+-commutative45.0%
sub-neg45.0%
log-div78.4%
fma-udef78.4%
Simplified78.4%
Taylor expanded in x around 0 48.7%
Final simplification48.7%
(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 2023318
(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))