
(FPCore (x y z t a b) :precision binary64 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b) :precision binary64 (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}
\end{array}
(FPCore (x y z t a b) :precision binary64 (* x (exp (- (* (- (log z) t) y) (* a (+ z b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp((((log(z) - t) * y) - (a * (z + 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(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x * exp((((log(z) - t) * y) - (a * (z + b))))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp((((Math.log(z) - t) * y) - (a * (z + b))));
}
def code(x, y, z, t, a, b): return x * math.exp((((math.log(z) - t) * y) - (a * (z + b))))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(Float64(log(z) - t) * y) - Float64(a * Float64(z + b))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp((((log(z) - t) * y) - (a * (z + b)))); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] - N[(a * N[(z + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{\left(\log z - t\right) \cdot y - a \cdot \left(z + b\right)}
\end{array}
Initial program 96.6%
Taylor expanded in z around 0
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
associate--l-N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
lower-+.f6499.2
Applied rewrites99.2%
(FPCore (x y z t a b)
:precision binary64
(if (<= b -5e-33)
(* (exp (* (- (log (- 1.0 z)) b) a)) x)
(if (<= b 1.45e+215)
(* (exp (* (- (log z) t) y)) x)
(* (exp (* (- a) b)) x))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -5e-33) {
tmp = exp(((log((1.0 - z)) - b) * a)) * x;
} else if (b <= 1.45e+215) {
tmp = exp(((log(z) - t) * y)) * x;
} else {
tmp = exp((-a * b)) * x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= (-5d-33)) then
tmp = exp(((log((1.0d0 - z)) - b) * a)) * x
else if (b <= 1.45d+215) then
tmp = exp(((log(z) - t) * y)) * x
else
tmp = exp((-a * b)) * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (b <= -5e-33) {
tmp = Math.exp(((Math.log((1.0 - z)) - b) * a)) * x;
} else if (b <= 1.45e+215) {
tmp = Math.exp(((Math.log(z) - t) * y)) * x;
} else {
tmp = Math.exp((-a * b)) * x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if b <= -5e-33: tmp = math.exp(((math.log((1.0 - z)) - b) * a)) * x elif b <= 1.45e+215: tmp = math.exp(((math.log(z) - t) * y)) * x else: tmp = math.exp((-a * b)) * x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (b <= -5e-33) tmp = Float64(exp(Float64(Float64(log(Float64(1.0 - z)) - b) * a)) * x); elseif (b <= 1.45e+215) tmp = Float64(exp(Float64(Float64(log(z) - t) * y)) * x); else tmp = Float64(exp(Float64(Float64(-a) * b)) * x); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (b <= -5e-33) tmp = exp(((log((1.0 - z)) - b) * a)) * x; elseif (b <= 1.45e+215) tmp = exp(((log(z) - t) * y)) * x; else tmp = exp((-a * b)) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -5e-33], N[(N[Exp[N[(N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], If[LessEqual[b, 1.45e+215], N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-33}:\\
\;\;\;\;e^{\left(\log \left(1 - z\right) - b\right) \cdot a} \cdot x\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{+215}:\\
\;\;\;\;e^{\left(\log z - t\right) \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-a\right) \cdot b} \cdot x\\
\end{array}
\end{array}
if b < -5.00000000000000028e-33Initial program 98.8%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6471.3
Applied rewrites71.3%
if -5.00000000000000028e-33 < b < 1.45e215Initial program 95.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6479.2
Applied rewrites79.2%
if 1.45e215 < b Initial program 96.9%
Taylor expanded in b around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6485.6
Applied rewrites85.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6485.6
Applied rewrites85.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (exp (* (- a) b)) x)))
(if (<= b -1.05e-14)
t_1
(if (<= b 1.45e+215) (* (exp (* (- (log z) t) y)) x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = exp((-a * b)) * x;
double tmp;
if (b <= -1.05e-14) {
tmp = t_1;
} else if (b <= 1.45e+215) {
tmp = exp(((log(z) - t) * y)) * x;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = exp((-a * b)) * x
if (b <= (-1.05d-14)) then
tmp = t_1
else if (b <= 1.45d+215) then
tmp = exp(((log(z) - t) * y)) * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = Math.exp((-a * b)) * x;
double tmp;
if (b <= -1.05e-14) {
tmp = t_1;
} else if (b <= 1.45e+215) {
tmp = Math.exp(((Math.log(z) - t) * y)) * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = math.exp((-a * b)) * x tmp = 0 if b <= -1.05e-14: tmp = t_1 elif b <= 1.45e+215: tmp = math.exp(((math.log(z) - t) * y)) * x else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(exp(Float64(Float64(-a) * b)) * x) tmp = 0.0 if (b <= -1.05e-14) tmp = t_1; elseif (b <= 1.45e+215) tmp = Float64(exp(Float64(Float64(log(z) - t) * y)) * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = exp((-a * b)) * x; tmp = 0.0; if (b <= -1.05e-14) tmp = t_1; elseif (b <= 1.45e+215) tmp = exp(((log(z) - t) * y)) * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[b, -1.05e-14], t$95$1, If[LessEqual[b, 1.45e+215], N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{\left(-a\right) \cdot b} \cdot x\\
\mathbf{if}\;b \leq -1.05 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{+215}:\\
\;\;\;\;e^{\left(\log z - t\right) \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -1.0499999999999999e-14 or 1.45e215 < b Initial program 98.4%
Taylor expanded in b around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6474.7
Applied rewrites74.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6474.7
Applied rewrites74.7%
if -1.0499999999999999e-14 < b < 1.45e215Initial program 95.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6478.9
Applied rewrites78.9%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (exp (* (- a) b)) x)))
(if (<= b -4.2e-57)
t_1
(if (<= b 31500000.0) (* (exp (* (- y) t)) x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = exp((-a * b)) * x;
double tmp;
if (b <= -4.2e-57) {
tmp = t_1;
} else if (b <= 31500000.0) {
tmp = exp((-y * t)) * x;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = exp((-a * b)) * x
if (b <= (-4.2d-57)) then
tmp = t_1
else if (b <= 31500000.0d0) then
tmp = exp((-y * t)) * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = Math.exp((-a * b)) * x;
double tmp;
if (b <= -4.2e-57) {
tmp = t_1;
} else if (b <= 31500000.0) {
tmp = Math.exp((-y * t)) * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = math.exp((-a * b)) * x tmp = 0 if b <= -4.2e-57: tmp = t_1 elif b <= 31500000.0: tmp = math.exp((-y * t)) * x else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(exp(Float64(Float64(-a) * b)) * x) tmp = 0.0 if (b <= -4.2e-57) tmp = t_1; elseif (b <= 31500000.0) tmp = Float64(exp(Float64(Float64(-y) * t)) * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = exp((-a * b)) * x; tmp = 0.0; if (b <= -4.2e-57) tmp = t_1; elseif (b <= 31500000.0) tmp = exp((-y * t)) * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[b, -4.2e-57], t$95$1, If[LessEqual[b, 31500000.0], N[(N[Exp[N[((-y) * t), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{\left(-a\right) \cdot b} \cdot x\\
\mathbf{if}\;b \leq -4.2 \cdot 10^{-57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;b \leq 31500000:\\
\;\;\;\;e^{\left(-y\right) \cdot t} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if b < -4.1999999999999999e-57 or 3.15e7 < b Initial program 98.5%
Taylor expanded in b around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6471.6
Applied rewrites71.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.6
Applied rewrites71.6%
if -4.1999999999999999e-57 < b < 3.15e7Initial program 94.3%
Taylor expanded in t around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
lower-*.f64N/A
lower-neg.f6467.4
Applied rewrites67.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6467.4
Applied rewrites67.4%
(FPCore (x y z t a b) :precision binary64 (* (exp (* (- a) b)) x))
double code(double x, double y, double z, double t, double a, double b) {
return exp((-a * b)) * x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = exp((-a * b)) * x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return Math.exp((-a * b)) * x;
}
def code(x, y, z, t, a, b): return math.exp((-a * b)) * x
function code(x, y, z, t, a, b) return Float64(exp(Float64(Float64(-a) * b)) * x) end
function tmp = code(x, y, z, t, a, b) tmp = exp((-a * b)) * x; end
code[x_, y_, z_, t_, a_, b_] := N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
e^{\left(-a\right) \cdot b} \cdot x
\end{array}
Initial program 96.6%
Taylor expanded in b around inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f6458.4
Applied rewrites58.4%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.4
Applied rewrites58.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (log z) t)) (t_2 (+ (* y t_1) (* a (- (log (- 1.0 z)) b)))))
(if (<= t_2 -50000000.0)
(* (* t x) (- y))
(if (<= t_2 0.0005) (fma (* (- t) y) x x) (fma (* t_1 x) y x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = log(z) - t;
double t_2 = (y * t_1) + (a * (log((1.0 - z)) - b));
double tmp;
if (t_2 <= -50000000.0) {
tmp = (t * x) * -y;
} else if (t_2 <= 0.0005) {
tmp = fma((-t * y), x, x);
} else {
tmp = fma((t_1 * x), y, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(log(z) - t) t_2 = Float64(Float64(y * t_1) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) tmp = 0.0 if (t_2 <= -50000000.0) tmp = Float64(Float64(t * x) * Float64(-y)); elseif (t_2 <= 0.0005) tmp = fma(Float64(Float64(-t) * y), x, x); else tmp = fma(Float64(t_1 * x), y, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * t$95$1), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -50000000.0], N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision], If[LessEqual[t$95$2, 0.0005], N[(N[((-t) * y), $MachinePrecision] * x + x), $MachinePrecision], N[(N[(t$95$1 * x), $MachinePrecision] * y + x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log z - t\\
t_2 := y \cdot t\_1 + a \cdot \left(\log \left(1 - z\right) - b\right)\\
\mathbf{if}\;t\_2 \leq -50000000:\\
\;\;\;\;\left(t \cdot x\right) \cdot \left(-y\right)\\
\mathbf{elif}\;t\_2 \leq 0.0005:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\right) \cdot y, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1 \cdot x, y, x\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < -5e7Initial program 98.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6468.4
Applied rewrites68.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6417.7
Applied rewrites17.7%
if -5e7 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 5.0000000000000001e-4Initial program 92.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6490.3
Applied rewrites90.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6487.8
Applied rewrites87.8%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6487.2
Applied rewrites87.2%
if 5.0000000000000001e-4 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 96.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6467.6
Applied rewrites67.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6429.7
Applied rewrites29.7%
lift-fma.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-log.f64N/A
+-commutativeN/A
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
lower-+.f64N/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6429.7
Applied rewrites29.7%
Applied rewrites28.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (log z) t)))
(if (<= (+ (* y t_1) (* a (- (log (- 1.0 z)) b))) -50000000.0)
(* (* t x) (- y))
(fma (* t_1 y) x x))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = log(z) - t;
double tmp;
if (((y * t_1) + (a * (log((1.0 - z)) - b))) <= -50000000.0) {
tmp = (t * x) * -y;
} else {
tmp = fma((t_1 * y), x, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(log(z) - t) tmp = 0.0 if (Float64(Float64(y * t_1) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) <= -50000000.0) tmp = Float64(Float64(t * x) * Float64(-y)); else tmp = fma(Float64(t_1 * y), x, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[N[(N[(y * t$95$1), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -50000000.0], N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision], N[(N[(t$95$1 * y), $MachinePrecision] * x + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log z - t\\
\mathbf{if}\;y \cdot t\_1 + a \cdot \left(\log \left(1 - z\right) - b\right) \leq -50000000:\\
\;\;\;\;\left(t \cdot x\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1 \cdot y, x, x\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < -5e7Initial program 98.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6468.4
Applied rewrites68.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6417.7
Applied rewrites17.7%
if -5e7 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 95.3%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6474.6
Applied rewrites74.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6447.5
Applied rewrites47.5%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (- (log z) t)) (t_2 (+ (* y t_1) (* a (- (log (- 1.0 z)) b)))))
(if (<= t_2 -50000000.0)
(* (* t x) (- y))
(if (<= t_2 2e+256) (* (fma (log z) y 1.0) x) (* (* t_1 y) x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = log(z) - t;
double t_2 = (y * t_1) + (a * (log((1.0 - z)) - b));
double tmp;
if (t_2 <= -50000000.0) {
tmp = (t * x) * -y;
} else if (t_2 <= 2e+256) {
tmp = fma(log(z), y, 1.0) * x;
} else {
tmp = (t_1 * y) * x;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(log(z) - t) t_2 = Float64(Float64(y * t_1) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) tmp = 0.0 if (t_2 <= -50000000.0) tmp = Float64(Float64(t * x) * Float64(-y)); elseif (t_2 <= 2e+256) tmp = Float64(fma(log(z), y, 1.0) * x); else tmp = Float64(Float64(t_1 * y) * x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * t$95$1), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -50000000.0], N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision], If[LessEqual[t$95$2, 2e+256], N[(N[(N[Log[z], $MachinePrecision] * y + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[(t$95$1 * y), $MachinePrecision] * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \log z - t\\
t_2 := y \cdot t\_1 + a \cdot \left(\log \left(1 - z\right) - b\right)\\
\mathbf{if}\;t\_2 \leq -50000000:\\
\;\;\;\;\left(t \cdot x\right) \cdot \left(-y\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\mathsf{fma}\left(\log z, y, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot y\right) \cdot x\\
\end{array}
\end{array}
if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < -5e7Initial program 98.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6468.4
Applied rewrites68.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6417.7
Applied rewrites17.7%
if -5e7 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 2.0000000000000001e256Initial program 95.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6476.2
Applied rewrites76.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6447.4
Applied rewrites47.4%
Taylor expanded in t around 0
lift-log.f6444.0
Applied rewrites44.0%
if 2.0000000000000001e256 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6470.6
Applied rewrites70.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6447.7
Applied rewrites47.7%
Taylor expanded in y around inf
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6447.3
Applied rewrites47.3%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b)))))
(if (<= t_1 -50000000.0)
(* (* t x) (- y))
(if (<= t_1 2e+256) (* (fma (log z) y 1.0) x) (fma (* (- t) y) x x)))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y * (log(z) - t)) + (a * (log((1.0 - z)) - b));
double tmp;
if (t_1 <= -50000000.0) {
tmp = (t * x) * -y;
} else if (t_1 <= 2e+256) {
tmp = fma(log(z), y, 1.0) * x;
} else {
tmp = fma((-t * y), x, x);
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) tmp = 0.0 if (t_1 <= -50000000.0) tmp = Float64(Float64(t * x) * Float64(-y)); elseif (t_1 <= 2e+256) tmp = Float64(fma(log(z), y, 1.0) * x); else tmp = fma(Float64(Float64(-t) * y), x, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000.0], N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision], If[LessEqual[t$95$1, 2e+256], N[(N[(N[Log[z], $MachinePrecision] * y + 1.0), $MachinePrecision] * x), $MachinePrecision], N[(N[((-t) * y), $MachinePrecision] * x + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)\\
\mathbf{if}\;t\_1 \leq -50000000:\\
\;\;\;\;\left(t \cdot x\right) \cdot \left(-y\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+256}:\\
\;\;\;\;\mathsf{fma}\left(\log z, y, 1\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\right) \cdot y, x, x\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < -5e7Initial program 98.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6468.4
Applied rewrites68.4%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6417.7
Applied rewrites17.7%
if -5e7 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 2.0000000000000001e256Initial program 95.1%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6476.2
Applied rewrites76.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f64N/A
lift--.f6447.4
Applied rewrites47.4%
Taylor expanded in t around 0
lift-log.f6444.0
Applied rewrites44.0%
if 2.0000000000000001e256 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 95.9%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6470.6
Applied rewrites70.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6447.7
Applied rewrites47.7%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6443.1
Applied rewrites43.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (* t x) (- y)))
(t_2 (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b)))))
(if (<= t_2 -50000000.0) t_1 (if (<= t_2 5e+55) x t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t * x) * -y;
double t_2 = (y * (log(z) - t)) + (a * (log((1.0 - z)) - b));
double tmp;
if (t_2 <= -50000000.0) {
tmp = t_1;
} else if (t_2 <= 5e+55) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (t * x) * -y
t_2 = (y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))
if (t_2 <= (-50000000.0d0)) then
tmp = t_1
else if (t_2 <= 5d+55) then
tmp = x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (t * x) * -y;
double t_2 = (y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b));
double tmp;
if (t_2 <= -50000000.0) {
tmp = t_1;
} else if (t_2 <= 5e+55) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = (t * x) * -y t_2 = (y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b)) tmp = 0 if t_2 <= -50000000.0: tmp = t_1 elif t_2 <= 5e+55: tmp = x else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(Float64(t * x) * Float64(-y)) t_2 = Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) tmp = 0.0 if (t_2 <= -50000000.0) tmp = t_1; elseif (t_2 <= 5e+55) tmp = x; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (t * x) * -y; t_2 = (y * (log(z) - t)) + (a * (log((1.0 - z)) - b)); tmp = 0.0; if (t_2 <= -50000000.0) tmp = t_1; elseif (t_2 <= 5e+55) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -50000000.0], t$95$1, If[LessEqual[t$95$2, 5e+55], x, t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t \cdot x\right) \cdot \left(-y\right)\\
t_2 := y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)\\
\mathbf{if}\;t\_2 \leq -50000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < -5e7 or 5.00000000000000046e55 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 97.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6468.8
Applied rewrites68.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6416.9
Applied rewrites16.9%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6420.7
Applied rewrites20.7%
if -5e7 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 5.00000000000000046e55Initial program 92.5%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6480.2
Applied rewrites80.2%
Taylor expanded in a around 0
Applied rewrites70.3%
(FPCore (x y z t a b) :precision binary64 (if (<= (* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))) 0.0) (* (* t x) (- y)) (fma (* (- t) y) x x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((x * exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))))) <= 0.0) {
tmp = (t * x) * -y;
} else {
tmp = fma((-t * y), x, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))))) <= 0.0) tmp = Float64(Float64(t * x) * Float64(-y)); else tmp = fma(Float64(Float64(-t) * y), x, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * N[Exp[N[(N[(y * N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[Log[N[(1.0 - z), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(t * x), $MachinePrecision] * (-y)), $MachinePrecision], N[(N[((-t) * y), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \leq 0:\\
\;\;\;\;\left(t \cdot x\right) \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\right) \cdot y, x, x\right)\\
\end{array}
\end{array}
if (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) < 0.0Initial program 97.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6471.0
Applied rewrites71.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6421.2
Applied rewrites21.2%
Taylor expanded in t around inf
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-*.f6417.5
Applied rewrites17.5%
if 0.0 < (*.f64 x (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))))) Initial program 94.3%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6474.5
Applied rewrites74.5%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6448.4
Applied rewrites48.4%
Taylor expanded in t around inf
mul-1-negN/A
lower-neg.f6444.7
Applied rewrites44.7%
(FPCore (x y z t a b) :precision binary64 x)
double code(double x, double y, double z, double t, double a, double b) {
return x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = x
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x;
}
def code(x, y, z, t, a, b): return x
function code(x, y, z, t, a, b) return x end
function tmp = code(x, y, z, t, a, b) tmp = x; end
code[x_, y_, z_, t_, a_, b_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 96.6%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower-exp.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6459.1
Applied rewrites59.1%
Taylor expanded in a around 0
Applied rewrites19.1%
herbie shell --seed 2025130
(FPCore (x y z t a b)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, B"
:precision binary64
(* x (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))