
(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]
\frac{e^{a}}{e^{a} + e^{b}}
Herbie found 17 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]
\frac{e^{a}}{e^{a} + e^{b}}
(FPCore (a b) :precision binary64 (/ (exp a) (+ (exp a) (/ 1 (exp (- b))))))
double code(double a, double b) {
return exp(a) / (exp(a) + (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 = exp(a) / (exp(a) + (1.0d0 / exp(-b)))
end function
public static double code(double a, double b) {
return Math.exp(a) / (Math.exp(a) + (1.0 / Math.exp(-b)));
}
def code(a, b): return math.exp(a) / (math.exp(a) + (1.0 / math.exp(-b)))
function code(a, b) return Float64(exp(a) / Float64(exp(a) + Float64(1.0 / exp(Float64(-b))))) end
function tmp = code(a, b) tmp = exp(a) / (exp(a) + (1.0 / exp(-b))); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(N[Exp[a], $MachinePrecision] + N[(1 / N[Exp[(-b)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e^{a}}{e^{a} + \frac{1}{e^{-b}}}
Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
(FPCore (a b) :precision binary64 (/ (exp a) (+ 1 (exp b))))
double code(double a, double b) {
return exp(a) / (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 = exp(a) / (1.0d0 + exp(b))
end function
public static double code(double a, double b) {
return Math.exp(a) / (1.0 + Math.exp(b));
}
def code(a, b): return math.exp(a) / (1.0 + math.exp(b))
function code(a, b) return Float64(exp(a) / Float64(1.0 + exp(b))) end
function tmp = code(a, b) tmp = exp(a) / (1.0 + exp(b)); end
code[a_, b_] := N[(N[Exp[a], $MachinePrecision] / N[(1 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{e^{a}}{1 + e^{b}}
Initial program 99.2%
Taylor expanded in a around 0
lower-+.f64N/A
lower-exp.f6497.7%
Applied rewrites97.7%
(FPCore (a b) :precision binary64 (/ 1 (- (+ (+ (exp b) a) (* (sqrt (* (* a a) (* a a))) 1/2)) -1)))
double code(double a, double b) {
return 1.0 / (((exp(b) + a) + (sqrt(((a * a) * (a * a))) * 0.5)) - -1.0);
}
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 / (((exp(b) + a) + (sqrt(((a * a) * (a * a))) * 0.5d0)) - (-1.0d0))
end function
public static double code(double a, double b) {
return 1.0 / (((Math.exp(b) + a) + (Math.sqrt(((a * a) * (a * a))) * 0.5)) - -1.0);
}
def code(a, b): return 1.0 / (((math.exp(b) + a) + (math.sqrt(((a * a) * (a * a))) * 0.5)) - -1.0)
function code(a, b) return Float64(1.0 / Float64(Float64(Float64(exp(b) + a) + Float64(sqrt(Float64(Float64(a * a) * Float64(a * a))) * 0.5)) - -1.0)) end
function tmp = code(a, b) tmp = 1.0 / (((exp(b) + a) + (sqrt(((a * a) * (a * a))) * 0.5)) - -1.0); end
code[a_, b_] := N[(1 / N[(N[(N[(N[Exp[b], $MachinePrecision] + a), $MachinePrecision] + N[(N[Sqrt[N[(N[(a * a), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision]
\frac{1}{\left(\left(e^{b} + a\right) + \sqrt{\left(a \cdot a\right) \cdot \left(a \cdot a\right)} \cdot \frac{1}{2}\right) - -1}
Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6489.6%
Applied rewrites89.6%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6494.0%
Applied rewrites94.0%
(FPCore (a b)
:precision binary64
(let* ((t_0 (+ 1 (* a (+ 1 (* 1/2 a))))))
(if (<=
a
-70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(/ t_0 (+ t_0 (exp b))))))double code(double a, double b) {
double t_0 = 1.0 + (a * (1.0 + (0.5 * a)));
double tmp;
if (a <= -7e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = t_0 / (t_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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 + (a * (1.0d0 + (0.5d0 * a)))
if (a <= (-7d+103)) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
else
tmp = t_0 / (t_0 + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = 1.0 + (a * (1.0 + (0.5 * a)));
double tmp;
if (a <= -7e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = t_0 / (t_0 + Math.exp(b));
}
return tmp;
}
def code(a, b): t_0 = 1.0 + (a * (1.0 + (0.5 * a))) tmp = 0 if a <= -7e+103: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) else: tmp = t_0 / (t_0 + math.exp(b)) return tmp
function code(a, b) t_0 = Float64(1.0 + Float64(a * Float64(1.0 + Float64(0.5 * a)))) tmp = 0.0 if (a <= -7e+103) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); else tmp = Float64(t_0 / Float64(t_0 + exp(b))); end return tmp end
function tmp_2 = code(a, b) t_0 = 1.0 + (a * (1.0 + (0.5 * a))); tmp = 0.0; if (a <= -7e+103) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); else tmp = t_0 / (t_0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(1 + N[(a * N[(1 + N[(1/2 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / N[(t$95$0 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := 1 + a \cdot \left(1 + \frac{1}{2} \cdot a\right)\\
\mathbf{if}\;a \leq -70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{t\_0 + e^{b}}\\
\end{array}
if a < -7e103Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if -7e103 < a Initial program 99.2%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6477.0%
Applied rewrites77.0%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6477.7%
Applied rewrites77.7%
(FPCore (a b)
:precision binary64
(if (<=
a
-70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(/ (+ 1 a) (+ (+ 1 a) (exp b)))))double code(double a, double b) {
double tmp;
if (a <= -7e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = (1.0 + a) / ((1.0 + a) + 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 <= (-7d+103)) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
else
tmp = (1.0d0 + a) / ((1.0d0 + a) + exp(b))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= -7e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = (1.0 + a) / ((1.0 + a) + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -7e+103: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) else: tmp = (1.0 + a) / ((1.0 + a) + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -7e+103) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); else tmp = Float64(Float64(1.0 + a) / Float64(Float64(1.0 + a) + exp(b))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= -7e+103) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); else tmp = (1.0 + a) / ((1.0 + a) + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1 + a), $MachinePrecision] / N[(N[(1 + a), $MachinePrecision] + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;a \leq -70000000000000000134097256001426811535116858908563440780696246021956552694279212917286530157572622647296:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 + a}{\left(1 + a\right) + e^{b}}\\
\end{array}
if a < -7e103Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if -7e103 < a Initial program 99.2%
Taylor expanded in a around 0
lower-+.f6481.1%
Applied rewrites81.1%
Taylor expanded in a around 0
lower-+.f6482.0%
Applied rewrites82.0%
(FPCore (a b)
:precision binary64
(if (<=
a
-94999999999999992224817350588207255454399766741059799452217921129377556751955301525765481584743122206720)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(/ 1 (+ 1 (exp b)))))double code(double a, double b) {
double tmp;
if (a <= -9.5e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} 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 <= (-9.5d+103)) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
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 <= -9.5e+103) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = 1.0 / (1.0 + Math.exp(b));
}
return tmp;
}
def code(a, b): tmp = 0 if a <= -9.5e+103: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) else: tmp = 1.0 / (1.0 + math.exp(b)) return tmp
function code(a, b) tmp = 0.0 if (a <= -9.5e+103) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); 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 <= -9.5e+103) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); else tmp = 1.0 / (1.0 + exp(b)); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, -94999999999999992224817350588207255454399766741059799452217921129377556751955301525765481584743122206720], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(1 + N[Exp[b], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;a \leq -94999999999999992224817350588207255454399766741059799452217921129377556751955301525765481584743122206720:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + e^{b}}\\
\end{array}
if a < -9.4999999999999992e103Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if -9.4999999999999992e103 < a Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
(FPCore (a b)
:precision binary64
(let* ((t_0 (* (* 1/2 b) b)))
(if (<= b -4436777100798803/158456325028528675187087900672)
(/ 1 (+ 1 (/ 1 (+ 1 (* b (- (* b (+ 1/2 (* -1/6 b))) 1))))))
(if (<=
b
9599999999999999937557116997815619882469347802379932726602603143008612253696)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(if (<=
b
13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160)
(/ 1 (+ 2 (/ (- (* b b) (* t_0 t_0)) (- b t_0))))
(/ 1 (+ 2 (* b (+ 1 (* 1/2 b))))))))))double code(double a, double b) {
double t_0 = (0.5 * b) * b;
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0)))));
} else if (b <= 9.6e+75) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else if (b <= 1.35e+154) {
tmp = 1.0 / (2.0 + (((b * b) - (t_0 * t_0)) / (b - t_0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * 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) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * b) * b
if (b <= (-2.8d-14)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * (0.5d0 + ((-0.16666666666666666d0) * b))) - 1.0d0)))))
else if (b <= 9.6d+75) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
else if (b <= 1.35d+154) then
tmp = 1.0d0 / (2.0d0 + (((b * b) - (t_0 * t_0)) / (b - t_0)))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double t_0 = (0.5 * b) * b;
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0)))));
} else if (b <= 9.6e+75) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else if (b <= 1.35e+154) {
tmp = 1.0 / (2.0 + (((b * b) - (t_0 * t_0)) / (b - t_0)));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b))));
}
return tmp;
}
def code(a, b): t_0 = (0.5 * b) * b tmp = 0 if b <= -2.8e-14: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0))))) elif b <= 9.6e+75: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) elif b <= 1.35e+154: tmp = 1.0 / (2.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))) return tmp
function code(a, b) t_0 = Float64(Float64(0.5 * b) * b) tmp = 0.0 if (b <= -2.8e-14) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * Float64(0.5 + Float64(-0.16666666666666666 * b))) - 1.0)))))); elseif (b <= 9.6e+75) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); elseif (b <= 1.35e+154) tmp = Float64(1.0 / Float64(2.0 + Float64(Float64(Float64(b * b) - Float64(t_0 * t_0)) / Float64(b - t_0)))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) t_0 = (0.5 * b) * b; tmp = 0.0; if (b <= -2.8e-14) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0))))); elseif (b <= 9.6e+75) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); elseif (b <= 1.35e+154) tmp = 1.0 / (2.0 + (((b * b) - (t_0 * t_0)) / (b - t_0))); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := Block[{t$95$0 = N[(N[(1/2 * b), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[b, -4436777100798803/158456325028528675187087900672], N[(1 / N[(1 + N[(1 / N[(1 + N[(b * N[(N[(b * N[(1/2 + N[(-1/6 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 9599999999999999937557116997815619882469347802379932726602603143008612253696], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160], N[(1 / N[(2 + N[(N[(N[(b * b), $MachinePrecision] - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(b - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(1/2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(\frac{1}{2} \cdot b\right) \cdot b\\
\mathbf{if}\;b \leq \frac{-4436777100798803}{158456325028528675187087900672}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot b\right) - 1\right)}}\\
\mathbf{elif}\;b \leq 9599999999999999937557116997815619882469347802379932726602603143008612253696:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{elif}\;b \leq 13500000000000000275507010685175621526490118987092636456657125042259125821644957267949903389666459196246900088209596760608108317076954234449082739494748160:\\
\;\;\;\;\frac{1}{2 + \frac{b \cdot b - t\_0 \cdot t\_0}{b - t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{2} \cdot b\right)}\\
\end{array}
if b < -2.8000000000000001e-14Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6454.9%
Applied rewrites54.9%
if -2.8000000000000001e-14 < b < 9.5999999999999999e75Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if 9.5999999999999999e75 < b < 1.35e154Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
flip-+N/A
*-commutativeN/A
*-commutativeN/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
*-lft-identityN/A
*-lft-identityN/A
lower-unsound-*.f64N/A
lower-unsound-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
*-rgt-identityN/A
*-commutativeN/A
lower-unsound--.f64N/A
lower-*.f6443.1%
Applied rewrites43.1%
if 1.35e154 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (a b)
:precision binary64
(if (<= b -4436777100798803/158456325028528675187087900672)
(/ 1 (+ 1 (/ 1 (+ 1 (* b (- (* b (+ 1/2 (* -1/6 b))) 1))))))
(if (<=
b
2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(/ 1 (+ 2 (* b (+ 1 (* b (+ 1/2 (* 1/6 b))))))))))double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0)))));
} else if (b <= 2.9e+99) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * 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 (b <= (-2.8d-14)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + (b * ((b * (0.5d0 + ((-0.16666666666666666d0) * b))) - 1.0d0)))))
else if (b <= 2.9d+99) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0)))));
} else if (b <= 2.9e+99) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -2.8e-14: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0))))) elif b <= 2.9e+99: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -2.8e-14) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(b * Float64(Float64(b * Float64(0.5 + Float64(-0.16666666666666666 * b))) - 1.0)))))); elseif (b <= 2.9e+99) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -2.8e-14) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (b * ((b * (0.5 + (-0.16666666666666666 * b))) - 1.0))))); elseif (b <= 2.9e+99) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -4436777100798803/158456325028528675187087900672], N[(1 / N[(1 + N[(1 / N[(1 + N[(b * N[(N[(b * N[(1/2 + N[(-1/6 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(b * N[(1/2 + N[(1/6 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{-4436777100798803}{158456325028528675187087900672}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + b \cdot \left(b \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot b\right) - 1\right)}}\\
\mathbf{elif}\;b \leq 2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}\\
\end{array}
if b < -2.8000000000000001e-14Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6454.9%
Applied rewrites54.9%
if -2.8000000000000001e-14 < b < 2.9000000000000002e99Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if 2.9000000000000002e99 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6454.6%
Applied rewrites54.6%
(FPCore (a b)
:precision binary64
(if (<= b -4436777100798803/158456325028528675187087900672)
(/ 1 (+ 1 (/ 1 (+ 1 (* -1 b)))))
(if (<=
b
2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216)
(/ 1 (+ 2 (* a (+ 1 (* a (+ 1/2 (* 1/6 a)))))))
(/ 1 (+ 2 (* b (+ 1 (* b (+ 1/2 (* 1/6 b))))))))))double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 2.9e+99) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * 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 (b <= (-2.8d-14)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + ((-1.0d0) * b))))
else if (b <= 2.9d+99) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (a * (0.5d0 + (0.16666666666666666d0 * a))))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 2.9e+99) {
tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a))))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -2.8e-14: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))) elif b <= 2.9e+99: tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -2.8e-14) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(-1.0 * b))))); elseif (b <= 2.9e+99) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(a * Float64(0.5 + Float64(0.16666666666666666 * a))))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -2.8e-14) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))); elseif (b <= 2.9e+99) tmp = 1.0 / (2.0 + (a * (1.0 + (a * (0.5 + (0.16666666666666666 * a)))))); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -4436777100798803/158456325028528675187087900672], N[(1 / N[(1 + N[(1 / N[(1 + N[(-1 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216], N[(1 / N[(2 + N[(a * N[(1 + N[(a * N[(1/2 + N[(1/6 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(b * N[(1/2 + N[(1/6 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{-4436777100798803}{158456325028528675187087900672}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + -1 \cdot b}}\\
\mathbf{elif}\;b \leq 2900000000000000220958584518619378718576206097660833200853200506439430156592527384137291964367241216:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + a \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot a\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}\\
\end{array}
if b < -2.8000000000000001e-14Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f6454.5%
Applied rewrites54.5%
if -2.8000000000000001e-14 < b < 2.9000000000000002e99Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6486.9%
Applied rewrites86.9%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6456.3%
Applied rewrites56.3%
if 2.9000000000000002e99 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6454.6%
Applied rewrites54.6%
(FPCore (a b)
:precision binary64
(if (<= b -3422735716801577/4503599627370496)
(/ 1 (+ 1 (/ 1 (+ 1 (* -1 b)))))
(if (<=
b
319999999999999989553922400211056615127884915412799357224512787796256103101104128)
(/ 1 (- (+ (+ (+ 1 b) a) (* (* a a) 1/2)) -1))
(/ 1 (+ 2 (* b (+ 1 (* b (+ 1/2 (* 1/6 b))))))))))double code(double a, double b) {
double tmp;
if (b <= -0.76) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 3.2e+80) {
tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * 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 (b <= (-0.76d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + ((-1.0d0) * b))))
else if (b <= 3.2d+80) then
tmp = 1.0d0 / ((((1.0d0 + b) + a) + ((a * a) * 0.5d0)) - (-1.0d0))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (b * (0.5d0 + (0.16666666666666666d0 * b))))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -0.76) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 3.2e+80) {
tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b))))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.76: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))) elif b <= 3.2e+80: tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))) return tmp
function code(a, b) tmp = 0.0 if (b <= -0.76) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(-1.0 * b))))); elseif (b <= 3.2e+80) tmp = Float64(1.0 / Float64(Float64(Float64(Float64(1.0 + b) + a) + Float64(Float64(a * a) * 0.5)) - -1.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(b * Float64(0.5 + Float64(0.16666666666666666 * b))))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -0.76) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))); elseif (b <= 3.2e+80) tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (b * (0.5 + (0.16666666666666666 * b)))))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -3422735716801577/4503599627370496], N[(1 / N[(1 + N[(1 / N[(1 + N[(-1 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 319999999999999989553922400211056615127884915412799357224512787796256103101104128], N[(1 / N[(N[(N[(N[(1 + b), $MachinePrecision] + a), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(b * N[(1/2 + N[(1/6 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{-3422735716801577}{4503599627370496}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + -1 \cdot b}}\\
\mathbf{elif}\;b \leq 319999999999999989553922400211056615127884915412799357224512787796256103101104128:\\
\;\;\;\;\frac{1}{\left(\left(\left(1 + b\right) + a\right) + \left(a \cdot a\right) \cdot \frac{1}{2}\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + b \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot b\right)\right)}\\
\end{array}
if b < -0.76000000000000001Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f6454.5%
Applied rewrites54.5%
if -0.76000000000000001 < b < 3.1999999999999999e80Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6489.6%
Applied rewrites89.6%
Taylor expanded in b around 0
lower-+.f6449.8%
Applied rewrites49.8%
if 3.1999999999999999e80 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6454.6%
Applied rewrites54.6%
(FPCore (a b)
:precision binary64
(if (<= b -3422735716801577/4503599627370496)
(/ 1 (+ 1 (/ 1 (+ 1 (* -1 b)))))
(if (<=
b
18999999999999999064581089979963101249120767266604493066770021892695906750618596520567186646577434152905173284039181572611431631767743819258237216708624384)
(/ 1 (- (+ (+ (+ 1 b) a) (* (* a a) 1/2)) -1))
(/ 1 (+ 2 (* b (+ 1 (* 1/2 b))))))))double code(double a, double b) {
double tmp;
if (b <= -0.76) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 1.9e+154) {
tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * 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 (b <= (-0.76d0)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + ((-1.0d0) * b))))
else if (b <= 1.9d+154) then
tmp = 1.0d0 / ((((1.0d0 + b) + a) + ((a * a) * 0.5d0)) - (-1.0d0))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -0.76) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 1.9e+154) {
tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -0.76: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))) elif b <= 1.9e+154: tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -0.76) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(-1.0 * b))))); elseif (b <= 1.9e+154) tmp = Float64(1.0 / Float64(Float64(Float64(Float64(1.0 + b) + a) + Float64(Float64(a * a) * 0.5)) - -1.0)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -0.76) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))); elseif (b <= 1.9e+154) tmp = 1.0 / ((((1.0 + b) + a) + ((a * a) * 0.5)) - -1.0); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -3422735716801577/4503599627370496], N[(1 / N[(1 + N[(1 / N[(1 + N[(-1 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 18999999999999999064581089979963101249120767266604493066770021892695906750618596520567186646577434152905173284039181572611431631767743819258237216708624384], N[(1 / N[(N[(N[(N[(1 + b), $MachinePrecision] + a), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * 1/2), $MachinePrecision]), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(1/2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{-3422735716801577}{4503599627370496}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + -1 \cdot b}}\\
\mathbf{elif}\;b \leq 18999999999999999064581089979963101249120767266604493066770021892695906750618596520567186646577434152905173284039181572611431631767743819258237216708624384:\\
\;\;\;\;\frac{1}{\left(\left(\left(1 + b\right) + a\right) + \left(a \cdot a\right) \cdot \frac{1}{2}\right) - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{2} \cdot b\right)}\\
\end{array}
if b < -0.76000000000000001Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f6454.5%
Applied rewrites54.5%
if -0.76000000000000001 < b < 1.8999999999999999e154Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f6489.6%
Applied rewrites89.6%
Taylor expanded in b around 0
lower-+.f6449.8%
Applied rewrites49.8%
if 1.8999999999999999e154 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (a b)
:precision binary64
(if (<= b -4436777100798803/158456325028528675187087900672)
(/ 1 (+ 1 (/ 1 (+ 1 (* -1 b)))))
(if (<=
b
2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784)
(/ 1 (+ 2 (* a (+ 1 (* 1/2 a)))))
(/ 1 (+ 2 (* b (+ 1 (* 1/2 b))))))))double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 2.8e+156) {
tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * 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 (b <= (-2.8d-14)) then
tmp = 1.0d0 / (1.0d0 + (1.0d0 / (1.0d0 + ((-1.0d0) * b))))
else if (b <= 2.8d+156) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (0.5d0 * a))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= -2.8e-14) {
tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b))));
} else if (b <= 2.8e+156) {
tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= -2.8e-14: tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))) elif b <= 2.8e+156: tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a)))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= -2.8e-14) tmp = Float64(1.0 / Float64(1.0 + Float64(1.0 / Float64(1.0 + Float64(-1.0 * b))))); elseif (b <= 2.8e+156) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(0.5 * a))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= -2.8e-14) tmp = 1.0 / (1.0 + (1.0 / (1.0 + (-1.0 * b)))); elseif (b <= 2.8e+156) tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a)))); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, -4436777100798803/158456325028528675187087900672], N[(1 / N[(1 + N[(1 / N[(1 + N[(-1 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784], N[(1 / N[(2 + N[(a * N[(1 + N[(1/2 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(1/2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{-4436777100798803}{158456325028528675187087900672}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + -1 \cdot b}}\\
\mathbf{elif}\;b \leq 2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + \frac{1}{2} \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{2} \cdot b\right)}\\
\end{array}
if b < -2.8000000000000001e-14Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f6454.5%
Applied rewrites54.5%
if -2.8000000000000001e-14 < b < 2.7999999999999999e156Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if 2.7999999999999999e156 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (a b)
:precision binary64
(if (<=
b
2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784)
(/ 1 (+ 2 (* a (+ 1 (* 1/2 a)))))
(/ 1 (+ 2 (* b (+ 1 (* 1/2 b)))))))double code(double a, double b) {
double tmp;
if (b <= 2.8e+156) {
tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * 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 (b <= 2.8d+156) then
tmp = 1.0d0 / (2.0d0 + (a * (1.0d0 + (0.5d0 * a))))
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.8e+156) {
tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a))));
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.8e+156: tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a)))) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.8e+156) tmp = Float64(1.0 / Float64(2.0 + Float64(a * Float64(1.0 + Float64(0.5 * a))))); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.8e+156) tmp = 1.0 / (2.0 + (a * (1.0 + (0.5 * a)))); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784], N[(1 / N[(2 + N[(a * N[(1 + N[(1/2 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(1/2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq 2799999999999999877191140408237791714304266252051693240387236978082789331230448443084335838169194391935053968040682242044884434993644427170305585304288886784:\\
\;\;\;\;\frac{1}{2 + a \cdot \left(1 + \frac{1}{2} \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{2} \cdot b\right)}\\
\end{array}
if b < 2.7999999999999999e156Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6489.6%
Applied rewrites89.6%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6452.1%
Applied rewrites52.1%
if 2.7999999999999999e156 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (a b)
:precision binary64
(if (<=
b
5342339453620755/242833611528216133864932738352939863330300854881517440156476551217363035650651062272)
(/ 1 (+ 2 a))
(/ 1 (+ 2 (* b (+ 1 (* 1/2 b)))))))double code(double a, double b) {
double tmp;
if (b <= 2.2e-68) {
tmp = 1.0 / (2.0 + a);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * 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 (b <= 2.2d-68) then
tmp = 1.0d0 / (2.0d0 + a)
else
tmp = 1.0d0 / (2.0d0 + (b * (1.0d0 + (0.5d0 * b))))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 2.2e-68) {
tmp = 1.0 / (2.0 + a);
} else {
tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b))));
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 2.2e-68: tmp = 1.0 / (2.0 + a) else: tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))) return tmp
function code(a, b) tmp = 0.0 if (b <= 2.2e-68) tmp = Float64(1.0 / Float64(2.0 + a)); else tmp = Float64(1.0 / Float64(2.0 + Float64(b * Float64(1.0 + Float64(0.5 * b))))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 2.2e-68) tmp = 1.0 / (2.0 + a); else tmp = 1.0 / (2.0 + (b * (1.0 + (0.5 * b)))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 5342339453620755/242833611528216133864932738352939863330300854881517440156476551217363035650651062272], N[(1 / N[(2 + a), $MachinePrecision]), $MachinePrecision], N[(1 / N[(2 + N[(b * N[(1 + N[(1/2 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;b \leq \frac{5342339453620755}{242833611528216133864932738352939863330300854881517440156476551217363035650651062272}:\\
\;\;\;\;\frac{1}{2 + a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + b \cdot \left(1 + \frac{1}{2} \cdot b\right)}\\
\end{array}
if b < 2.2e-68Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f6481.1%
Applied rewrites81.1%
Taylor expanded in b around 0
lower-+.f6439.7%
Applied rewrites39.7%
if 2.2e-68 < b Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6450.2%
Applied rewrites50.2%
(FPCore (a b) :precision binary64 (/ 1 (+ 2 a)))
double code(double a, double b) {
return 1.0 / (2.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 = 1.0d0 / (2.0d0 + a)
end function
public static double code(double a, double b) {
return 1.0 / (2.0 + a);
}
def code(a, b): return 1.0 / (2.0 + a)
function code(a, b) return Float64(1.0 / Float64(2.0 + a)) end
function tmp = code(a, b) tmp = 1.0 / (2.0 + a); end
code[a_, b_] := N[(1 / N[(2 + a), $MachinePrecision]), $MachinePrecision]
\frac{1}{2 + a}
Initial program 99.2%
Taylor expanded in a around 0
Applied rewrites80.7%
Taylor expanded in a around 0
Applied rewrites81.5%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-exp.f6481.1%
Applied rewrites81.1%
Taylor expanded in b around 0
lower-+.f6439.7%
Applied rewrites39.7%
(FPCore (a b) :precision binary64 1/2)
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_] := 1/2
\frac{1}{2}
Initial program 99.2%
lift-exp.f64N/A
sinh-+-cosh-revN/A
add-flipN/A
cosh-neg-revN/A
sinh-neg-revN/A
sinh---cosh-revN/A
exp-negN/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6499.2%
Applied rewrites99.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-exp.f64N/A
lower-neg.f6481.5%
Applied rewrites81.5%
Taylor expanded in b around 0
Applied rewrites39.2%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (a b)
:name "Quotient of sum of exps"
:precision binary64
(/ (exp a) (+ (exp a) (exp b))))