
(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 (<= x -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 (x <= -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 (x <= (-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 (x <= -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 x <= -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 (x <= -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 (x <= -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[x, -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}\;x \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 x < -1.999999999999994e-310Initial program 77.2%
Taylor expanded in y around -inf 99.3%
metadata-eval99.3%
distribute-neg-frac99.3%
distribute-frac-neg299.3%
log-rec99.3%
sub-neg99.3%
neg-mul-199.3%
Simplified99.3%
if -1.999999999999994e-310 < x Initial program 79.3%
Taylor expanded in x around 0 99.5%
log-rec99.5%
neg-mul-199.5%
neg-mul-199.5%
sub-neg99.5%
Simplified99.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 5e+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 <= 5e+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 <= 5e+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, 5e+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 5 \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 4.9999999999999997e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.6%
Taylor expanded in x around 0 51.3%
mul-1-neg51.3%
Simplified51.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999997e303Initial program 99.9%
fma-neg99.9%
Simplified99.9%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* x (log (/ x y))))) (if (or (<= t_0 (- INFINITY)) (not (<= t_0 5e+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 <= 5e+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 <= 5e+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 <= 5e+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 <= 5e+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 <= 5e+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, 5e+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 5 \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 4.9999999999999997e303 < (*.f64 x (log.f64 (/.f64 x y))) Initial program 7.6%
Taylor expanded in x around 0 51.3%
mul-1-neg51.3%
Simplified51.3%
if -inf.0 < (*.f64 x (log.f64 (/.f64 x y))) < 4.9999999999999997e303Initial program 99.9%
Final simplification88.5%
(FPCore (x y z)
:precision binary64
(if (<= x -4.2e+199)
(* x (- (log (- x)) (log (- y))))
(if (<= x -6e-157)
(- (* x (- (log (/ y x)))) z)
(if (<= x 3.6e-144)
(- z)
(if (<= x 4.4e+254)
(fma x (log (/ x y)) (- z))
(* x (- (log x) (log y))))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -4.2e+199) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -6e-157) {
tmp = (x * -log((y / x))) - z;
} else if (x <= 3.6e-144) {
tmp = -z;
} else if (x <= 4.4e+254) {
tmp = fma(x, log((x / y)), -z);
} else {
tmp = x * (log(x) - log(y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= -4.2e+199) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -6e-157) tmp = Float64(Float64(x * Float64(-log(Float64(y / x)))) - z); elseif (x <= 3.6e-144) tmp = Float64(-z); elseif (x <= 4.4e+254) tmp = fma(x, log(Float64(x / y)), Float64(-z)); else tmp = Float64(x * Float64(log(x) - log(y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, -4.2e+199], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -6e-157], N[(N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, 3.6e-144], (-z), If[LessEqual[x, 4.4e+254], N[(x * N[Log[N[(x / y), $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 -4.2 \cdot 10^{+199}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -6 \cdot 10^{-157}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-144}:\\
\;\;\;\;-z\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{+254}:\\
\;\;\;\;\mathsf{fma}\left(x, \log \left(\frac{x}{y}\right), -z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right)\\
\end{array}
\end{array}
if x < -4.1999999999999999e199Initial program 64.2%
Taylor expanded in z around 0 60.9%
Taylor expanded in y around -inf 95.6%
metadata-eval98.7%
distribute-neg-frac98.7%
distribute-frac-neg298.7%
log-rec98.7%
sub-neg98.7%
neg-mul-198.7%
Simplified95.6%
if -4.1999999999999999e199 < x < -6e-157Initial program 88.7%
clear-num88.7%
neg-log89.9%
Applied egg-rr89.9%
if -6e-157 < x < 3.6e-144Initial program 60.2%
Taylor expanded in x around 0 92.6%
mul-1-neg92.6%
Simplified92.6%
if 3.6e-144 < x < 4.4000000000000002e254Initial program 94.0%
fma-neg94.0%
Simplified94.0%
if 4.4000000000000002e254 < x Initial program 48.0%
Taylor expanded in z around 0 48.0%
Taylor expanded in x around 0 92.7%
log-rec99.1%
neg-mul-199.1%
neg-mul-199.1%
sub-neg99.1%
Simplified92.7%
(FPCore (x y z)
:precision binary64
(if (<= x -5e+199)
(* x (- (log (- x)) (log (- y))))
(if (<= x -1.8e-167)
(- (* x (- (log (/ y x)))) z)
(if (<= x -1e-309) (- z) (- (* x (- (log x) (log y))) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -5e+199) {
tmp = x * (log(-x) - log(-y));
} else if (x <= -1.8e-167) {
tmp = (x * -log((y / x))) - z;
} else if (x <= -1e-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 <= (-5d+199)) then
tmp = x * (log(-x) - log(-y))
else if (x <= (-1.8d-167)) then
tmp = (x * -log((y / x))) - z
else if (x <= (-1d-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 <= -5e+199) {
tmp = x * (Math.log(-x) - Math.log(-y));
} else if (x <= -1.8e-167) {
tmp = (x * -Math.log((y / x))) - z;
} else if (x <= -1e-309) {
tmp = -z;
} else {
tmp = (x * (Math.log(x) - Math.log(y))) - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -5e+199: tmp = x * (math.log(-x) - math.log(-y)) elif x <= -1.8e-167: tmp = (x * -math.log((y / x))) - z elif x <= -1e-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 <= -5e+199) tmp = Float64(x * Float64(log(Float64(-x)) - log(Float64(-y)))); elseif (x <= -1.8e-167) tmp = Float64(Float64(x * Float64(-log(Float64(y / x)))) - z); elseif (x <= -1e-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 <= -5e+199) tmp = x * (log(-x) - log(-y)); elseif (x <= -1.8e-167) tmp = (x * -log((y / x))) - z; elseif (x <= -1e-309) tmp = -z; else tmp = (x * (log(x) - log(y))) - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -5e+199], N[(x * N[(N[Log[(-x)], $MachinePrecision] - N[Log[(-y)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -1.8e-167], N[(N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision] - z), $MachinePrecision], If[LessEqual[x, -1e-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 -5 \cdot 10^{+199}:\\
\;\;\;\;x \cdot \left(\log \left(-x\right) - \log \left(-y\right)\right)\\
\mathbf{elif}\;x \leq -1.8 \cdot 10^{-167}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right) - z\\
\mathbf{elif}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\log x - \log y\right) - z\\
\end{array}
\end{array}
if x < -4.9999999999999998e199Initial program 64.2%
Taylor expanded in z around 0 60.9%
Taylor expanded in y around -inf 95.6%
metadata-eval98.7%
distribute-neg-frac98.7%
distribute-frac-neg298.7%
log-rec98.7%
sub-neg98.7%
neg-mul-198.7%
Simplified95.6%
if -4.9999999999999998e199 < x < -1.8e-167Initial program 88.7%
clear-num88.7%
neg-log89.9%
Applied egg-rr89.9%
if -1.8e-167 < x < -1.000000000000002e-309Initial program 62.5%
Taylor expanded in x around 0 95.0%
mul-1-neg95.0%
Simplified95.0%
if -1.000000000000002e-309 < x Initial program 79.3%
Taylor expanded in x around 0 99.5%
log-rec99.5%
neg-mul-199.5%
neg-mul-199.5%
sub-neg99.5%
Simplified99.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.02e-114) (not (<= z 4.6e-5))) (- z) (* x (- (log (/ y x))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.02e-114) || !(z <= 4.6e-5)) {
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.02d-114)) .or. (.not. (z <= 4.6d-5))) 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.02e-114) || !(z <= 4.6e-5)) {
tmp = -z;
} else {
tmp = x * -Math.log((y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.02e-114) or not (z <= 4.6e-5): tmp = -z else: tmp = x * -math.log((y / x)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.02e-114) || !(z <= 4.6e-5)) 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.02e-114) || ~((z <= 4.6e-5))) tmp = -z; else tmp = x * -log((y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.02e-114], N[Not[LessEqual[z, 4.6e-5]], $MachinePrecision]], (-z), N[(x * (-N[Log[N[(y / x), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{-114} \lor \neg \left(z \leq 4.6 \cdot 10^{-5}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\log \left(\frac{y}{x}\right)\right)\\
\end{array}
\end{array}
if z < -1.0199999999999999e-114 or 4.6e-5 < z Initial program 77.8%
Taylor expanded in x around 0 73.6%
mul-1-neg73.6%
Simplified73.6%
if -1.0199999999999999e-114 < z < 4.6e-5Initial program 79.0%
clear-num79.0%
neg-log80.5%
Applied egg-rr80.5%
Taylor expanded in z around 0 68.0%
associate-*r*68.0%
neg-mul-168.0%
Simplified68.0%
Final simplification71.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.15e-114) (not (<= z 1.45e-5))) (- z) (* x (log (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.15e-114) || !(z <= 1.45e-5)) {
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.15d-114)) .or. (.not. (z <= 1.45d-5))) 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.15e-114) || !(z <= 1.45e-5)) {
tmp = -z;
} else {
tmp = x * Math.log((x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.15e-114) or not (z <= 1.45e-5): tmp = -z else: tmp = x * math.log((x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.15e-114) || !(z <= 1.45e-5)) 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.15e-114) || ~((z <= 1.45e-5))) tmp = -z; else tmp = x * log((x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.15e-114], N[Not[LessEqual[z, 1.45e-5]], $MachinePrecision]], (-z), N[(x * N[Log[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{-114} \lor \neg \left(z \leq 1.45 \cdot 10^{-5}\right):\\
\;\;\;\;-z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \log \left(\frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -2.15e-114 or 1.45e-5 < z Initial program 77.8%
Taylor expanded in x around 0 73.6%
mul-1-neg73.6%
Simplified73.6%
if -2.15e-114 < z < 1.45e-5Initial program 79.0%
Taylor expanded in z around 0 66.5%
Final simplification70.8%
(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.3%
Taylor expanded in x around 0 52.7%
mul-1-neg52.7%
Simplified52.7%
(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.3%
*-commutative78.3%
add-sqr-sqrt40.1%
associate-*r*40.2%
fma-neg40.2%
add-sqr-sqrt21.2%
sqrt-unprod25.0%
sqr-neg25.0%
sqrt-unprod9.1%
add-sqr-sqrt19.3%
Applied egg-rr19.3%
Taylor expanded in x around 0 2.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 2024144
(FPCore (x y z)
:name "Numeric.SpecFunctions.Extra:bd0 from math-functions-0.1.5.2"
:precision binary64
:alt
(! :herbie-platform default (if (< y 7595077799083773/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* x (log (/ x y))) z) (- (* x (- (log x) (log y))) z)))
(- (* x (log (/ x y))) z))