
(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 -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 77.9%
Taylor expanded in y around -inf 99.6%
neg-mul-199.6%
metadata-eval99.6%
distribute-neg-frac99.6%
distribute-frac-neg299.6%
log-rec99.6%
sub-neg99.6%
Simplified99.6%
if -1.999999999999994e-310 < y Initial program 78.0%
Taylor expanded in x around 0 99.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
Final simplification99.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 4e+303)))
(- z)
(fma x t_0 (- z)))))
double code(double x, double y, double z) {
double t_0 = log((x / y));
double t_1 = x * t_0;
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 4e+303)) {
tmp = -z;
} else {
tmp = fma(x, t_0, -z);
}
return tmp;
}
function code(x, y, z) t_0 = log(Float64(x / y)) t_1 = Float64(x * t_0) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 4e+303)) tmp = Float64(-z); else tmp = fma(x, t_0, Float64(-z)); end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 4e+303]], $MachinePrecision]], (-z), N[(x * t$95$0 + (-z)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \log \left(\frac{x}{y}\right)\\
t_1 := x \cdot t\_0\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 4 \cdot 10^{+303}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, t\_0, -z\right)\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.0%
fma-neg5.0%
Simplified5.0%
Taylor expanded in x around 0 47.4%
mul-1-neg47.4%
Simplified47.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4e303Initial program 99.8%
fma-neg99.8%
Simplified99.8%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+303))) (- 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 <= 4e+303)) {
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 <= 4e+303)) {
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 <= 4e+303): 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 <= 4e+303)) 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 <= 4e+303))) 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, 4e+303]], $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 4 \cdot 10^{+303}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;t\_0 - z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 4e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 5.0%
fma-neg5.0%
Simplified5.0%
Taylor expanded in x around 0 47.4%
mul-1-neg47.4%
Simplified47.4%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4e303Initial program 99.8%
Final simplification87.7%
(FPCore (x y z)
:precision binary64
(if (<= x -2.2e+174)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2.3e-190)
(fma x (log (/ x y)) (- z))
(if (<= x 3.8e-159)
(- z)
(if (<= x 2.95e+203)
(- (* x (- (log (/ y x)))) z)
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.2e+174) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2.3e-190) {
tmp = fma(x, log((x / y)), -z);
} else if (x <= 3.8e-159) {
tmp = -z;
} else if (x <= 2.95e+203) {
tmp = (x * -log((y / x))) - z;
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -2.2e+174) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2.3e-190) tmp = fma(x, log(Float64(x / y)), Float64(-z)); elseif (x <= 3.8e-159) tmp = Float64(-z); elseif (x <= 2.95e+203) tmp = Float64(Float64(x * Float64(-log(Float64(y / x)))) - z); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -2.2e+174], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2.3e-190], N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision] + (-z)), $MachinePrecision], If[LessEqual[x, 3.8e-159], (-z), If[LessEqual[x, 2.95e+203], N[(N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision], N[(x * N[(N[Log[x], $MachinePrecision] - N[Log[y], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.2 \cdot 10^{+174}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2.3 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-159}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 2.95 \cdot 10^{+203}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -2.2000000000000002e174Initial program 41.5%
fma-neg41.5%
Simplified41.5%
Taylor expanded in z around 0 38.1%
Taylor expanded in y around -inf 89.1%
neg-mul-199.4%
metadata-eval99.4%
distribute-neg-frac99.4%
distribute-frac-neg299.4%
log-rec99.4%
sub-neg99.4%
Simplified89.1%
if -2.2000000000000002e174 < x < -2.29999999999999992e-190Initial program 90.6%
fma-neg90.6%
Simplified90.6%
if -2.29999999999999992e-190 < x < 3.8000000000000001e-159Initial program 68.9%
fma-neg68.9%
Simplified68.9%
Taylor expanded in x around 0 89.9%
mul-1-neg89.9%
Simplified89.9%
if 3.8000000000000001e-159 < x < 2.94999999999999986e203Initial program 93.2%
clear-num59.4%
log-div59.4%
metadata-eval59.4%
Applied egg-rr94.5%
neg-sub059.4%
Simplified94.5%
if 2.94999999999999986e203 < x Initial program 55.7%
fma-neg55.7%
Simplified55.7%
Taylor expanded in z around 0 47.9%
Taylor expanded in x around 0 85.4%
log-rec99.1%
sub-neg99.1%
Simplified85.4%
Final simplification91.0%
(FPCore (x y z)
:precision binary64
(if (<= x -1.9e+174)
(* x (- (log (- x)) (log (- y))))
(if (<= x -2e-310)
(fma x (log (/ x y)) (- z))
(- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.9e+174) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -2e-310) {
tmp = fma(x, log((x / y)), -z);
} else {
tmp = (x * (log(x) - log(y))) - z;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -1.9e+174) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -2e-310) tmp = fma(x, log(Float64(x / y)), Float64(-z)); else tmp = Float64(Float64(x * Float64(log(x) - log(y))) - z); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -1.9e+174], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -2e-310], N[(x * N[Log[N[(x / y), $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}\;x \leq -1.9 \cdot 10^{+174}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -1.9000000000000001e174Initial program 41.5%
fma-neg41.5%
Simplified41.5%
Taylor expanded in z around 0 38.1%
Taylor expanded in y around -inf 89.1%
neg-mul-199.4%
metadata-eval99.4%
distribute-neg-frac99.4%
distribute-frac-neg299.4%
log-rec99.4%
sub-neg99.4%
Simplified89.1%
if -1.9000000000000001e174 < x < -1.999999999999994e-310Initial program 88.0%
fma-neg88.0%
Simplified88.0%
if -1.999999999999994e-310 < x Initial program 78.0%
Taylor expanded in x around 0 99.4%
log-rec99.4%
sub-neg99.4%
Simplified99.4%
Final simplification94.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.15e-79) (not (<= z 2.1e+15))) (- z) (* x (- (log (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15e-79) || !(z <= 2.1e+15)) {
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 <= (-1.15d-79)) .or. (.not. (z <= 2.1d+15))) 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 <= -1.15e-79) || !(z <= 2.1e+15)) {
tmp = -z;
} else {
tmp = x * -Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.15e-79) or not (z <= 2.1e+15): tmp = -z else: tmp = x * -math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.15e-79) || !(z <= 2.1e+15)) tmp = Float64(-z); else tmp = Float64(x * Float64(-log(Float64(y / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.15e-79) || ~((z <= 2.1e+15))) tmp = -z; else tmp = x * -log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.15e-79], N[Not[LessEqual[z, 2.1e+15]], $MachinePrecision]], (-z), N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{-79} \lor \neg \left(z \leq 2.1 \cdot 10^{+15}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if z < -1.15000000000000006e-79 or 2.1e15 < z Initial program 84.2%
fma-neg84.2%
Simplified84.2%
Taylor expanded in x around 0 80.3%
mul-1-neg80.3%
Simplified80.3%
if -1.15000000000000006e-79 < z < 2.1e15Initial program 71.8%
fma-neg71.8%
Simplified71.8%
Taylor expanded in z around 0 58.9%
clear-num58.9%
log-div58.9%
metadata-eval58.9%
Applied egg-rr58.9%
neg-sub058.9%
Simplified58.9%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.5e-79) (not (<= z 1.5e+14))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.5e-79) || !(z <= 1.5e+14)) {
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 <= (-2.5d-79)) .or. (.not. (z <= 1.5d+14))) 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 <= -2.5e-79) || !(z <= 1.5e+14)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.5e-79) or not (z <= 1.5e+14): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.5e-79) || !(z <= 1.5e+14)) 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 <= -2.5e-79) || ~((z <= 1.5e+14))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.5e-79], N[Not[LessEqual[z, 1.5e+14]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{-79} \lor \neg \left(z \leq 1.5 \cdot 10^{+14}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -2.5e-79 or 1.5e14 < z Initial program 84.2%
fma-neg84.2%
Simplified84.2%
Taylor expanded in x around 0 80.3%
mul-1-neg80.3%
Simplified80.3%
if -2.5e-79 < z < 1.5e14Initial program 71.8%
fma-neg71.8%
Simplified71.8%
Taylor expanded in z around 0 58.9%
Final simplification69.5%
(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 78.0%
fma-neg78.0%
Simplified78.0%
Taylor expanded in x around 0 51.1%
mul-1-neg51.1%
Simplified51.1%
Final simplification51.1%
(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 78.0%
fma-neg78.0%
Simplified78.0%
Taylor expanded in x around inf 44.3%
log-rec44.3%
associate-+r+44.3%
mul-1-neg44.3%
unsub-neg44.3%
neg-mul-144.3%
distribute-lft-out44.3%
distribute-lft-out44.3%
neg-mul-144.3%
mul-1-neg44.3%
log-rec44.3%
remove-double-neg44.3%
+-commutative44.3%
sub-neg44.3%
Simplified44.3%
Taylor expanded in x around 0 38.2%
neg-mul-138.2%
distribute-neg-frac38.2%
Simplified38.2%
clear-num38.1%
un-div-inv38.5%
add-sqr-sqrt19.1%
sqrt-unprod12.6%
sqr-neg12.6%
sqrt-unprod1.1%
add-sqr-sqrt2.0%
Applied egg-rr2.0%
associate-/r/2.1%
*-inverses2.1%
*-lft-identity2.1%
Simplified2.1%
Final simplification2.1%
(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 2024071
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(if (< y 7.595077799083773e-308) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z))
(- (* x (log (/ x y))) z))