
(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 14 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 (+ (* y (- (log z) t)) (* a (- (- z) b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(((y * (log(z) - t)) + (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(((y * (log(z) - t)) + (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(((y * (Math.log(z) - t)) + (a * (-z - b))));
}
def code(x, y, z, t, a, b): return x * math.exp(((y * (math.log(z) - t)) + (a * (-z - b))))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(Float64(-z) - b))))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp(((y * (log(z) - t)) + (a * (-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[((-z) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{y \cdot \left(\log z - t\right) + a \cdot \left(\left(-z\right) - b\right)}
\end{array}
Initial program 96.7%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6499.2
Applied rewrites99.2%
(FPCore (x y z t a b) :precision binary64 (if (<= a 5.8e+201) (* x (exp (fma (- a) b (* (- (log z) t) y)))) (* x (exp (fma y (- t) (* a (- (- z) b)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (a <= 5.8e+201) {
tmp = x * exp(fma(-a, b, ((log(z) - t) * y)));
} else {
tmp = x * exp(fma(y, -t, (a * (-z - b))));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (a <= 5.8e+201) tmp = Float64(x * exp(fma(Float64(-a), b, Float64(Float64(log(z) - t) * y)))); else tmp = Float64(x * exp(fma(y, Float64(-t), Float64(a * Float64(Float64(-z) - b))))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[a, 5.8e+201], N[(x * N[Exp[N[((-a) * b + N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[Exp[N[(y * (-t) + N[(a * N[((-z) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 5.8 \cdot 10^{+201}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-a, b, \left(\log z - t\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(y, -t, a \cdot \left(\left(-z\right) - b\right)\right)}\\
\end{array}
\end{array}
if a < 5.8000000000000003e201Initial program 97.5%
Taylor expanded in z around 0
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6497.3
Applied rewrites97.3%
if 5.8000000000000003e201 < a Initial program 89.2%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6496.7
Applied rewrites96.7%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6492.5
Applied rewrites92.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6495.1
Applied rewrites95.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (exp (* (- (log z) t) y)) x)))
(if (<= y -3.3e+109)
t_1
(if (<= y 4.3e-29) (* x (exp (fma y (- t) (* a (- (- z) b))))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = exp(((log(z) - t) * y)) * x;
double tmp;
if (y <= -3.3e+109) {
tmp = t_1;
} else if (y <= 4.3e-29) {
tmp = x * exp(fma(y, -t, (a * (-z - b))));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(exp(Float64(Float64(log(z) - t) * y)) * x) tmp = 0.0 if (y <= -3.3e+109) tmp = t_1; elseif (y <= 4.3e-29) tmp = Float64(x * exp(fma(y, Float64(-t), Float64(a * Float64(Float64(-z) - b))))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -3.3e+109], t$95$1, If[LessEqual[y, 4.3e-29], N[(x * N[Exp[N[(y * (-t) + N[(a * N[((-z) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{\left(\log z - t\right) \cdot y} \cdot x\\
\mathbf{if}\;y \leq -3.3 \cdot 10^{+109}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-29}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(y, -t, a \cdot \left(\left(-z\right) - b\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -3.2999999999999999e109 or 4.2999999999999998e-29 < y Initial program 97.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--.f6488.7
Applied rewrites88.7%
if -3.2999999999999999e109 < y < 4.2999999999999998e-29Initial program 96.1%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6499.9
Applied rewrites99.9%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6495.5
Applied rewrites95.5%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6495.6
Applied rewrites95.6%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (exp (* (- (log z) t) y)) x)))
(if (<= y -7.6e+18)
t_1
(if (<= y 4.3e-29) (* x (exp (fma (- a) b (* (- t) y)))) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = exp(((log(z) - t) * y)) * x;
double tmp;
if (y <= -7.6e+18) {
tmp = t_1;
} else if (y <= 4.3e-29) {
tmp = x * exp(fma(-a, b, (-t * y)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a, b) t_1 = Float64(exp(Float64(Float64(log(z) - t) * y)) * x) tmp = 0.0 if (y <= -7.6e+18) tmp = t_1; elseif (y <= 4.3e-29) tmp = Float64(x * exp(fma(Float64(-a), b, Float64(Float64(-t) * y)))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -7.6e+18], t$95$1, If[LessEqual[y, 4.3e-29], N[(x * N[Exp[N[((-a) * b + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{\left(\log z - t\right) \cdot y} \cdot x\\
\mathbf{if}\;y \leq -7.6 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{-29}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-a, b, \left(-t\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.6e18 or 4.2999999999999998e-29 < y Initial 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--.f6488.1
Applied rewrites88.1%
if -7.6e18 < y < 4.2999999999999998e-29Initial program 95.9%
Taylor expanded in z around 0
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6495.0
Applied rewrites95.0%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6493.8
Applied rewrites93.8%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.1e+191) (* (pow z y) x) (* x (exp (fma (- a) b (* (- t) y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.1e+191) {
tmp = pow(z, y) * x;
} else {
tmp = x * exp(fma(-a, b, (-t * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.1e+191) tmp = Float64((z ^ y) * x); else tmp = Float64(x * exp(fma(Float64(-a), b, Float64(Float64(-t) * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.1e+191], N[(N[Power[z, y], $MachinePrecision] * x), $MachinePrecision], N[(x * N[Exp[N[((-a) * b + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+191}:\\
\;\;\;\;{z}^{y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-a, b, \left(-t\right) \cdot y\right)}\\
\end{array}
\end{array}
if y < -1.1e191Initial program 97.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--.f6492.5
Applied rewrites92.5%
Taylor expanded in t around 0
lower-pow.f6472.0
Applied rewrites72.0%
if -1.1e191 < y Initial program 96.7%
Taylor expanded in z around 0
associate-*r*N/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6496.3
Applied rewrites96.3%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6484.9
Applied rewrites84.9%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (pow z y) x))) (if (<= y -5.8e+16) t_1 (if (<= y 7.8e+60) (* (exp (* (- a) b)) x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = pow(z, y) * x;
double tmp;
if (y <= -5.8e+16) {
tmp = t_1;
} else if (y <= 7.8e+60) {
tmp = exp((-a * b)) * 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 = (z ** y) * x
if (y <= (-5.8d+16)) then
tmp = t_1
else if (y <= 7.8d+60) then
tmp = exp((-a * b)) * 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.pow(z, y) * x;
double tmp;
if (y <= -5.8e+16) {
tmp = t_1;
} else if (y <= 7.8e+60) {
tmp = Math.exp((-a * b)) * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = math.pow(z, y) * x tmp = 0 if y <= -5.8e+16: tmp = t_1 elif y <= 7.8e+60: tmp = math.exp((-a * b)) * x else: tmp = t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64((z ^ y) * x) tmp = 0.0 if (y <= -5.8e+16) tmp = t_1; elseif (y <= 7.8e+60) tmp = Float64(exp(Float64(Float64(-a) * b)) * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (z ^ y) * x; tmp = 0.0; if (y <= -5.8e+16) tmp = t_1; elseif (y <= 7.8e+60) tmp = exp((-a * b)) * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[Power[z, y], $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[y, -5.8e+16], t$95$1, If[LessEqual[y, 7.8e+60], N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := {z}^{y} \cdot x\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{+60}:\\
\;\;\;\;e^{\left(-a\right) \cdot b} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -5.8e16 or 7.8000000000000006e60 < y 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--.f6489.9
Applied rewrites89.9%
Taylor expanded in t around 0
lower-pow.f6470.5
Applied rewrites70.5%
if -5.8e16 < y < 7.8000000000000006e60Initial program 95.9%
Taylor expanded in b around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6475.3
Applied rewrites75.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.3
Applied rewrites75.3%
(FPCore (x y z t a b) :precision binary64 (let* ((t_1 (* (exp (* (- a) b)) x))) (if (<= a -6.6e-11) t_1 (if (<= a 9.5e+66) (* (exp (* (- 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 (a <= -6.6e-11) {
tmp = t_1;
} else if (a <= 9.5e+66) {
tmp = exp((-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 (a <= (-6.6d-11)) then
tmp = t_1
else if (a <= 9.5d+66) then
tmp = exp((-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 (a <= -6.6e-11) {
tmp = t_1;
} else if (a <= 9.5e+66) {
tmp = Math.exp((-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 a <= -6.6e-11: tmp = t_1 elif a <= 9.5e+66: tmp = math.exp((-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 (a <= -6.6e-11) tmp = t_1; elseif (a <= 9.5e+66) tmp = Float64(exp(Float64(Float64(-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 (a <= -6.6e-11) tmp = t_1; elseif (a <= 9.5e+66) tmp = exp((-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[a, -6.6e-11], t$95$1, If[LessEqual[a, 9.5e+66], N[(N[Exp[N[((-t) * 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}\;a \leq -6.6 \cdot 10^{-11}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{+66}:\\
\;\;\;\;e^{\left(-t\right) \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -6.6000000000000005e-11 or 9.50000000000000051e66 < a Initial program 93.1%
Taylor expanded in b around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6469.3
Applied rewrites69.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.3
Applied rewrites69.3%
if -6.6000000000000005e-11 < a < 9.50000000000000051e66Initial program 99.9%
Taylor expanded in t around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6468.6
Applied rewrites68.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6468.6
Applied rewrites68.6%
(FPCore (x y z t a b) :precision binary64 (if (<= y -3.6e+150) (* (* (log z) y) x) (* (exp (* (- a) b)) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -3.6e+150) {
tmp = (log(z) * 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 (y <= (-3.6d+150)) then
tmp = (log(z) * 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 (y <= -3.6e+150) {
tmp = (Math.log(z) * y) * x;
} else {
tmp = Math.exp((-a * b)) * x;
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -3.6e+150: tmp = (math.log(z) * y) * x else: tmp = math.exp((-a * b)) * x return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -3.6e+150) tmp = Float64(Float64(log(z) * 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 (y <= -3.6e+150) tmp = (log(z) * y) * x; else tmp = exp((-a * b)) * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -3.6e+150], N[(N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision] * x), $MachinePrecision], N[(N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+150}:\\
\;\;\;\;\left(\log z \cdot y\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-a\right) \cdot b} \cdot x\\
\end{array}
\end{array}
if y < -3.59999999999999986e150Initial program 97.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--.f6492.3
Applied rewrites92.3%
Taylor expanded in t around 0
lower-pow.f6471.5
Applied rewrites71.5%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f64N/A
lift-log.f6429.9
Applied rewrites29.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f6429.9
Applied rewrites29.9%
if -3.59999999999999986e150 < y Initial program 96.6%
Taylor expanded in b around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6461.5
Applied rewrites61.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6461.5
Applied rewrites61.5%
(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))) -1.0)
(* (- t) (* y x))
(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))) <= -1.0) {
tmp = -t * (y * x);
} 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))) <= -1.0) tmp = Float64(Float64(-t) * Float64(y * x)); 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], -1.0], N[((-t) * N[(y * x), $MachinePrecision]), $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 -1:\\
\;\;\;\;\left(-t\right) \cdot \left(y \cdot x\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))) < -1Initial program 98.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--.f6467.3
Applied rewrites67.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-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
if -1 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial 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--.f6475.6
Applied rewrites75.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.6
Applied rewrites47.6%
(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 -1.0)
(* (- t) (* y x))
(if (<= t_2 2e+128) (fma (* (- t) y) x 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 <= -1.0) {
tmp = -t * (y * x);
} else if (t_2 <= 2e+128) {
tmp = fma((-t * y), x, 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 <= -1.0) tmp = Float64(Float64(-t) * Float64(y * x)); elseif (t_2 <= 2e+128) tmp = fma(Float64(Float64(-t) * y), x, 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, -1.0], N[((-t) * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+128], N[(N[((-t) * y), $MachinePrecision] * x + 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 -1:\\
\;\;\;\;\left(-t\right) \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+128}:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\right) \cdot y, x, x\right)\\
\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))) < -1Initial program 98.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--.f6467.3
Applied rewrites67.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-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
if -1 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 2.0000000000000002e128Initial program 93.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--.f6481.7
Applied rewrites81.7%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6459.9
Applied rewrites59.9%
Taylor expanded in t around inf
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f6458.1
Applied rewrites58.1%
if 2.0000000000000002e128 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 97.4%
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.0
Applied rewrites70.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-*.f6436.3
Applied rewrites36.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6435.9
Applied rewrites35.9%
(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 -1000000000000.0)
(* (- t) (* y x))
(if (<= t_1 2e+307) (fma (* (log z) y) x 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 <= -1000000000000.0) {
tmp = -t * (y * x);
} else if (t_1 <= 2e+307) {
tmp = fma((log(z) * y), x, 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 <= -1000000000000.0) tmp = Float64(Float64(-t) * Float64(y * x)); elseif (t_1 <= 2e+307) tmp = fma(Float64(log(z) * y), x, 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, -1000000000000.0], N[((-t) * N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+307], N[(N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision] * x + 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 -1000000000000:\\
\;\;\;\;\left(-t\right) \cdot \left(y \cdot x\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(\log z \cdot y, x, x\right)\\
\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))) < -1e12Initial program 98.4%
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-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6415.9
Applied rewrites15.9%
if -1e12 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) < 1.99999999999999997e307Initial program 96.0%
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.5
Applied rewrites78.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-*.f6446.1
Applied rewrites46.1%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lift-log.f6441.3
Applied rewrites41.3%
if 1.99999999999999997e307 < (+.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--.f6463.1
Applied rewrites63.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift--.f64N/A
lift-*.f6450.8
Applied rewrites50.8%
Taylor expanded in t around inf
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f6449.8
Applied rewrites49.8%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b)))))
(t_2 (* (- t) (* y x))))
(if (<= t_1 0.0) t_2 (if (<= t_1 1.0000002) x t_2))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))));
double t_2 = -t * (y * x);
double tmp;
if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1.0000002) {
tmp = x;
} else {
tmp = t_2;
}
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 = exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
t_2 = -t * (y * x)
if (t_1 <= 0.0d0) then
tmp = t_2
else if (t_1 <= 1.0000002d0) then
tmp = x
else
tmp = t_2
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(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))));
double t_2 = -t * (y * x);
double tmp;
if (t_1 <= 0.0) {
tmp = t_2;
} else if (t_1 <= 1.0000002) {
tmp = x;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b)))) t_2 = -t * (y * x) tmp = 0 if t_1 <= 0.0: tmp = t_2 elif t_1 <= 1.0000002: tmp = x else: tmp = t_2 return tmp
function code(x, y, z, t, a, b) t_1 = exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))) t_2 = Float64(Float64(-t) * Float64(y * x)) tmp = 0.0 if (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1.0000002) tmp = x; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))); t_2 = -t * (y * x); tmp = 0.0; if (t_1 <= 0.0) tmp = t_2; elseif (t_1 <= 1.0000002) tmp = x; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = 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]}, Block[{t$95$2 = N[((-t) * N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 1.0000002], x, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)}\\
t_2 := \left(-t\right) \cdot \left(y \cdot x\right)\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 1.0000002:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) < 0.0 or 1.00000019999999989 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) Initial program 97.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.3
Applied rewrites68.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-*.f6416.9
Applied rewrites16.9%
Taylor expanded in t around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6418.9
Applied rewrites18.9%
if 0.0 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) < 1.00000019999999989Initial program 93.0%
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--.f6491.2
Applied rewrites91.2%
Taylor expanded in y around 0
Applied rewrites89.0%
(FPCore (x y z t a b) :precision binary64 (if (<= (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b)))) 0.4) (* (- t) (* y x)) (fma (* (- t) y) x x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))) <= 0.4) {
tmp = -t * (y * x);
} else {
tmp = fma((-t * y), x, x);
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if (exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))) <= 0.4) tmp = Float64(Float64(-t) * Float64(y * x)); else tmp = fma(Float64(Float64(-t) * y), x, x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[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], 0.4], N[((-t) * N[(y * x), $MachinePrecision]), $MachinePrecision], N[(N[((-t) * y), $MachinePrecision] * x + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \leq 0.4:\\
\;\;\;\;\left(-t\right) \cdot \left(y \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-t\right) \cdot y, x, x\right)\\
\end{array}
\end{array}
if (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) < 0.40000000000000002Initial program 98.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--.f6467.3
Applied rewrites67.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-*.f642.7
Applied rewrites2.7%
Taylor expanded in t around inf
associate-*r*N/A
mul-1-negN/A
lift-neg.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6416.1
Applied rewrites16.1%
if 0.40000000000000002 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) Initial 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--.f6475.6
Applied rewrites75.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.6
Applied rewrites47.6%
Taylor expanded in t around inf
mul-1-negN/A
distribute-lft-neg-outN/A
lift-neg.f64N/A
lift-*.f6443.3
Applied rewrites43.3%
(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.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--.f6472.2
Applied rewrites72.2%
Taylor expanded in y around 0
Applied rewrites18.7%
herbie shell --seed 2025119
(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))))))