
(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 10 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 77.5%
add-cube-cbrt77.5%
log-prod77.5%
pow277.5%
Applied egg-rr77.5%
log-pow77.5%
distribute-lft1-in77.5%
metadata-eval77.5%
Simplified77.5%
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 (<= t_0 (- INFINITY))
(- z)
(if (<= t_0 INFINITY) (- t_0 z) (* x (- (log x) (log y)))))))
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 <= ((double) INFINITY)) {
tmp = t_0 - z;
} else {
tmp = x * (log(x) - log(y));
}
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 <= Double.POSITIVE_INFINITY) {
tmp = t_0 - z;
} else {
tmp = x * (Math.log(x) - Math.log(y));
}
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 <= math.inf: tmp = t_0 - z else: tmp = x * (math.log(x) - math.log(y)) 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 <= Inf) tmp = Float64(t_0 - z); else tmp = Float64(x * Float64(log(x) - log(y))); 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 <= Inf) tmp = t_0 - z; else tmp = x * (log(x) - log(y)); 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, Infinity], N[(t$95$0 - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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 \infty:\\
\;\;\;\;t\_0 - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0Initial program 5.3%
remove-double-neg5.3%
sub-neg5.3%
distribute-neg-in5.3%
distribute-rgt-neg-in5.3%
remove-double-neg5.3%
fma-udef5.3%
log-div40.5%
sub-neg40.5%
distribute-neg-in40.5%
remove-double-neg40.5%
+-commutative40.5%
sub-neg40.5%
log-div7.9%
Simplified7.9%
Taylor expanded in x around 0 36.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 89.7%
if +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 77.5%
log-div51.7%
Applied egg-rr51.7%
Taylor expanded in z around 0 27.5%
Final simplification82.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 INFINITY))) (- 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 <= ((double) INFINITY))) {
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 <= Double.POSITIVE_INFINITY)) {
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 <= math.inf): 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 <= Inf)) 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 <= Inf))) 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, Infinity]], $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 \infty\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or +inf.0 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.3%
remove-double-neg5.3%
sub-neg5.3%
distribute-neg-in5.3%
distribute-rgt-neg-in5.3%
remove-double-neg5.3%
fma-udef5.3%
log-div40.5%
sub-neg40.5%
distribute-neg-in40.5%
remove-double-neg40.5%
+-commutative40.5%
sub-neg40.5%
log-div7.9%
Simplified7.9%
Taylor expanded in x around 0 36.5%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < +inf.0Initial program 89.7%
Final simplification82.0%
(FPCore (x y z)
:precision binary64
(if (<= x -3.75e+152)
(* x (+ (log (- x)) (log (/ -1.0 y))))
(if (<= x -5e-136)
(- (* x (log (/ x y))) z)
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.75e+152) {
tmp = x * (log(-x) + log((-1.0 / y)));
} else if (x <= -5e-136) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-309) {
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 <= (-3.75d+152)) then
tmp = x * (log(-x) + log(((-1.0d0) / y)))
else if (x <= (-5d-136)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-309)) 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 <= -3.75e+152) {
tmp = x * (Math.log(-x) + Math.log((-1.0 / y)));
} else if (x <= -5e-136) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.75e+152: tmp = x * (math.log(-x) + math.log((-1.0 / y))) elif x <= -5e-136: tmp = (x * math.log((x / y))) - z elif x <= -5e-309: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.75e+152) tmp = Float64(x * Float64(log(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (x <= -5e-136) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-309) 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 <= -3.75e+152) tmp = x * (log(-x) + log((-1.0 / y))); elseif (x <= -5e-136) tmp = (x * log((x / y))) - z; elseif (x <= -5e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.75e+152], N[(x * N[(N[Log[(-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -5e-136], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-309], (-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 -3.75 \cdot 10^{+152}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-136}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -3.75000000000000023e152Initial program 47.1%
flip--2.5%
clear-num2.5%
fma-def2.5%
pow22.5%
pow22.5%
Applied egg-rr2.5%
Taylor expanded in z around 0 44.5%
Taylor expanded in y around -inf 94.3%
+-commutative94.3%
neg-mul-194.3%
Simplified94.3%
if -3.75000000000000023e152 < x < -5.0000000000000002e-136Initial program 96.1%
if -5.0000000000000002e-136 < x < -4.9999999999999995e-309Initial program 73.2%
remove-double-neg73.2%
sub-neg73.2%
distribute-neg-in73.2%
distribute-rgt-neg-in73.2%
remove-double-neg73.2%
fma-udef73.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div70.3%
Simplified70.3%
Taylor expanded in x around 0 85.7%
if -4.9999999999999995e-309 < x Initial program 79.6%
log-div99.4%
Applied egg-rr99.4%
Final simplification96.2%
(FPCore (x y z)
:precision binary64
(if (<= x -9.5e+147)
(* x (+ (log (- x)) (log (/ -1.0 y))))
(if (<= x -3.6e-136)
(- (* x (* 3.0 (log (cbrt (/ x y))))) z)
(if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9.5e+147) {
tmp = x * (log(-x) + log((-1.0 / y)));
} else if (x <= -3.6e-136) {
tmp = (x * (3.0 * log(cbrt((x / y))))) - z;
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9.5e+147) {
tmp = x * (Math.log(-x) + Math.log((-1.0 / y)));
} else if (x <= -3.6e-136) {
tmp = (x * (3.0 * Math.log(Math.cbrt((x / y))))) - z;
} else if (x <= -5e-309) {
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.5e+147) tmp = Float64(x * Float64(log(Float64(-x)) + log(Float64(-1.0 / y)))); elseif (x <= -3.6e-136) tmp = Float64(Float64(x * Float64(3.0 * log(cbrt(Float64(x / y))))) - z); elseif (x <= -5e-309) tmp = Float64(-z); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -9.5e+147], N[(x * N[(N[Log[(-x)], $MachinePrecision] + N[Log[N[(-1.0 / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.6e-136], N[(N[(x * N[(3.0 * N[Log[N[Power[N[(x / y), $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-309], (-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.5 \cdot 10^{+147}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) + \log \left(\frac{-1}{y}\right)\right)\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-136}:\\
\;\;\;\;x \cdot \left(3 \cdot \log \left(\sqrt[3]{\frac{x}{y}}\right)\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -9.4999999999999996e147Initial program 47.1%
flip--2.5%
clear-num2.5%
fma-def2.5%
pow22.5%
pow22.5%
Applied egg-rr2.5%
Taylor expanded in z around 0 44.5%
Taylor expanded in y around -inf 94.3%
+-commutative94.3%
neg-mul-194.3%
Simplified94.3%
if -9.4999999999999996e147 < x < -3.5999999999999998e-136Initial program 96.1%
add-cube-cbrt96.1%
log-prod96.1%
pow296.1%
Applied egg-rr96.1%
log-pow96.1%
distribute-lft1-in96.1%
metadata-eval96.1%
Simplified96.1%
if -3.5999999999999998e-136 < x < -4.9999999999999995e-309Initial program 73.2%
remove-double-neg73.2%
sub-neg73.2%
distribute-neg-in73.2%
distribute-rgt-neg-in73.2%
remove-double-neg73.2%
fma-udef73.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div70.3%
Simplified70.3%
Taylor expanded in x around 0 85.7%
if -4.9999999999999995e-309 < x Initial program 79.6%
log-div99.4%
Applied egg-rr99.4%
Final simplification96.2%
(FPCore (x y z) :precision binary64 (if (<= x -3.6e-136) (- (* x (log (/ x y))) z) (if (<= x -5e-309) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.6e-136) {
tmp = (x * log((x / y))) - z;
} else if (x <= -5e-309) {
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 <= (-3.6d-136)) then
tmp = (x * log((x / y))) - z
else if (x <= (-5d-309)) 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 <= -3.6e-136) {
tmp = (x * Math.log((x / y))) - z;
} else if (x <= -5e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3.6e-136: tmp = (x * math.log((x / y))) - z elif x <= -5e-309: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3.6e-136) tmp = Float64(Float64(x * log(Float64(x / y))) - z); elseif (x <= -5e-309) 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 <= -3.6e-136) tmp = (x * log((x / y))) - z; elseif (x <= -5e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3.6e-136], N[(N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-309], (-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 -3.6 \cdot 10^{-136}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -3.5999999999999998e-136Initial program 75.9%
if -3.5999999999999998e-136 < x < -4.9999999999999995e-309Initial program 73.2%
remove-double-neg73.2%
sub-neg73.2%
distribute-neg-in73.2%
distribute-rgt-neg-in73.2%
remove-double-neg73.2%
fma-udef73.2%
log-div0.0%
sub-neg0.0%
distribute-neg-in0.0%
remove-double-neg0.0%
+-commutative0.0%
sub-neg0.0%
log-div70.3%
Simplified70.3%
Taylor expanded in x around 0 85.7%
if -4.9999999999999995e-309 < x Initial program 79.6%
log-div99.4%
Applied egg-rr99.4%
Final simplification89.4%
(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 75.2%
frac-2neg75.2%
log-div99.5%
Applied egg-rr99.5%
if -4.999999999999985e-310 < y Initial program 79.6%
log-div99.4%
Applied egg-rr99.4%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.95e-84) (not (<= z 3.6e-72))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.95e-84) || !(z <= 3.6e-72)) {
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 <= (-1.95d-84)) .or. (.not. (z <= 3.6d-72))) 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 <= -1.95e-84) || !(z <= 3.6e-72)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.95e-84) or not (z <= 3.6e-72): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.95e-84) || !(z <= 3.6e-72)) 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 <= -1.95e-84) || ~((z <= 3.6e-72))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.95e-84], N[Not[LessEqual[z, 3.6e-72]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-84} \lor \neg \left(z \leq 3.6 \cdot 10^{-72}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.95000000000000011e-84 or 3.6e-72 < z Initial program 78.3%
remove-double-neg78.3%
sub-neg78.3%
distribute-neg-in78.3%
distribute-rgt-neg-in78.3%
remove-double-neg78.3%
fma-udef78.3%
log-div51.8%
sub-neg51.8%
distribute-neg-in51.8%
remove-double-neg51.8%
+-commutative51.8%
sub-neg51.8%
log-div79.5%
Simplified79.5%
Taylor expanded in x around 0 69.3%
if -1.95000000000000011e-84 < z < 3.6e-72Initial program 76.3%
Taylor expanded in z around 0 69.2%
Final simplification69.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 77.5%
remove-double-neg77.5%
sub-neg77.5%
distribute-neg-in77.5%
distribute-rgt-neg-in77.5%
remove-double-neg77.5%
fma-udef77.5%
log-div51.7%
sub-neg51.7%
distribute-neg-in51.7%
remove-double-neg51.7%
+-commutative51.7%
sub-neg51.7%
log-div77.1%
Simplified77.1%
Taylor expanded in x around 0 48.0%
Final simplification48.0%
(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 z end
function tmp = code(x, y, z) tmp = z; end
code[x_, y_, z_] := z
\begin{array}{l}
\\
z
\end{array}
Initial program 77.5%
flip--45.0%
clear-num44.9%
fma-def44.9%
pow244.9%
pow244.9%
Applied egg-rr44.9%
Taylor expanded in x around 0 47.9%
add-sqr-sqrt25.2%
sqrt-unprod15.1%
associate-/r/15.1%
metadata-eval15.1%
associate-/r/15.1%
metadata-eval15.1%
swap-sqr15.1%
metadata-eval15.1%
*-un-lft-identity15.1%
sqrt-unprod1.2%
add-sqr-sqrt2.5%
expm1-log1p-u2.1%
expm1-udef2.0%
Applied egg-rr2.0%
expm1-def2.1%
expm1-log1p2.5%
Simplified2.5%
Final simplification2.5%
(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 2024027
(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))