
(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}
Sampling outcomes in binary64 precision:
Herbie found 9 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 (- (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}
Initial program 97.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -400.0) (not (<= t 1e-97))) (* x (exp (fma (- b) a (* (- t) y)))) (* x (exp (fma (- b) a (* (log z) y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -400.0) || !(t <= 1e-97)) {
tmp = x * exp(fma(-b, a, (-t * y)));
} else {
tmp = x * exp(fma(-b, a, (log(z) * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -400.0) || !(t <= 1e-97)) tmp = Float64(x * exp(fma(Float64(-b), a, Float64(Float64(-t) * y)))); else tmp = Float64(x * exp(fma(Float64(-b), a, Float64(log(z) * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -400.0], N[Not[LessEqual[t, 1e-97]], $MachinePrecision]], N[(x * N[Exp[N[((-b) * a + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[Exp[N[((-b) * a + N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -400 \lor \neg \left(t \leq 10^{-97}\right):\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-b, a, \left(-t\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-b, a, \log z \cdot y\right)}\\
\end{array}
\end{array}
if t < -400 or 1.00000000000000004e-97 < t Initial program 97.4%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6496.8
Applied rewrites96.8%
Taylor expanded in t around inf
Applied rewrites96.8%
if -400 < t < 1.00000000000000004e-97Initial program 98.1%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6497.2
Applied rewrites97.2%
Taylor expanded in t around 0
Applied rewrites97.2%
Final simplification97.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -106000000000.0) (not (<= y 3.65e-16))) (* (exp (* (- (log z) t) y)) x) (* x (exp (fma (- b) a (* (- t) y))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -106000000000.0) || !(y <= 3.65e-16)) {
tmp = exp(((log(z) - t) * y)) * x;
} else {
tmp = x * exp(fma(-b, a, (-t * y)));
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -106000000000.0) || !(y <= 3.65e-16)) tmp = Float64(exp(Float64(Float64(log(z) - t) * y)) * x); else tmp = Float64(x * exp(fma(Float64(-b), a, Float64(Float64(-t) * y)))); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -106000000000.0], N[Not[LessEqual[y, 3.65e-16]], $MachinePrecision]], N[(N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision], N[(x * N[Exp[N[((-b) * a + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -106000000000 \lor \neg \left(y \leq 3.65 \cdot 10^{-16}\right):\\
\;\;\;\;e^{\left(\log z - t\right) \cdot y} \cdot x\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-b, a, \left(-t\right) \cdot y\right)}\\
\end{array}
\end{array}
if y < -1.06e11 or 3.6500000000000001e-16 < y Initial program 97.7%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6497.7
Applied rewrites97.7%
Taylor expanded in y around inf
div-subN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
unpow2N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-pow.f64N/A
lower-log.f64N/A
Applied rewrites93.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6493.9
Applied rewrites93.9%
if -1.06e11 < y < 3.6500000000000001e-16Initial program 97.7%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6495.4
Applied rewrites95.4%
Taylor expanded in t around inf
Applied rewrites95.0%
Final simplification94.4%
(FPCore (x y z t a b) :precision binary64 (if (or (<= t -43.0) (not (<= t -3.55e-202))) (* x (exp (fma (- b) a (* (- t) y)))) (* (exp (* (log z) y)) x)))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((t <= -43.0) || !(t <= -3.55e-202)) {
tmp = x * exp(fma(-b, a, (-t * y)));
} else {
tmp = exp((log(z) * y)) * x;
}
return tmp;
}
function code(x, y, z, t, a, b) tmp = 0.0 if ((t <= -43.0) || !(t <= -3.55e-202)) tmp = Float64(x * exp(fma(Float64(-b), a, Float64(Float64(-t) * y)))); else tmp = Float64(exp(Float64(log(z) * y)) * x); end return tmp end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[t, -43.0], N[Not[LessEqual[t, -3.55e-202]], $MachinePrecision]], N[(x * N[Exp[N[((-b) * a + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[z], $MachinePrecision] * y), $MachinePrecision]], $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -43 \lor \neg \left(t \leq -3.55 \cdot 10^{-202}\right):\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(-b, a, \left(-t\right) \cdot y\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\log z \cdot y} \cdot x\\
\end{array}
\end{array}
if t < -43 or -3.55e-202 < t Initial program 98.1%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6497.2
Applied rewrites97.2%
Taylor expanded in t around inf
Applied rewrites92.3%
if -43 < t < -3.55e-202Initial program 95.8%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
flip--N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6495.9
Applied rewrites95.9%
Taylor expanded in y around inf
div-subN/A
associate-/l*N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
unpow2N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unpow2N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
lower-pow.f64N/A
lower-log.f64N/A
Applied rewrites71.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6471.0
Applied rewrites71.0%
Taylor expanded in t around 0
Applied rewrites71.0%
Final simplification88.4%
(FPCore (x y z t a b) :precision binary64 (* x (exp (fma (- b) a (* (- (log z) t) y)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(fma(-b, a, ((log(z) - t) * y)));
}
function code(x, y, z, t, a, b) return Float64(x * exp(fma(Float64(-b), a, Float64(Float64(log(z) - t) * y)))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[((-b) * a + N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{\mathsf{fma}\left(-b, a, \left(\log z - t\right) \cdot y\right)}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6497.0
Applied rewrites97.0%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -1.75e+48) (not (<= y 1.4e-12))) (* x (exp (* (- y) t))) (* x (exp (* (- (- z) b) a)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -1.75e+48) || !(y <= 1.4e-12)) {
tmp = x * exp((-y * t));
} else {
tmp = x * exp(((-z - b) * a));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 <= (-1.75d+48)) .or. (.not. (y <= 1.4d-12))) then
tmp = x * exp((-y * t))
else
tmp = x * exp(((-z - b) * a))
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 <= -1.75e+48) || !(y <= 1.4e-12)) {
tmp = x * Math.exp((-y * t));
} else {
tmp = x * Math.exp(((-z - b) * a));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -1.75e+48) or not (y <= 1.4e-12): tmp = x * math.exp((-y * t)) else: tmp = x * math.exp(((-z - b) * a)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -1.75e+48) || !(y <= 1.4e-12)) tmp = Float64(x * exp(Float64(Float64(-y) * t))); else tmp = Float64(x * exp(Float64(Float64(Float64(-z) - b) * a))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -1.75e+48) || ~((y <= 1.4e-12))) tmp = x * exp((-y * t)); else tmp = x * exp(((-z - b) * a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -1.75e+48], N[Not[LessEqual[y, 1.4e-12]], $MachinePrecision]], N[(x * N[Exp[N[((-y) * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[Exp[N[(N[((-z) - b), $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+48} \lor \neg \left(y \leq 1.4 \cdot 10^{-12}\right):\\
\;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\left(\left(-z\right) - b\right) \cdot a}\\
\end{array}
\end{array}
if y < -1.7499999999999999e48 or 1.4000000000000001e-12 < y Initial program 98.3%
Taylor expanded in t around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6468.9
Applied rewrites68.9%
if -1.7499999999999999e48 < y < 1.4000000000000001e-12Initial program 97.2%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
mul-1-negN/A
lower-log1p.f64N/A
lower-neg.f6482.4
Applied rewrites82.4%
Taylor expanded in z around 0
Applied rewrites82.4%
Final simplification76.3%
(FPCore (x y z t a b) :precision binary64 (if (or (<= b -5.2e-79) (not (<= b 1.2e+145))) (* x (exp (* (- b) a))) (* x (exp (* (- y) t)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((b <= -5.2e-79) || !(b <= 1.2e+145)) {
tmp = x * exp((-b * a));
} else {
tmp = x * exp((-y * t));
}
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 <= (-5.2d-79)) .or. (.not. (b <= 1.2d+145))) then
tmp = x * exp((-b * a))
else
tmp = x * exp((-y * t))
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 <= -5.2e-79) || !(b <= 1.2e+145)) {
tmp = x * Math.exp((-b * a));
} else {
tmp = x * Math.exp((-y * t));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (b <= -5.2e-79) or not (b <= 1.2e+145): tmp = x * math.exp((-b * a)) else: tmp = x * math.exp((-y * t)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((b <= -5.2e-79) || !(b <= 1.2e+145)) tmp = Float64(x * exp(Float64(Float64(-b) * a))); else tmp = Float64(x * exp(Float64(Float64(-y) * t))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((b <= -5.2e-79) || ~((b <= 1.2e+145))) tmp = x * exp((-b * a)); else tmp = x * exp((-y * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[b, -5.2e-79], N[Not[LessEqual[b, 1.2e+145]], $MachinePrecision]], N[(x * N[Exp[N[((-b) * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[Exp[N[((-y) * t), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-79} \lor \neg \left(b \leq 1.2 \cdot 10^{+145}\right):\\
\;\;\;\;x \cdot e^{\left(-b\right) \cdot a}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\left(-y\right) \cdot t}\\
\end{array}
\end{array}
if b < -5.19999999999999987e-79 or 1.19999999999999996e145 < b Initial program 99.1%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
mul-1-negN/A
lower-log1p.f64N/A
lower-neg.f6478.9
Applied rewrites78.9%
Taylor expanded in z around 0
Applied rewrites77.2%
if -5.19999999999999987e-79 < b < 1.19999999999999996e145Initial program 96.5%
Taylor expanded in t around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6472.3
Applied rewrites72.3%
Final simplification74.5%
(FPCore (x y z t a b) :precision binary64 (* x (exp (fma (- b) a (* (- t) y)))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(fma(-b, a, (-t * y)));
}
function code(x, y, z, t, a, b) return Float64(x * exp(fma(Float64(-b), a, Float64(Float64(-t) * y)))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[((-b) * a + N[((-t) * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{\mathsf{fma}\left(-b, a, \left(-t\right) \cdot y\right)}
\end{array}
Initial program 97.7%
Taylor expanded in z around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-log.f6497.0
Applied rewrites97.0%
Taylor expanded in t around inf
Applied rewrites83.8%
(FPCore (x y z t a b) :precision binary64 (* x (exp (* (- b) a))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp((-b * a));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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((-b * a))
end function
public static double code(double x, double y, double z, double t, double a, double b) {
return x * Math.exp((-b * a));
}
def code(x, y, z, t, a, b): return x * math.exp((-b * a))
function code(x, y, z, t, a, b) return Float64(x * exp(Float64(Float64(-b) * a))) end
function tmp = code(x, y, z, t, a, b) tmp = x * exp((-b * a)); end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[((-b) * a), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{\left(-b\right) \cdot a}
\end{array}
Initial program 97.7%
Taylor expanded in y around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-subN/A
mul-1-negN/A
lower-log1p.f64N/A
lower-neg.f6459.9
Applied rewrites59.9%
Taylor expanded in z around 0
Applied rewrites54.7%
herbie shell --seed 2025017
(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))))))