
(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 10 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 95.3%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6498.4
Applied rewrites98.4%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))))
(if (or (<= t_1 0.99999999999995) (not (<= t_1 9.0)))
(* 0.5 (* (* t t) (* x (* y y))))
x)))
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 tmp;
if ((t_1 <= 0.99999999999995) || !(t_1 <= 9.0)) {
tmp = 0.5 * ((t * t) * (x * (y * y)));
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))))
if ((t_1 <= 0.99999999999995d0) .or. (.not. (t_1 <= 9.0d0))) then
tmp = 0.5d0 * ((t * t) * (x * (y * y)))
else
tmp = x
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 tmp;
if ((t_1 <= 0.99999999999995) || !(t_1 <= 9.0)) {
tmp = 0.5 * ((t * t) * (x * (y * y)));
} else {
tmp = x;
}
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)))) tmp = 0 if (t_1 <= 0.99999999999995) or not (t_1 <= 9.0): tmp = 0.5 * ((t * t) * (x * (y * y))) else: tmp = x 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)))) tmp = 0.0 if ((t_1 <= 0.99999999999995) || !(t_1 <= 9.0)) tmp = Float64(0.5 * Float64(Float64(t * t) * Float64(x * Float64(y * y)))); else tmp = x; 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)))); tmp = 0.0; if ((t_1 <= 0.99999999999995) || ~((t_1 <= 9.0))) tmp = 0.5 * ((t * t) * (x * (y * y))); else tmp = x; 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]}, If[Or[LessEqual[t$95$1, 0.99999999999995], N[Not[LessEqual[t$95$1, 9.0]], $MachinePrecision]], N[(0.5 * N[(N[(t * t), $MachinePrecision] * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\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)}\\
\mathbf{if}\;t\_1 \leq 0.99999999999995 \lor \neg \left(t\_1 \leq 9\right):\\
\;\;\;\;0.5 \cdot \left(\left(t \cdot t\right) \cdot \left(x \cdot \left(y \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\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.99999999999995004 or 9 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) Initial program 96.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites44.4%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites27.8%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6436.4
Applied rewrites36.4%
if 0.99999999999995004 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) < 9Initial program 90.2%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites65.2%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites74.6%
Taylor expanded in y around 0
Applied rewrites84.3%
Final simplification44.1%
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* 0.5 (* (* t t) (* x (* y y))))))
(if (<=
(exp (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))))
0.99999999999995)
t_1
(+ x t_1))))
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = 0.5 * ((t * t) * (x * (y * y)));
double tmp;
if (exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))) <= 0.99999999999995) {
tmp = t_1;
} else {
tmp = x + 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 = 0.5d0 * ((t * t) * (x * (y * y)))
if (exp(((y * (log(z) - t)) + (a * (log((1.0d0 - z)) - b)))) <= 0.99999999999995d0) then
tmp = t_1
else
tmp = x + 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 = 0.5 * ((t * t) * (x * (y * y)));
double tmp;
if (Math.exp(((y * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b)))) <= 0.99999999999995) {
tmp = t_1;
} else {
tmp = x + t_1;
}
return tmp;
}
def code(x, y, z, t, a, b): t_1 = 0.5 * ((t * t) * (x * (y * y))) tmp = 0 if math.exp(((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b)))) <= 0.99999999999995: tmp = t_1 else: tmp = x + t_1 return tmp
function code(x, y, z, t, a, b) t_1 = Float64(0.5 * Float64(Float64(t * t) * Float64(x * Float64(y * y)))) tmp = 0.0 if (exp(Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b)))) <= 0.99999999999995) tmp = t_1; else tmp = Float64(x + t_1); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) t_1 = 0.5 * ((t * t) * (x * (y * y))); tmp = 0.0; if (exp(((y * (log(z) - t)) + (a * (log((1.0 - z)) - b)))) <= 0.99999999999995) tmp = t_1; else tmp = x + t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(0.5 * N[(N[(t * t), $MachinePrecision] * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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.99999999999995], t$95$1, N[(x + t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := 0.5 \cdot \left(\left(t \cdot t\right) \cdot \left(x \cdot \left(y \cdot y\right)\right)\right)\\
\mathbf{if}\;e^{y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right)} \leq 0.99999999999995:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + t\_1\\
\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.99999999999995004Initial program 98.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites33.9%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites2.7%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.1
Applied rewrites30.1%
if 0.99999999999995004 < (exp.f64 (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b)))) Initial program 92.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.4%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites62.7%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6453.5
Applied rewrites53.5%
(FPCore (x y z t a b) :precision binary64 (if (<= (+ (* y (- (log z) t)) (* a (- (log (- 1.0 z)) b))) -5e-14) (* 0.5 (* (* t t) (* x (* y y)))) (+ x (* y (* 0.5 (* (* t t) (* x y)))))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))) <= -5e-14) {
tmp = 0.5 * ((t * t) * (x * (y * y)));
} else {
tmp = x + (y * (0.5 * ((t * t) * (x * y))));
}
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 * (log(z) - t)) + (a * (log((1.0d0 - z)) - b))) <= (-5d-14)) then
tmp = 0.5d0 * ((t * t) * (x * (y * y)))
else
tmp = x + (y * (0.5d0 * ((t * t) * (x * y))))
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 * (Math.log(z) - t)) + (a * (Math.log((1.0 - z)) - b))) <= -5e-14) {
tmp = 0.5 * ((t * t) * (x * (y * y)));
} else {
tmp = x + (y * (0.5 * ((t * t) * (x * y))));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if ((y * (math.log(z) - t)) + (a * (math.log((1.0 - z)) - b))) <= -5e-14: tmp = 0.5 * ((t * t) * (x * (y * y))) else: tmp = x + (y * (0.5 * ((t * t) * (x * y)))) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (Float64(Float64(y * Float64(log(z) - t)) + Float64(a * Float64(log(Float64(1.0 - z)) - b))) <= -5e-14) tmp = Float64(0.5 * Float64(Float64(t * t) * Float64(x * Float64(y * y)))); else tmp = Float64(x + Float64(y * Float64(0.5 * Float64(Float64(t * t) * Float64(x * y))))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (((y * (log(z) - t)) + (a * (log((1.0 - z)) - b))) <= -5e-14) tmp = 0.5 * ((t * t) * (x * (y * y))); else tmp = x + (y * (0.5 * ((t * t) * (x * y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[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], -5e-14], N[(0.5 * N[(N[(t * t), $MachinePrecision] * N[(x * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(0.5 * N[(N[(t * t), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \cdot \left(\log z - t\right) + a \cdot \left(\log \left(1 - z\right) - b\right) \leq -5 \cdot 10^{-14}:\\
\;\;\;\;0.5 \cdot \left(\left(t \cdot t\right) \cdot \left(x \cdot \left(y \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(0.5 \cdot \left(\left(t \cdot t\right) \cdot \left(x \cdot y\right)\right)\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))) < -5.0000000000000002e-14Initial program 98.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites33.9%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites2.7%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6430.1
Applied rewrites30.1%
if -5.0000000000000002e-14 < (+.f64 (*.f64 y (-.f64 (log.f64 z) t)) (*.f64 a (-.f64 (log.f64 (-.f64 #s(literal 1 binary64) z)) b))) Initial program 92.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.4%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites62.7%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6456.7
Applied rewrites56.7%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -840.0) (not (<= y 11.6))) (* x (exp (* (- (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 ((y <= -840.0) || !(y <= 11.6)) {
tmp = x * exp(((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 ((y <= -840.0) || !(y <= 11.6)) tmp = Float64(x * exp(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[Or[LessEqual[y, -840.0], N[Not[LessEqual[y, 11.6]], $MachinePrecision]], N[(x * N[Exp[N[(N[(N[Log[z], $MachinePrecision] - t), $MachinePrecision] * y), $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}\;y \leq -840 \lor \neg \left(y \leq 11.6\right):\\
\;\;\;\;x \cdot e^{\left(\log z - t\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\mathsf{fma}\left(y, -t, a \cdot \left(\left(-z\right) - b\right)\right)}\\
\end{array}
\end{array}
if y < -840 or 11.5999999999999996 < y Initial program 96.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lift-log.f64N/A
lift--.f6493.3
Applied rewrites93.3%
if -840 < y < 11.5999999999999996Initial program 94.2%
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.f6499.3
Applied rewrites99.3%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6499.3
Applied rewrites99.3%
Final simplification96.6%
(FPCore (x y z t a b) :precision binary64 (if (or (<= y -135.0) (not (<= y 11.6))) (* x (pow z y)) (* x (exp (* (- a) b)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if ((y <= -135.0) || !(y <= 11.6)) {
tmp = x * pow(z, y);
} else {
tmp = x * exp((-a * b));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 <= (-135.0d0)) .or. (.not. (y <= 11.6d0))) then
tmp = x * (z ** y)
else
tmp = x * exp((-a * b))
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 <= -135.0) || !(y <= 11.6)) {
tmp = x * Math.pow(z, y);
} else {
tmp = x * Math.exp((-a * b));
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if (y <= -135.0) or not (y <= 11.6): tmp = x * math.pow(z, y) else: tmp = x * math.exp((-a * b)) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if ((y <= -135.0) || !(y <= 11.6)) tmp = Float64(x * (z ^ y)); else tmp = Float64(x * exp(Float64(Float64(-a) * b))); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if ((y <= -135.0) || ~((y <= 11.6))) tmp = x * (z ^ y); else tmp = x * exp((-a * b)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -135.0], N[Not[LessEqual[y, 11.6]], $MachinePrecision]], N[(x * N[Power[z, y], $MachinePrecision]), $MachinePrecision], N[(x * N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -135 \lor \neg \left(y \leq 11.6\right):\\
\;\;\;\;x \cdot {z}^{y}\\
\mathbf{else}:\\
\;\;\;\;x \cdot e^{\left(-a\right) \cdot b}\\
\end{array}
\end{array}
if y < -135 or 11.5999999999999996 < y Initial program 96.6%
Taylor expanded in t around 0
+-commutativeN/A
exp-sumN/A
*-commutativeN/A
pow-to-expN/A
lower-*.f64N/A
lower-pow.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6455.5
Applied rewrites55.5%
Taylor expanded in a around 0
lift-pow.f6465.8
Applied rewrites65.8%
if -135 < y < 11.5999999999999996Initial program 94.2%
Taylor expanded in b around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6473.0
Applied rewrites73.0%
Final simplification69.7%
(FPCore (x y z t a b) :precision binary64 (if (<= y -1.75e-127) (* x (exp (* (- t) y))) (if (<= y 11.6) (* x (exp (* (- a) b))) (* x (pow z y)))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (y <= -1.75e-127) {
tmp = x * exp((-t * y));
} else if (y <= 11.6) {
tmp = x * exp((-a * b));
} else {
tmp = x * pow(z, y);
}
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-127)) then
tmp = x * exp((-t * y))
else if (y <= 11.6d0) then
tmp = x * exp((-a * b))
else
tmp = x * (z ** y)
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-127) {
tmp = x * Math.exp((-t * y));
} else if (y <= 11.6) {
tmp = x * Math.exp((-a * b));
} else {
tmp = x * Math.pow(z, y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if y <= -1.75e-127: tmp = x * math.exp((-t * y)) elif y <= 11.6: tmp = x * math.exp((-a * b)) else: tmp = x * math.pow(z, y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (y <= -1.75e-127) tmp = Float64(x * exp(Float64(Float64(-t) * y))); elseif (y <= 11.6) tmp = Float64(x * exp(Float64(Float64(-a) * b))); else tmp = Float64(x * (z ^ y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (y <= -1.75e-127) tmp = x * exp((-t * y)); elseif (y <= 11.6) tmp = x * exp((-a * b)); else tmp = x * (z ^ y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -1.75e-127], N[(x * N[Exp[N[((-t) * y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 11.6], N[(x * N[Exp[N[((-a) * b), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(x * N[Power[z, y], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{-127}:\\
\;\;\;\;x \cdot e^{\left(-t\right) \cdot y}\\
\mathbf{elif}\;y \leq 11.6:\\
\;\;\;\;x \cdot e^{\left(-a\right) \cdot b}\\
\mathbf{else}:\\
\;\;\;\;x \cdot {z}^{y}\\
\end{array}
\end{array}
if y < -1.74999999999999995e-127Initial program 94.3%
Taylor expanded in t around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6473.3
Applied rewrites73.3%
if -1.74999999999999995e-127 < y < 11.5999999999999996Initial program 94.6%
Taylor expanded in b around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6479.2
Applied rewrites79.2%
if 11.5999999999999996 < y Initial program 98.3%
Taylor expanded in t around 0
+-commutativeN/A
exp-sumN/A
*-commutativeN/A
pow-to-expN/A
lower-*.f64N/A
lower-pow.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6458.9
Applied rewrites58.9%
Taylor expanded in a around 0
lift-pow.f6469.5
Applied rewrites69.5%
(FPCore (x y z t a b) :precision binary64 (* x (exp (fma y (- t) (* a (- (- z) b))))))
double code(double x, double y, double z, double t, double a, double b) {
return x * exp(fma(y, -t, (a * (-z - b))));
}
function code(x, y, z, t, a, b) return Float64(x * exp(fma(y, Float64(-t), Float64(a * Float64(Float64(-z) - b))))) end
code[x_, y_, z_, t_, a_, b_] := N[(x * N[Exp[N[(y * (-t) + N[(a * N[((-z) - b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot e^{\mathsf{fma}\left(y, -t, a \cdot \left(\left(-z\right) - b\right)\right)}
\end{array}
Initial program 95.3%
Taylor expanded in z around 0
mul-1-negN/A
lower-neg.f6498.4
Applied rewrites98.4%
Taylor expanded in t around inf
mul-1-negN/A
lift-neg.f6489.0
Applied rewrites89.0%
lift-+.f64N/A
lift-*.f64N/A
lower-fma.f6490.1
Applied rewrites90.1%
(FPCore (x y z t a b) :precision binary64 (if (<= t -1.85e-107) (+ x (* y (* 0.5 (* (* t t) (* x y))))) (* x (pow z y))))
double code(double x, double y, double z, double t, double a, double b) {
double tmp;
if (t <= -1.85e-107) {
tmp = x + (y * (0.5 * ((t * t) * (x * y))));
} else {
tmp = x * pow(z, y);
}
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 (t <= (-1.85d-107)) then
tmp = x + (y * (0.5d0 * ((t * t) * (x * y))))
else
tmp = x * (z ** y)
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 (t <= -1.85e-107) {
tmp = x + (y * (0.5 * ((t * t) * (x * y))));
} else {
tmp = x * Math.pow(z, y);
}
return tmp;
}
def code(x, y, z, t, a, b): tmp = 0 if t <= -1.85e-107: tmp = x + (y * (0.5 * ((t * t) * (x * y)))) else: tmp = x * math.pow(z, y) return tmp
function code(x, y, z, t, a, b) tmp = 0.0 if (t <= -1.85e-107) tmp = Float64(x + Float64(y * Float64(0.5 * Float64(Float64(t * t) * Float64(x * y))))); else tmp = Float64(x * (z ^ y)); end return tmp end
function tmp_2 = code(x, y, z, t, a, b) tmp = 0.0; if (t <= -1.85e-107) tmp = x + (y * (0.5 * ((t * t) * (x * y)))); else tmp = x * (z ^ y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[t, -1.85e-107], N[(x + N[(y * N[(0.5 * N[(N[(t * t), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[Power[z, y], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.85 \cdot 10^{-107}:\\
\;\;\;\;x + y \cdot \left(0.5 \cdot \left(\left(t \cdot t\right) \cdot \left(x \cdot y\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot {z}^{y}\\
\end{array}
\end{array}
if t < -1.8500000000000001e-107Initial program 94.6%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites43.9%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites35.9%
Taylor expanded in t around inf
lower-*.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6435.1
Applied rewrites35.1%
if -1.8500000000000001e-107 < t Initial program 95.7%
Taylor expanded in t around 0
+-commutativeN/A
exp-sumN/A
*-commutativeN/A
pow-to-expN/A
lower-*.f64N/A
lower-pow.f64N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lift-log.f64N/A
lift--.f64N/A
lift--.f6475.4
Applied rewrites75.4%
Taylor expanded in a around 0
lift-pow.f6461.9
Applied rewrites61.9%
(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 95.3%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites47.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites35.3%
Taylor expanded in y around 0
Applied rewrites17.3%
herbie shell --seed 2025051
(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))))))