
(FPCore (x y) :precision binary64 (- (log (+ 1.0 (exp x))) (* x y)))
double code(double x, double y) {
return log((1.0 + exp(x))) - (x * y);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = log((1.0d0 + exp(x))) - (x * y)
end function
public static double code(double x, double y) {
return Math.log((1.0 + Math.exp(x))) - (x * y);
}
def code(x, y): return math.log((1.0 + math.exp(x))) - (x * y)
function code(x, y) return Float64(log(Float64(1.0 + exp(x))) - Float64(x * y)) end
function tmp = code(x, y) tmp = log((1.0 + exp(x))) - (x * y); end
code[x_, y_] := N[(N[Log[N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\log \left(1 + e^{x}\right) - x \cdot y
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (- (log (+ 1.0 (exp x))) (* x y)))
double code(double x, double y) {
return log((1.0 + exp(x))) - (x * y);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = log((1.0d0 + exp(x))) - (x * y)
end function
public static double code(double x, double y) {
return Math.log((1.0 + Math.exp(x))) - (x * y);
}
def code(x, y): return math.log((1.0 + math.exp(x))) - (x * y)
function code(x, y) return Float64(log(Float64(1.0 + exp(x))) - Float64(x * y)) end
function tmp = code(x, y) tmp = log((1.0 + exp(x))) - (x * y); end
code[x_, y_] := N[(N[Log[N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\log \left(1 + e^{x}\right) - x \cdot y
(FPCore (x y) :precision binary64 (- (log (+ 1.0 (/ 1.0 (exp (- x))))) (* x y)))
double code(double x, double y) {
return log((1.0 + (1.0 / exp(-x)))) - (x * y);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = log((1.0d0 + (1.0d0 / exp(-x)))) - (x * y)
end function
public static double code(double x, double y) {
return Math.log((1.0 + (1.0 / Math.exp(-x)))) - (x * y);
}
def code(x, y): return math.log((1.0 + (1.0 / math.exp(-x)))) - (x * y)
function code(x, y) return Float64(log(Float64(1.0 + Float64(1.0 / exp(Float64(-x))))) - Float64(x * y)) end
function tmp = code(x, y) tmp = log((1.0 + (1.0 / exp(-x)))) - (x * y); end
code[x_, y_] := N[(N[Log[N[(1.0 + N[(1.0 / N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]
\log \left(1 + \frac{1}{e^{-x}}\right) - x \cdot y
Initial program 99.1%
lift-exp.f64N/A
remove-double-negN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.1%
Applied rewrites99.1%
(FPCore (x y) :precision binary64 (if (<= x -11500.0) (* (- y) x) (+ 0.6931471805599453 (* x (- (+ 0.5 (* 0.125 x)) y)))))
double code(double x, double y) {
double tmp;
if (x <= -11500.0) {
tmp = -y * x;
} else {
tmp = 0.6931471805599453 + (x * ((0.5 + (0.125 * x)) - y));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-11500.0d0)) then
tmp = -y * x
else
tmp = 0.6931471805599453d0 + (x * ((0.5d0 + (0.125d0 * x)) - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -11500.0) {
tmp = -y * x;
} else {
tmp = 0.6931471805599453 + (x * ((0.5 + (0.125 * x)) - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -11500.0: tmp = -y * x else: tmp = 0.6931471805599453 + (x * ((0.5 + (0.125 * x)) - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -11500.0) tmp = Float64(Float64(-y) * x); else tmp = Float64(0.6931471805599453 + Float64(x * Float64(Float64(0.5 + Float64(0.125 * x)) - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -11500.0) tmp = -y * x; else tmp = 0.6931471805599453 + (x * ((0.5 + (0.125 * x)) - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -11500.0], N[((-y) * x), $MachinePrecision], N[(0.6931471805599453 + N[(x * N[(N[(0.5 + N[(0.125 * x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -11500:\\
\;\;\;\;\left(-y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.6931471805599453 + x \cdot \left(\left(0.5 + 0.125 \cdot x\right) - y\right)\\
\end{array}
if x < -11500Initial program 99.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.3%
Applied rewrites51.3%
if -11500 < x Initial program 99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-*.f6477.1%
Applied rewrites77.1%
Evaluated real constant77.1%
(FPCore (x y) :precision binary64 (if (<= x -1.4) (* (- y) x) (+ 0.6931471805599453 (* x (- 0.5 y)))))
double code(double x, double y) {
double tmp;
if (x <= -1.4) {
tmp = -y * x;
} else {
tmp = 0.6931471805599453 + (x * (0.5 - y));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-1.4d0)) then
tmp = -y * x
else
tmp = 0.6931471805599453d0 + (x * (0.5d0 - y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -1.4) {
tmp = -y * x;
} else {
tmp = 0.6931471805599453 + (x * (0.5 - y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -1.4: tmp = -y * x else: tmp = 0.6931471805599453 + (x * (0.5 - y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -1.4) tmp = Float64(Float64(-y) * x); else tmp = Float64(0.6931471805599453 + Float64(x * Float64(0.5 - y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -1.4) tmp = -y * x; else tmp = 0.6931471805599453 + (x * (0.5 - y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -1.4], N[((-y) * x), $MachinePrecision], N[(0.6931471805599453 + N[(x * N[(0.5 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq -1.4:\\
\;\;\;\;\left(-y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;0.6931471805599453 + x \cdot \left(0.5 - y\right)\\
\end{array}
if x < -1.3999999999999999Initial program 99.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.3%
Applied rewrites51.3%
if -1.3999999999999999 < x Initial program 99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f6482.7%
Applied rewrites82.7%
Evaluated real constant82.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- (log (+ 1.0 (exp x))) (* x y))) (t_1 (* (- y) x)))
(if (<= t_0 5e-5)
t_1
(if (<= t_0 20.0) (+ 0.6931471805599453 (* 0.5 x)) t_1))))double code(double x, double y) {
double t_0 = log((1.0 + exp(x))) - (x * y);
double t_1 = -y * x;
double tmp;
if (t_0 <= 5e-5) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = 0.6931471805599453 + (0.5 * x);
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log((1.0d0 + exp(x))) - (x * y)
t_1 = -y * x
if (t_0 <= 5d-5) then
tmp = t_1
else if (t_0 <= 20.0d0) then
tmp = 0.6931471805599453d0 + (0.5d0 * x)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.log((1.0 + Math.exp(x))) - (x * y);
double t_1 = -y * x;
double tmp;
if (t_0 <= 5e-5) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = 0.6931471805599453 + (0.5 * x);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = math.log((1.0 + math.exp(x))) - (x * y) t_1 = -y * x tmp = 0 if t_0 <= 5e-5: tmp = t_1 elif t_0 <= 20.0: tmp = 0.6931471805599453 + (0.5 * x) else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(log(Float64(1.0 + exp(x))) - Float64(x * y)) t_1 = Float64(Float64(-y) * x) tmp = 0.0 if (t_0 <= 5e-5) tmp = t_1; elseif (t_0 <= 20.0) tmp = Float64(0.6931471805599453 + Float64(0.5 * x)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = log((1.0 + exp(x))) - (x * y); t_1 = -y * x; tmp = 0.0; if (t_0 <= 5e-5) tmp = t_1; elseif (t_0 <= 20.0) tmp = 0.6931471805599453 + (0.5 * x); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Log[N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) * x), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-5], t$95$1, If[LessEqual[t$95$0, 20.0], N[(0.6931471805599453 + N[(0.5 * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \log \left(1 + e^{x}\right) - x \cdot y\\
t_1 := \left(-y\right) \cdot x\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;0.6931471805599453 + 0.5 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) < 5.0000000000000002e-5 or 20 < (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) Initial program 99.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.3%
Applied rewrites51.3%
if 5.0000000000000002e-5 < (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) < 20Initial program 99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f6482.7%
Applied rewrites82.7%
Evaluated real constant82.7%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6449.9%
Applied rewrites49.9%
(FPCore (x y) :precision binary64 (let* ((t_0 (- (log (+ 1.0 (exp x))) (* x y))) (t_1 (* (- y) x))) (if (<= t_0 5e-5) t_1 (if (<= t_0 20.0) 0.6931471805599453 t_1))))
double code(double x, double y) {
double t_0 = log((1.0 + exp(x))) - (x * y);
double t_1 = -y * x;
double tmp;
if (t_0 <= 5e-5) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = 0.6931471805599453;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = log((1.0d0 + exp(x))) - (x * y)
t_1 = -y * x
if (t_0 <= 5d-5) then
tmp = t_1
else if (t_0 <= 20.0d0) then
tmp = 0.6931471805599453d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.log((1.0 + Math.exp(x))) - (x * y);
double t_1 = -y * x;
double tmp;
if (t_0 <= 5e-5) {
tmp = t_1;
} else if (t_0 <= 20.0) {
tmp = 0.6931471805599453;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y): t_0 = math.log((1.0 + math.exp(x))) - (x * y) t_1 = -y * x tmp = 0 if t_0 <= 5e-5: tmp = t_1 elif t_0 <= 20.0: tmp = 0.6931471805599453 else: tmp = t_1 return tmp
function code(x, y) t_0 = Float64(log(Float64(1.0 + exp(x))) - Float64(x * y)) t_1 = Float64(Float64(-y) * x) tmp = 0.0 if (t_0 <= 5e-5) tmp = t_1; elseif (t_0 <= 20.0) tmp = 0.6931471805599453; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y) t_0 = log((1.0 + exp(x))) - (x * y); t_1 = -y * x; tmp = 0.0; if (t_0 <= 5e-5) tmp = t_1; elseif (t_0 <= 20.0) tmp = 0.6931471805599453; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Log[N[(1.0 + N[Exp[x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) * x), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-5], t$95$1, If[LessEqual[t$95$0, 20.0], 0.6931471805599453, t$95$1]]]]
\begin{array}{l}
t_0 := \log \left(1 + e^{x}\right) - x \cdot y\\
t_1 := \left(-y\right) \cdot x\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 20:\\
\;\;\;\;0.6931471805599453\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) < 5.0000000000000002e-5 or 20 < (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) Initial program 99.1%
Taylor expanded in x around inf
lower-*.f64N/A
lower-*.f6451.3%
Applied rewrites51.3%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.3%
Applied rewrites51.3%
if 5.0000000000000002e-5 < (-.f64 (log.f64 (+.f64 #s(literal 1 binary64) (exp.f64 x))) (*.f64 x y)) < 20Initial program 99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f6482.7%
Applied rewrites82.7%
Evaluated real constant82.7%
Taylor expanded in x around 0
Applied rewrites49.4%
(FPCore (x y) :precision binary64 0.6931471805599453)
double code(double x, double y) {
return 0.6931471805599453;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.6931471805599453d0
end function
public static double code(double x, double y) {
return 0.6931471805599453;
}
def code(x, y): return 0.6931471805599453
function code(x, y) return 0.6931471805599453 end
function tmp = code(x, y) tmp = 0.6931471805599453; end
code[x_, y_] := 0.6931471805599453
0.6931471805599453
Initial program 99.1%
Taylor expanded in x around 0
lower-+.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower--.f6482.7%
Applied rewrites82.7%
Evaluated real constant82.7%
Taylor expanded in x around 0
Applied rewrites49.4%
herbie shell --seed 2025258
(FPCore (x y)
:name "Logistic regression 2"
:precision binary64
(- (log (+ 1.0 (exp x))) (* x y)))