
(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 7 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 (* (log (/ (cbrt x) (cbrt y))) 3.0)) z))
double code(double x, double y, double z) {
return (x * (log((cbrt(x) / cbrt(y))) * 3.0)) - z;
}
public static double code(double x, double y, double z) {
return (x * (Math.log((Math.cbrt(x) / Math.cbrt(y))) * 3.0)) - z;
}
function code(x, y, z) return Float64(Float64(x * Float64(log(Float64(cbrt(x) / cbrt(y))) * 3.0)) - z) end
code[x_, y_, z_] := N[(N[(x * N[(N[Log[N[(N[Power[x, 1/3], $MachinePrecision] / N[Power[y, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\log \left(\frac{\sqrt[3]{x}}{\sqrt[3]{y}}\right) \cdot 3\right) - z
\end{array}
Initial program 80.1%
add-cube-cbrt80.1%
log-prod80.1%
pow280.1%
Applied egg-rr80.1%
log-pow80.1%
distribute-lft1-in80.1%
metadata-eval80.1%
*-commutative80.1%
Simplified80.1%
cbrt-div99.8%
div-inv99.7%
Applied egg-rr99.7%
associate-*r/99.8%
*-rgt-identity99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (log (/ x y))) (t_1 (* x t_0)))
(if (<= t_1 (- INFINITY))
(- z)
(if (<= t_1 5e+307) (- (* x (+ (+ t_0 1.0) -1.0)) z) (- 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)) {
tmp = -z;
} else if (t_1 <= 5e+307) {
tmp = (x * ((t_0 + 1.0) + -1.0)) - z;
} else {
tmp = -z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.log((x / y));
double t_1 = x * t_0;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -z;
} else if (t_1 <= 5e+307) {
tmp = (x * ((t_0 + 1.0) + -1.0)) - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = math.log((x / y)) t_1 = x * t_0 tmp = 0 if t_1 <= -math.inf: tmp = -z elif t_1 <= 5e+307: tmp = (x * ((t_0 + 1.0) + -1.0)) - z else: tmp = -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)) tmp = Float64(-z); elseif (t_1 <= 5e+307) tmp = Float64(Float64(x * Float64(Float64(t_0 + 1.0) + -1.0)) - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = log((x / y)); t_1 = x * t_0; tmp = 0.0; if (t_1 <= -Inf) tmp = -z; elseif (t_1 <= 5e+307) tmp = (x * ((t_0 + 1.0) + -1.0)) - z; else tmp = -z; end tmp_2 = 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[LessEqual[t$95$1, (-Infinity)], (-z), If[LessEqual[t$95$1, 5e+307], N[(N[(x * N[(N[(t$95$0 + 1.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], (-z)]]]]
\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:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;x \cdot \left(\left(t_0 + 1\right) + -1\right) - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.4%
clear-num8.4%
log-rec13.8%
Applied egg-rr13.8%
neg-log8.4%
clear-num8.4%
expm1-log1p-u7.1%
expm1-udef7.1%
log1p-udef7.1%
add-exp-log8.4%
associate--l+8.4%
distribute-lft-in8.4%
*-commutative8.4%
*-un-lft-identity8.4%
sub-neg8.4%
add-sqr-sqrt7.1%
sqrt-unprod8.0%
clear-num8.0%
neg-log8.0%
clear-num8.0%
neg-log13.3%
sqr-neg13.3%
sqrt-unprod0.9%
add-sqr-sqrt1.2%
metadata-eval1.2%
Applied egg-rr1.2%
+-commutative1.2%
*-rgt-identity1.2%
distribute-lft-in1.2%
associate-+l+1.2%
metadata-eval1.2%
+-rgt-identity1.2%
Simplified1.2%
Taylor expanded in x around 0 44.8%
neg-mul-144.8%
Simplified44.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
expm1-log1p-u50.1%
expm1-udef50.1%
log1p-udef50.1%
add-exp-log99.8%
Applied egg-rr99.8%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (<= t_0 (- INFINITY)) (- z) (if (<= t_0 5e+307) (- t_0 z) (- z)))))
double code(double x, double y, double z) {
double t_0 = x * log((x / y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = -z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = -z;
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = x * Math.log((x / y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = -z;
} else if (t_0 <= 5e+307) {
tmp = t_0 - z;
} else {
tmp = -z;
}
return tmp;
}
def code(x, y, z): t_0 = x * math.log((x / y)) tmp = 0 if t_0 <= -math.inf: tmp = -z elif t_0 <= 5e+307: tmp = t_0 - z else: tmp = -z return tmp
function code(x, y, z) t_0 = Float64(x * log(Float64(x / y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(-z); elseif (t_0 <= 5e+307) tmp = Float64(t_0 - z); else tmp = Float64(-z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * log((x / y)); tmp = 0.0; if (t_0 <= -Inf) tmp = -z; elseif (t_0 <= 5e+307) tmp = t_0 - z; else tmp = -z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], (-z), If[LessEqual[t$95$0, 5e+307], N[(t$95$0 - z), $MachinePrecision], (-z)]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \log \left(\frac{x}{y}\right)\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;-z\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;t_0 - z\\
\mathbf{else}:\\
\;\;\;\;-z\\
\end{array}
\end{array}
if (*.f64 x (log.f64 (/.f64 x y))) < -inf.0 or 5e307 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 8.4%
clear-num8.4%
log-rec13.8%
Applied egg-rr13.8%
neg-log8.4%
clear-num8.4%
expm1-log1p-u7.1%
expm1-udef7.1%
log1p-udef7.1%
add-exp-log8.4%
associate--l+8.4%
distribute-lft-in8.4%
*-commutative8.4%
*-un-lft-identity8.4%
sub-neg8.4%
add-sqr-sqrt7.1%
sqrt-unprod8.0%
clear-num8.0%
neg-log8.0%
clear-num8.0%
neg-log13.3%
sqr-neg13.3%
sqrt-unprod0.9%
add-sqr-sqrt1.2%
metadata-eval1.2%
Applied egg-rr1.2%
+-commutative1.2%
*-rgt-identity1.2%
distribute-lft-in1.2%
associate-+l+1.2%
metadata-eval1.2%
+-rgt-identity1.2%
Simplified1.2%
Taylor expanded in x around 0 44.8%
neg-mul-144.8%
Simplified44.8%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 5e307Initial program 99.8%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (<= x -4.5e-170) (- (* (- x) (log (/ y x))) z) (if (<= x -5e-305) (- z) (- (* x (- (log x) (log y))) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.5e-170) {
tmp = (-x * log((y / x))) - z;
} else if (x <= -5e-305) {
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 <= (-4.5d-170)) then
tmp = (-x * log((y / x))) - z
else if (x <= (-5d-305)) 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 <= -4.5e-170) {
tmp = (-x * Math.log((y / x))) - z;
} else if (x <= -5e-305) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -4.5e-170: tmp = (-x * math.log((y / x))) - z elif x <= -5e-305: tmp = -z else: tmp = (x * (math.log(x) - math.log(y))) - z return tmp
function code(x, y, z) tmp = 0.0 if (x <= -4.5e-170) tmp = Float64(Float64(Float64(-x) * log(Float64(y / x))) - z); elseif (x <= -5e-305) 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 <= -4.5e-170) tmp = (-x * log((y / x))) - z; elseif (x <= -5e-305) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -4.5e-170], N[(N[((-x) * N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -5e-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 -4.5 \cdot 10^{-170}:\\
\;\;\;\;\left(-x\right) \cdot \log \left(\frac{y}{x}\right) - z\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-305}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -4.50000000000000002e-170Initial program 81.9%
clear-num81.9%
log-rec84.1%
Applied egg-rr84.1%
if -4.50000000000000002e-170 < x < -4.99999999999999985e-305Initial program 59.5%
clear-num59.5%
log-rec59.5%
Applied egg-rr59.5%
neg-log59.5%
clear-num59.5%
expm1-log1p-u8.3%
expm1-udef8.3%
log1p-udef8.3%
add-exp-log59.5%
associate--l+59.5%
distribute-lft-in59.5%
*-commutative59.5%
*-un-lft-identity59.5%
sub-neg59.5%
add-sqr-sqrt8.3%
sqrt-unprod59.4%
clear-num59.4%
neg-log59.4%
clear-num59.4%
neg-log59.4%
sqr-neg59.4%
sqrt-unprod51.1%
add-sqr-sqrt59.4%
metadata-eval59.4%
Applied egg-rr59.4%
+-commutative59.4%
*-rgt-identity59.4%
distribute-lft-in59.4%
associate-+l+59.4%
metadata-eval59.4%
+-rgt-identity59.4%
Simplified59.4%
Taylor expanded in x around 0 89.5%
neg-mul-189.5%
Simplified89.5%
if -4.99999999999999985e-305 < x Initial program 82.6%
log-div99.3%
Applied egg-rr99.3%
Final simplification92.5%
(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.5%
frac-2neg77.5%
log-div99.5%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 82.6%
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 77.5%
frac-2neg77.5%
log-div99.5%
Applied egg-rr99.5%
if -1.999999999999994e-310 < y Initial program 82.6%
clear-num82.6%
log-rec83.1%
Applied egg-rr83.1%
neg-log82.6%
clear-num82.6%
expm1-log1p-u41.4%
expm1-udef41.4%
log1p-udef41.4%
add-exp-log82.6%
associate--l+82.6%
distribute-lft-in82.6%
*-commutative82.6%
*-un-lft-identity82.6%
sub-neg82.6%
add-sqr-sqrt41.7%
sqrt-unprod65.0%
clear-num65.0%
neg-log65.0%
clear-num65.0%
neg-log65.6%
sqr-neg65.6%
sqrt-unprod23.2%
add-sqr-sqrt36.3%
metadata-eval36.3%
Applied egg-rr36.3%
+-commutative36.3%
*-rgt-identity36.3%
distribute-lft-in36.3%
associate-+l+36.3%
metadata-eval36.3%
+-rgt-identity36.3%
Simplified36.3%
add-cube-cbrt36.3%
pow336.3%
exp-to-pow36.3%
add-log-exp36.3%
add-sqr-sqrt23.2%
sqrt-unprod65.6%
sqr-neg65.6%
sqrt-unprod42.2%
add-sqr-sqrt83.1%
add-log-exp82.5%
exp-neg82.5%
exp-to-pow82.6%
pow382.6%
add-cube-cbrt82.6%
clear-num82.6%
diff-log99.3%
sub-neg99.3%
Applied egg-rr99.3%
Final simplification99.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 80.1%
clear-num80.1%
log-rec81.3%
Applied egg-rr81.3%
neg-log80.1%
clear-num80.1%
expm1-log1p-u40.9%
expm1-udef40.9%
log1p-udef40.9%
add-exp-log80.1%
associate--l+80.1%
distribute-lft-in80.1%
*-commutative80.1%
*-un-lft-identity80.1%
sub-neg80.1%
add-sqr-sqrt41.1%
sqrt-unprod62.1%
clear-num62.1%
neg-log62.1%
clear-num62.1%
neg-log63.2%
sqr-neg63.2%
sqrt-unprod20.9%
add-sqr-sqrt35.2%
metadata-eval35.2%
Applied egg-rr35.2%
+-commutative35.2%
*-rgt-identity35.2%
distribute-lft-in35.2%
associate-+l+35.2%
metadata-eval35.2%
+-rgt-identity35.2%
Simplified35.2%
Taylor expanded in x around 0 45.7%
neg-mul-145.7%
Simplified45.7%
Final simplification45.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 2023196
(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))