
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
(FPCore (a b)
:precision binary64
(if (<= a -0.0005)
(/ (exp a) (+ (exp a) 1.0))
(/
(- (* (- (* (- (* 0.16666666666666666 a) -0.5) a) -1.0) a) -1.0)
(+
(+ (* (+ (* (+ (* 0.16666666666666666 a) 0.5) a) 1.0) a) 1.0)
(exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -0.0005) {
tmp = exp(a) / (exp(a) + 1.0);
} else {
tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.0005d0)) then
tmp = exp(a) / (exp(a) + 1.0d0)
else
tmp = ((((((0.16666666666666666d0 * a) - (-0.5d0)) * a) - (-1.0d0)) * a) - (-1.0d0)) / (((((((0.16666666666666666d0 * a) + 0.5d0) * a) + 1.0d0) * a) + 1.0d0) + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.0005) {
tmp = Math.exp(a) / (Math.exp(a) + 1.0);
} else {
tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.0005: tmp = math.exp(a) / (math.exp(a) + 1.0) else: tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.0005) tmp = Float64(exp(a) / Float64(exp(a) + 1.0)); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.0005) tmp = exp(a) / (exp(a) + 1.0); else tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.0005], N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.16666666666666666 * a), $MachinePrecision] - -0.5), $MachinePrecision] * a), $MachinePrecision] - -1.0), $MachinePrecision] * a), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(0.16666666666666666 * a), $MachinePrecision] + 0.5), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.0005:\\
\;\;\;\;\frac{e^{a}}{e^{a} + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(0.16666666666666666 \cdot a - -0.5\right) \cdot a - -1\right) \cdot a - -1}{\left(\left(\left(0.16666666666666666 \cdot a + 0.5\right) \cdot a + 1\right) \cdot a + 1\right) + e^{b}}\\
\end{array}
\end{array}
if a < -5.0000000000000001e-4Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
if -5.0000000000000001e-4 < a Initial program 98.3%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
Applied rewrites97.9%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f6499.5
Applied rewrites99.5%
(FPCore (a b) :precision binary64 (if (<= (/ (exp a) (+ (exp a) (exp b))) 0.0) (/ 1.0 (+ (+ (* (* (* b b) 0.16666666666666666) b) 1.0) 1.0)) (+ 0.5 (* 0.25 a))))
double code(double a, double b) {
double tmp;
if ((exp(a) / (exp(a) + exp(b))) <= 0.0) {
tmp = 1.0 / (((((b * b) * 0.16666666666666666) * b) + 1.0) + 1.0);
} else {
tmp = 0.5 + (0.25 * a);
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((exp(a) / (exp(a) + exp(b))) <= 0.0d0) then
tmp = 1.0d0 / (((((b * b) * 0.16666666666666666d0) * b) + 1.0d0) + 1.0d0)
else
tmp = 0.5d0 + (0.25d0 * a)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((Math.exp(a) / (Math.exp(a) + Math.exp(b))) <= 0.0) {
tmp = 1.0 / (((((b * b) * 0.16666666666666666) * b) + 1.0) + 1.0);
} else {
tmp = 0.5 + (0.25 * a);
}
return tmp;
}
def code(a, b): tmp = 0 if (math.exp(a) / (math.exp(a) + math.exp(b))) <= 0.0: tmp = 1.0 / (((((b * b) * 0.16666666666666666) * b) + 1.0) + 1.0) else: tmp = 0.5 + (0.25 * a) return tmp
function code(a, b) tmp = 0.0 if (Float64(exp(a) / Float64(exp(a) + exp(b))) <= 0.0) tmp = Float64(1.0 / Float64(Float64(Float64(Float64(Float64(b * b) * 0.16666666666666666) * b) + 1.0) + 1.0)); else tmp = Float64(0.5 + Float64(0.25 * a)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((exp(a) / (exp(a) + exp(b))) <= 0.0) tmp = 1.0 / (((((b * b) * 0.16666666666666666) * b) + 1.0) + 1.0); else tmp = 0.5 + (0.25 * a); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[(N[(N[(N[(b * b), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] * b), $MachinePrecision] + 1.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(0.5 + N[(0.25 * a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{e^{a}}{e^{a} + e^{b}} \leq 0:\\
\;\;\;\;\frac{1}{\left(\left(\left(b \cdot b\right) \cdot 0.16666666666666666\right) \cdot b + 1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;0.5 + 0.25 \cdot a\\
\end{array}
\end{array}
if (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) < 0.0Initial program 100.0%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f641.2
Applied rewrites1.2%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f642.5
Applied rewrites2.5%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f642.5
Applied rewrites2.5%
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f6438.0
Applied rewrites38.0%
if 0.0 < (/.f64 (exp.f64 a) (+.f64 (exp.f64 a) (exp.f64 b))) Initial program 97.7%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites64.6%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6464.0
Applied rewrites64.0%
Taylor expanded in b around 0
Applied rewrites66.7%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (exp b))))
double code(double a, double b) {
return exp(a) / (exp(a) + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / (exp(a) + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + Math.exp(b));
}
def code(a, b): return math.exp(a) / (math.exp(a) + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{e^{a} + e^{b}}
\end{array}
Initial program 98.8%
(FPCore (a b) :precision binary64 (/ (exp a) (+ (- (exp b) -1.0) (* (- (* 0.5 a) -1.0) a))))
double code(double a, double b) {
return exp(a) / ((exp(b) - -1.0) + (((0.5 * a) - -1.0) * a));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp(a) / ((exp(b) - (-1.0d0)) + (((0.5d0 * a) - (-1.0d0)) * a))
end function
public static double code(double a, double b) {
return Math.exp(a) / ((Math.exp(b) - -1.0) + (((0.5 * a) - -1.0) * a));
}
def code(a, b): return math.exp(a) / ((math.exp(b) - -1.0) + (((0.5 * a) - -1.0) * a))
function code(a, b) return Float64(exp(a) / Float64(Float64(exp(b) - -1.0) + Float64(Float64(Float64(0.5 * a) - -1.0) * a))) end
function tmp = code(a, b) tmp = exp(a) / ((exp(b) - -1.0) + (((0.5 * a) - -1.0) * a)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[(N[Exp[b], $MachinePrecision] - -1.0), $MachinePrecision] + N[(N[(N[(0.5 * a), $MachinePrecision] - -1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{e^{a}}{\left(e^{b} - -1\right) + \left(0.5 \cdot a - -1\right) \cdot a}
\end{array}
Initial program 98.8%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6498.3
Applied rewrites98.3%
(FPCore (a b) :precision binary64 (if (<= (exp b) 0.99999998) (ratio-square-sum 1.0 (exp b)) (/ 1.0 (+ (* (+ (* (+ (* 0.16666666666666666 b) 0.5) b) 1.0) b) 2.0))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 0.99999998:\\
\;\;\;\;\mathsf{ratio\_square\_sum}\left(1, \left(e^{b}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(0.16666666666666666 \cdot b + 0.5\right) \cdot b + 1\right) \cdot b + 2}\\
\end{array}
\end{array}
if (exp.f64 b) < 0.999999980000000011Initial program 98.0%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
if 0.999999980000000011 < (exp.f64 b) Initial program 99.0%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f6439.5
Applied rewrites39.5%
lift-exp.f64N/A
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f64N/A
lift-exp.f6475.4
Applied rewrites75.4%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f6461.1
Applied rewrites61.1%
(FPCore (a b)
:precision binary64
(if (<= a -720.0)
(/ (exp a) (+ 1.0 1.0))
(/
(- (* (- (* (- (* 0.16666666666666666 a) -0.5) a) -1.0) a) -1.0)
(+
(+ (* (+ (* (+ (* 0.16666666666666666 a) 0.5) a) 1.0) a) 1.0)
(exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -720.0) {
tmp = exp(a) / (1.0 + 1.0);
} else {
tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-720.0d0)) then
tmp = exp(a) / (1.0d0 + 1.0d0)
else
tmp = ((((((0.16666666666666666d0 * a) - (-0.5d0)) * a) - (-1.0d0)) * a) - (-1.0d0)) / (((((((0.16666666666666666d0 * a) + 0.5d0) * a) + 1.0d0) * a) + 1.0d0) + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -720.0) {
tmp = Math.exp(a) / (1.0 + 1.0);
} else {
tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -720.0: tmp = math.exp(a) / (1.0 + 1.0) else: tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -720.0) tmp = Float64(exp(a) / Float64(1.0 + 1.0)); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / Float64(Float64(Float64(Float64(Float64(Float64(Float64(0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -720.0) tmp = exp(a) / (1.0 + 1.0); else tmp = ((((((0.16666666666666666 * a) - -0.5) * a) - -1.0) * a) - -1.0) / (((((((0.16666666666666666 * a) + 0.5) * a) + 1.0) * a) + 1.0) + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -720.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(N[(0.16666666666666666 * a), $MachinePrecision] - -0.5), $MachinePrecision] * a), $MachinePrecision] - -1.0), $MachinePrecision] * a), $MachinePrecision] - -1.0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(N[(0.16666666666666666 * a), $MachinePrecision] + 0.5), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -720:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(0.16666666666666666 \cdot a - -0.5\right) \cdot a - -1\right) \cdot a - -1}{\left(\left(\left(0.16666666666666666 \cdot a + 0.5\right) \cdot a + 1\right) \cdot a + 1\right) + e^{b}}\\
\end{array}
\end{array}
if a < -720Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -720 < a Initial program 98.3%
Taylor expanded in a around 0
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
Applied rewrites97.8%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f6499.5
Applied rewrites99.5%
(FPCore (a b)
:precision binary64
(if (<= a -1900.0)
(/ (exp a) (+ 1.0 1.0))
(/
(+ (* (+ (* 0.5 a) 1.0) a) 1.0)
(+ (- (exp b) -1.0) (* (- (* 0.5 a) -1.0) a)))))
double code(double a, double b) {
double tmp;
if (a <= -1900.0) {
tmp = exp(a) / (1.0 + 1.0);
} else {
tmp = ((((0.5 * a) + 1.0) * a) + 1.0) / ((exp(b) - -1.0) + (((0.5 * a) - -1.0) * a));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-1900.0d0)) then
tmp = exp(a) / (1.0d0 + 1.0d0)
else
tmp = ((((0.5d0 * a) + 1.0d0) * a) + 1.0d0) / ((exp(b) - (-1.0d0)) + (((0.5d0 * a) - (-1.0d0)) * a))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -1900.0) {
tmp = Math.exp(a) / (1.0 + 1.0);
} else {
tmp = ((((0.5 * a) + 1.0) * a) + 1.0) / ((Math.exp(b) - -1.0) + (((0.5 * a) - -1.0) * a));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -1900.0: tmp = math.exp(a) / (1.0 + 1.0) else: tmp = ((((0.5 * a) + 1.0) * a) + 1.0) / ((math.exp(b) - -1.0) + (((0.5 * a) - -1.0) * a)) return tmp
function code(a, b) tmp = 0.0 if (a <= -1900.0) tmp = Float64(exp(a) / Float64(1.0 + 1.0)); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 * a) + 1.0) * a) + 1.0) / Float64(Float64(exp(b) - -1.0) + Float64(Float64(Float64(0.5 * a) - -1.0) * a))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -1900.0) tmp = exp(a) / (1.0 + 1.0); else tmp = ((((0.5 * a) + 1.0) * a) + 1.0) / ((exp(b) - -1.0) + (((0.5 * a) - -1.0) * a)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -1900.0], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(0.5 * a), $MachinePrecision] + 1.0), $MachinePrecision] * a), $MachinePrecision] + 1.0), $MachinePrecision] / N[(N[(N[Exp[b], $MachinePrecision] - -1.0), $MachinePrecision] + N[(N[(N[(0.5 * a), $MachinePrecision] - -1.0), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1900:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(0.5 \cdot a + 1\right) \cdot a + 1}{\left(e^{b} - -1\right) + \left(0.5 \cdot a - -1\right) \cdot a}\\
\end{array}
\end{array}
if a < -1900Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites100.0%
if -1900 < a Initial program 98.3%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6497.7
Applied rewrites97.7%
Taylor expanded in a around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
(FPCore (a b) :precision binary64 (if (<= (exp b) 1.02) (+ 0.5 (* 0.25 a)) (* (* (/ a b) 0.25) b)))
double code(double a, double b) {
double tmp;
if (exp(b) <= 1.02) {
tmp = 0.5 + (0.25 * a);
} else {
tmp = ((a / b) * 0.25) * b;
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (exp(b) <= 1.02d0) then
tmp = 0.5d0 + (0.25d0 * a)
else
tmp = ((a / b) * 0.25d0) * b
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (Math.exp(b) <= 1.02) {
tmp = 0.5 + (0.25 * a);
} else {
tmp = ((a / b) * 0.25) * b;
}
return tmp;
}
def code(a, b): tmp = 0 if math.exp(b) <= 1.02: tmp = 0.5 + (0.25 * a) else: tmp = ((a / b) * 0.25) * b return tmp
function code(a, b) tmp = 0.0 if (exp(b) <= 1.02) tmp = Float64(0.5 + Float64(0.25 * a)); else tmp = Float64(Float64(Float64(a / b) * 0.25) * b); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (exp(b) <= 1.02) tmp = 0.5 + (0.25 * a); else tmp = ((a / b) * 0.25) * b; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[Exp[b], $MachinePrecision], 1.02], N[(0.5 + N[(0.25 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(a / b), $MachinePrecision] * 0.25), $MachinePrecision] * b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{b} \leq 1.02:\\
\;\;\;\;0.5 + 0.25 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{a}{b} \cdot 0.25\right) \cdot b\\
\end{array}
\end{array}
if (exp.f64 b) < 1.02Initial program 98.3%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites73.6%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6448.3
Applied rewrites48.3%
Taylor expanded in b around 0
Applied rewrites50.3%
if 1.02 < (exp.f64 b) Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites34.9%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f642.2
Applied rewrites2.2%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f642.2
Applied rewrites2.2%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6430.6
Applied rewrites30.6%
(FPCore (a b) :precision binary64 (if (<= a -0.000118) (/ (exp a) (+ 1.0 1.0)) (/ 1.0 (+ 1.0 (exp b)))))
double code(double a, double b) {
double tmp;
if (a <= -0.000118) {
tmp = exp(a) / (1.0 + 1.0);
} else {
tmp = 1.0 / (1.0 + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= (-0.000118d0)) then
tmp = exp(a) / (1.0d0 + 1.0d0)
else
tmp = 1.0d0 / (1.0d0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -0.000118) {
tmp = Math.exp(a) / (1.0 + 1.0);
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -0.000118: tmp = math.exp(a) / (1.0 + 1.0) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -0.000118) tmp = Float64(exp(a) / Float64(1.0 + 1.0)); else tmp = Float64(1.0 / Float64(1.0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -0.000118) tmp = exp(a) / (1.0 + 1.0); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -0.000118], N[(N[Exp[a], $MachinePrecision] / N[(1.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -0.000118:\\
\;\;\;\;\frac{e^{a}}{1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
\end{array}
if a < -1.18e-4Initial program 100.0%
Taylor expanded in b around 0
Applied rewrites100.0%
Taylor expanded in a around 0
Applied rewrites98.3%
if -1.18e-4 < a Initial program 98.3%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f6470.6
Applied rewrites70.6%
lift-exp.f64N/A
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f64N/A
lift-exp.f6497.9
Applied rewrites97.9%
(FPCore (a b) :precision binary64 (/ 1.0 (+ 1.0 (exp b))))
double code(double a, double b) {
return 1.0 / (1.0 + exp(b));
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 1.0d0 / (1.0d0 + exp(b))
end function
public static double code(double a, double b) {
return 1.0 / (1.0 + Math.exp(b));
}
def code(a, b): return 1.0 / (1.0 + math.exp(b))
function code(a, b) return Float64(1.0 / Float64(1.0 + exp(b))) end
function tmp = code(a, b) tmp = 1.0 / (1.0 + exp(b)); end
code[a_, b_] := N[(1.0 / N[(1.0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + e^{b}}
\end{array}
Initial program 98.8%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f6451.3
Applied rewrites51.3%
lift-exp.f64N/A
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f64N/A
lift-exp.f6480.2
Applied rewrites80.2%
(FPCore (a b) :precision binary64 (if (<= b 3.1e-19) (+ 0.5 (* 0.25 a)) (/ 1.0 (+ (* (+ (* (+ (* 0.16666666666666666 b) 0.5) b) 1.0) b) 2.0))))
double code(double a, double b) {
double tmp;
if (b <= 3.1e-19) {
tmp = 0.5 + (0.25 * a);
} else {
tmp = 1.0 / ((((((0.16666666666666666 * b) + 0.5) * b) + 1.0) * b) + 2.0);
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 3.1d-19) then
tmp = 0.5d0 + (0.25d0 * a)
else
tmp = 1.0d0 / ((((((0.16666666666666666d0 * b) + 0.5d0) * b) + 1.0d0) * b) + 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 3.1e-19) {
tmp = 0.5 + (0.25 * a);
} else {
tmp = 1.0 / ((((((0.16666666666666666 * b) + 0.5) * b) + 1.0) * b) + 2.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 3.1e-19: tmp = 0.5 + (0.25 * a) else: tmp = 1.0 / ((((((0.16666666666666666 * b) + 0.5) * b) + 1.0) * b) + 2.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 3.1e-19) tmp = Float64(0.5 + Float64(0.25 * a)); else tmp = Float64(1.0 / Float64(Float64(Float64(Float64(Float64(Float64(0.16666666666666666 * b) + 0.5) * b) + 1.0) * b) + 2.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 3.1e-19) tmp = 0.5 + (0.25 * a); else tmp = 1.0 / ((((((0.16666666666666666 * b) + 0.5) * b) + 1.0) * b) + 2.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 3.1e-19], N[(0.5 + N[(0.25 * a), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(N[(N[(0.16666666666666666 * b), $MachinePrecision] + 0.5), $MachinePrecision] * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 3.1 \cdot 10^{-19}:\\
\;\;\;\;0.5 + 0.25 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(\left(0.16666666666666666 \cdot b + 0.5\right) \cdot b + 1\right) \cdot b + 2}\\
\end{array}
\end{array}
if b < 3.0999999999999999e-19Initial program 98.2%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites72.9%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6446.8
Applied rewrites46.8%
Taylor expanded in b around 0
Applied rewrites49.8%
if 3.0999999999999999e-19 < b Initial program 100.0%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f646.3
Applied rewrites6.3%
lift-exp.f64N/A
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f64N/A
lift-exp.f6498.8
Applied rewrites98.8%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
+-commutativeN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f6461.9
Applied rewrites61.9%
(FPCore (a b)
:precision binary64
(if (<= b 0.028)
(+ 0.5 (* 0.25 a))
(if (<= b 1.9e+150)
(* (* (/ a b) 0.25) b)
(/ 1.0 (+ (* (+ (* 0.5 b) 1.0) b) 2.0)))))
double code(double a, double b) {
double tmp;
if (b <= 0.028) {
tmp = 0.5 + (0.25 * a);
} else if (b <= 1.9e+150) {
tmp = ((a / b) * 0.25) * b;
} else {
tmp = 1.0 / ((((0.5 * b) + 1.0) * b) + 2.0);
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.028d0) then
tmp = 0.5d0 + (0.25d0 * a)
else if (b <= 1.9d+150) then
tmp = ((a / b) * 0.25d0) * b
else
tmp = 1.0d0 / ((((0.5d0 * b) + 1.0d0) * b) + 2.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.028) {
tmp = 0.5 + (0.25 * a);
} else if (b <= 1.9e+150) {
tmp = ((a / b) * 0.25) * b;
} else {
tmp = 1.0 / ((((0.5 * b) + 1.0) * b) + 2.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.028: tmp = 0.5 + (0.25 * a) elif b <= 1.9e+150: tmp = ((a / b) * 0.25) * b else: tmp = 1.0 / ((((0.5 * b) + 1.0) * b) + 2.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.028) tmp = Float64(0.5 + Float64(0.25 * a)); elseif (b <= 1.9e+150) tmp = Float64(Float64(Float64(a / b) * 0.25) * b); else tmp = Float64(1.0 / Float64(Float64(Float64(Float64(0.5 * b) + 1.0) * b) + 2.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.028) tmp = 0.5 + (0.25 * a); elseif (b <= 1.9e+150) tmp = ((a / b) * 0.25) * b; else tmp = 1.0 / ((((0.5 * b) + 1.0) * b) + 2.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.028], N[(0.5 + N[(0.25 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.9e+150], N[(N[(N[(a / b), $MachinePrecision] * 0.25), $MachinePrecision] * b), $MachinePrecision], N[(1.0 / N[(N[(N[(N[(0.5 * b), $MachinePrecision] + 1.0), $MachinePrecision] * b), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.028:\\
\;\;\;\;0.5 + 0.25 \cdot a\\
\mathbf{elif}\;b \leq 1.9 \cdot 10^{+150}:\\
\;\;\;\;\left(\frac{a}{b} \cdot 0.25\right) \cdot b\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(0.5 \cdot b + 1\right) \cdot b + 2}\\
\end{array}
\end{array}
if b < 0.0280000000000000006Initial program 98.3%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites73.6%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6448.3
Applied rewrites48.3%
Taylor expanded in b around 0
Applied rewrites50.3%
if 0.0280000000000000006 < b < 1.89999999999999995e150Initial program 100.0%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites33.6%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f642.6
Applied rewrites2.6%
Taylor expanded in b around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-addN/A
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-*.f642.6
Applied rewrites2.6%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
lower-/.f6422.7
Applied rewrites22.7%
if 1.89999999999999995e150 < b Initial program 100.0%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f640.0
Applied rewrites0.0%
lift-exp.f64N/A
lift-ratio-square-sum.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-+.f64N/A
lift-exp.f64100.0
Applied rewrites100.0%
Taylor expanded in b around 0
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f6497.4
Applied rewrites97.4%
(FPCore (a b) :precision binary64 (+ 0.5 (* 0.25 a)))
double code(double a, double b) {
return 0.5 + (0.25 * a);
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0 + (0.25d0 * a)
end function
public static double code(double a, double b) {
return 0.5 + (0.25 * a);
}
def code(a, b): return 0.5 + (0.25 * a)
function code(a, b) return Float64(0.5 + Float64(0.25 * a)) end
function tmp = code(a, b) tmp = 0.5 + (0.25 * a); end
code[a_, b_] := N[(0.5 + N[(0.25 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 + 0.25 \cdot a
\end{array}
Initial program 98.8%
Taylor expanded in b around 0
lower-+.f64N/A
Applied rewrites62.3%
Taylor expanded in a around 0
associate-+r+N/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6434.8
Applied rewrites34.8%
Taylor expanded in b around 0
Applied rewrites36.4%
(FPCore (a b) :precision binary64 0.5)
double code(double a, double b) {
return 0.5;
}
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(a, b)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: b
code = 0.5d0
end function
public static double code(double a, double b) {
return 0.5;
}
def code(a, b): return 0.5
function code(a, b) return 0.5 end
function tmp = code(a, b) tmp = 0.5; end
code[a_, b_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 98.8%
Taylor expanded in a around 0
metadata-evalN/A
lower-ratio-square-sum.f64N/A
lift-exp.f6451.3
Applied rewrites51.3%
Taylor expanded in b around 0
Applied rewrites36.0%
herbie shell --seed 2025058
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
:alt
(! :herbie-platform default (/ 1 (+ 1 (exp (- b a)))))
(/ (exp a) (+ (exp a) (exp b))))