
(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 (- (* 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 73.4%
add-cube-cbrt73.4%
log-prod73.4%
pow273.4%
Applied egg-rr73.4%
log-pow73.4%
distribute-lft1-in73.4%
metadata-eval73.4%
Simplified73.4%
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 5e+305) (- 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 <= 5e+305) {
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 <= 5e+305) {
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 <= 5e+305: 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 <= 5e+305) 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 <= 5e+305) 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, 5e+305], 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 5 \cdot 10^{+305}:\\
\;\;\;\;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 8.1%
remove-double-neg8.1%
sub0-neg8.1%
associate--r-8.1%
neg-sub08.1%
distribute-rgt-neg-in8.1%
neg-sub08.1%
log-div39.9%
associate-+l-39.9%
neg-sub039.9%
+-commutative39.9%
sub-neg39.9%
log-div12.9%
fma-udef12.9%
Simplified12.9%
Taylor expanded in x around 0 39.1%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000009e305Initial program 99.8%
if 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.9%
Taylor expanded in z around 0 3.9%
log-div48.9%
Applied egg-rr48.9%
Final simplification84.2%
(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+305) (- 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 = x * (log(-x) - log(-y));
} else if (t_0 <= 5e+305) {
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 = x * (Math.log(-x) - Math.log(-y));
} else if (t_0 <= 5e+305) {
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 = x * (math.log(-x) - math.log(-y)) elif t_0 <= 5e+305: 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(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (t_0 <= 5e+305) 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 = x * (log(-x) - log(-y)); elseif (t_0 <= 5e+305) 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)], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+305], 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:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;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 8.1%
Taylor expanded in z around 0 8.1%
frac-2neg8.1%
log-div54.2%
Applied egg-rr54.2%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000009e305Initial program 99.8%
if 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 3.9%
Taylor expanded in z around 0 3.9%
log-div48.9%
Applied egg-rr48.9%
Final simplification86.2%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+305))) (- 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+305)) {
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+305)) {
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+305): 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+305)) 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+305))) 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+305]], $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^{+305}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5.00000000000000009e305 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 6.0%
remove-double-neg6.0%
sub0-neg6.0%
associate--r-6.0%
neg-sub06.0%
distribute-rgt-neg-in6.0%
neg-sub06.0%
log-div48.5%
associate-+l-48.5%
neg-sub048.5%
+-commutative48.5%
sub-neg48.5%
log-div10.6%
fma-udef10.6%
Simplified10.6%
Taylor expanded in x around 0 39.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5.00000000000000009e305Initial program 99.8%
Final simplification82.8%
(FPCore (x y z)
:precision binary64
(if (<= x -6.8e+129)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.75e-126)
(- (fma x (log (/ y x)) z))
(if (<= x -1e-305) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -6.8e+129) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.75e-126) {
tmp = -fma(x, log((y / x)), z);
} else if (x <= -1e-305) {
tmp = -z;
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -6.8e+129) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.75e-126) tmp = Float64(-fma(x, log(Float64(y / x)), z)); elseif (x <= -1e-305) 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, -6.8e+129], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.75e-126], (-N[(x * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision] + z), $MachinePrecision]), If[LessEqual[x, -1e-305], (-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.8 \cdot 10^{+129}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-126}:\\
\;\;\;\;-\mathsf{fma}\left(x, \log \left(\frac{y}{x}\right), z\right)\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-305}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -6.80000000000000036e129Initial program 60.4%
Taylor expanded in z around 0 51.5%
frac-2neg51.5%
log-div90.4%
Applied egg-rr90.4%
if -6.80000000000000036e129 < x < -1.75e-126Initial program 93.8%
remove-double-neg93.8%
sub0-neg93.8%
associate--r-93.8%
neg-sub093.8%
distribute-rgt-neg-in93.8%
neg-sub093.8%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div93.7%
fma-udef93.8%
Simplified93.8%
if -1.75e-126 < x < -9.99999999999999996e-306Initial program 59.2%
remove-double-neg59.2%
sub0-neg59.2%
associate--r-59.2%
neg-sub059.2%
distribute-rgt-neg-in59.2%
neg-sub059.2%
log-div0.0%
associate-+l-0.0%
neg-sub00.0%
+-commutative0.0%
sub-neg0.0%
log-div56.5%
fma-udef56.5%
Simplified56.5%
Taylor expanded in x around 0 84.4%
if -9.99999999999999996e-306 < x Initial program 74.0%
log-div52.7%
Applied egg-rr99.3%
Final simplification94.7%
(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 72.8%
frac-2neg35.9%
log-div52.0%
Applied egg-rr99.6%
if -4.999999999999985e-310 < y Initial program 74.0%
log-div52.7%
Applied egg-rr99.3%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.5e+77) (not (<= x 2e+67))) (* (- x) (log (/ y x))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e+77) || !(x <= 2e+67)) {
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 ((x <= (-1.5d+77)) .or. (.not. (x <= 2d+67))) 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 ((x <= -1.5e+77) || !(x <= 2e+67)) {
tmp = -x * Math.log((y / x));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.5e+77) or not (x <= 2e+67): tmp = -x * math.log((y / x)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.5e+77) || !(x <= 2e+67)) 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 ((x <= -1.5e+77) || ~((x <= 2e+67))) tmp = -x * log((y / x)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.5e+77], N[Not[LessEqual[x, 2e+67]], $MachinePrecision]], N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{+77} \lor \neg \left(x \leq 2 \cdot 10^{+67}\right):\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -1.4999999999999999e77 or 1.99999999999999997e67 < x Initial program 71.6%
remove-double-neg71.6%
sub0-neg71.6%
associate--r-71.6%
neg-sub071.6%
distribute-rgt-neg-in71.6%
neg-sub071.6%
log-div54.9%
associate-+l-54.9%
neg-sub054.9%
+-commutative54.9%
sub-neg54.9%
log-div72.8%
fma-udef72.8%
Simplified72.8%
Taylor expanded in x around inf 45.8%
log-rec45.8%
neg-mul-145.8%
neg-mul-145.8%
sub-neg45.8%
log-div57.2%
Simplified57.2%
if -1.4999999999999999e77 < x < 1.99999999999999997e67Initial program 75.0%
remove-double-neg75.0%
sub0-neg75.0%
associate--r-75.0%
neg-sub075.0%
distribute-rgt-neg-in75.0%
neg-sub075.0%
log-div46.6%
associate-+l-46.6%
neg-sub046.6%
+-commutative46.6%
sub-neg46.6%
log-div75.0%
fma-udef75.0%
Simplified75.0%
Taylor expanded in x around 0 75.4%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -7e+77) (not (<= x 1.3e+76))) (* x (log (/ x y))) (- z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7e+77) || !(x <= 1.3e+76)) {
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 ((x <= (-7d+77)) .or. (.not. (x <= 1.3d+76))) 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 ((x <= -7e+77) || !(x <= 1.3e+76)) {
tmp = x * Math.log((x / y));
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7e+77) or not (x <= 1.3e+76): tmp = x * math.log((x / y)) else: tmp = -z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7e+77) || !(x <= 1.3e+76)) 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 ((x <= -7e+77) || ~((x <= 1.3e+76))) tmp = x * log((x / y)); else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7e+77], N[Not[LessEqual[x, 1.3e+76]], $MachinePrecision]], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], (-z)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+77} \lor \neg \left(x \leq 1.3 \cdot 10^{+76}\right):\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if x < -7.0000000000000003e77 or 1.3e76 < x Initial program 71.6%
Taylor expanded in z around 0 56.0%
if -7.0000000000000003e77 < x < 1.3e76Initial program 75.0%
remove-double-neg75.0%
sub0-neg75.0%
associate--r-75.0%
neg-sub075.0%
distribute-rgt-neg-in75.0%
neg-sub075.0%
log-div46.6%
associate-+l-46.6%
neg-sub046.6%
+-commutative46.6%
sub-neg46.6%
log-div75.0%
fma-udef75.0%
Simplified75.0%
Taylor expanded in x around 0 75.4%
Final simplification66.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 73.4%
remove-double-neg73.4%
sub0-neg73.4%
associate--r-73.4%
neg-sub073.4%
distribute-rgt-neg-in73.4%
neg-sub073.4%
log-div50.4%
associate-+l-50.4%
neg-sub050.4%
+-commutative50.4%
sub-neg50.4%
log-div73.9%
fma-udef74.0%
Simplified74.0%
Taylor expanded in x around 0 48.3%
Final simplification48.3%
(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 2023308
(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))