
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c i) :precision binary64 (+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
}
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
}
def code(x, y, z, t, a, b, c, i): return (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i)
function code(x, y, z, t, a, b, c, i) return Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) end
function tmp = code(x, y, z, t, a, b, c, i) tmp = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i); end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i
\end{array}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (fma (- b 0.5) (log c) (+ (fma i y (+ a (fma (log y) x z))) t)))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma((b - 0.5), log(c), (fma(i, y, (a + fma(log(y), x, z))) + t));
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return fma(Float64(b - 0.5), log(c), Float64(fma(i, y, Float64(a + fma(log(y), x, z))) + t)) end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision] + N[(N[(i * y + N[(a + N[(N[Log[y], $MachinePrecision] * x + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\mathsf{fma}\left(b - 0.5, \log c, \mathsf{fma}\left(i, y, a + \mathsf{fma}\left(\log y, x, z\right)\right) + t\right)
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (+ (fma i y (+ (fma (log c) (- b 0.5) (fma (log y) x t)) z)) a))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return fma(i, y, (fma(log(c), (b - 0.5), fma(log(y), x, t)) + z)) + a;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(fma(i, y, Float64(fma(log(c), Float64(b - 0.5), fma(log(y), x, t)) + z)) + a) end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(i * y + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x + t), $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, \mathsf{fma}\left(\log y, x, t\right)\right) + z\right) + a
\end{array}
Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(if (<=
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i))
-1e+21)
(+ t (+ z (fma i y (fma x (log y) (* (log c) (- b 0.5))))))
(+ (fma y i (fma x (log y) (fma (log c) (- b 0.5) t))) a)))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (((((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i)) <= -1e+21) {
tmp = t + (z + fma(i, y, fma(x, log(y), (log(c) * (b - 0.5)))));
} else {
tmp = fma(y, i, fma(x, log(y), fma(log(c), (b - 0.5), t))) + a;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) <= -1e+21) tmp = Float64(t + Float64(z + fma(i, y, fma(x, log(y), Float64(log(c) * Float64(b - 0.5)))))); else tmp = Float64(fma(y, i, fma(x, log(y), fma(log(c), Float64(b - 0.5), t))) + a); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision], -1e+21], N[(t + N[(z + N[(i * y + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * i + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i \leq -1 \cdot 10^{+21}:\\
\;\;\;\;t + \left(z + \mathsf{fma}\left(i, y, \mathsf{fma}\left(x, \log y, \log c \cdot \left(b - 0.5\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, \mathsf{fma}\left(\log c, b - 0.5, t\right)\right)\right) + a\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -1e21Initial program 99.8%
Taylor expanded in a around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.6
Applied rewrites77.6%
if -1e21 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6477.1
Applied rewrites77.1%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (fma (log c) (- b 0.5) t)))
(if (<= z -3.9e+96)
(+ (fma i y (+ t_1 z)) a)
(+ (fma y i (fma x (log y) t_1)) a))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = fma(log(c), (b - 0.5), t);
double tmp;
if (z <= -3.9e+96) {
tmp = fma(i, y, (t_1 + z)) + a;
} else {
tmp = fma(y, i, fma(x, log(y), t_1)) + a;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = fma(log(c), Float64(b - 0.5), t) tmp = 0.0 if (z <= -3.9e+96) tmp = Float64(fma(i, y, Float64(t_1 + z)) + a); else tmp = Float64(fma(y, i, fma(x, log(y), t_1)) + a); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[z, -3.9e+96], N[(N[(i * y + N[(t$95$1 + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(N[(y * i + N[(x * N[Log[y], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\log c, b - 0.5, t\right)\\
\mathbf{if}\;z \leq -3.9 \cdot 10^{+96}:\\
\;\;\;\;\mathsf{fma}\left(i, y, t\_1 + z\right) + a\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, i, \mathsf{fma}\left(x, \log y, t\_1\right)\right) + a\\
\end{array}
\end{array}
if z < -3.9e96Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
if -3.9e96 < z Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6477.1
Applied rewrites77.1%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= z -6e+90) (+ (fma i y (+ (fma (log c) (- b 0.5) t) z)) a) (+ a (fma i y (fma x (log y) (* (log c) (- b 0.5)))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (z <= -6e+90) {
tmp = fma(i, y, (fma(log(c), (b - 0.5), t) + z)) + a;
} else {
tmp = a + fma(i, y, fma(x, log(y), (log(c) * (b - 0.5))));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (z <= -6e+90) tmp = Float64(fma(i, y, Float64(fma(log(c), Float64(b - 0.5), t) + z)) + a); else tmp = Float64(a + fma(i, y, fma(x, log(y), Float64(log(c) * Float64(b - 0.5))))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[z, -6e+90], N[(N[(i * y + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], N[(a + N[(i * y + N[(x * N[Log[y], $MachinePrecision] + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6 \cdot 10^{+90}:\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, t\right) + z\right) + a\\
\mathbf{else}:\\
\;\;\;\;a + \mathsf{fma}\left(i, y, \mathsf{fma}\left(x, \log y, \log c \cdot \left(b - 0.5\right)\right)\right)\\
\end{array}
\end{array}
if z < -5.99999999999999957e90Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
if -5.99999999999999957e90 < z Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6476.6
Applied rewrites76.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ (+ (fma (log c) (- b 0.5) (* (log y) x)) t) a)))
(if (<= x -2.5e+172)
t_1
(if (<= x 3.3e+171)
(+ (fma i y (+ (fma (log c) (- b 0.5) t) z)) a)
t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (fma(log(c), (b - 0.5), (log(y) * x)) + t) + a;
double tmp;
if (x <= -2.5e+172) {
tmp = t_1;
} else if (x <= 3.3e+171) {
tmp = fma(i, y, (fma(log(c), (b - 0.5), t) + z)) + a;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(fma(log(c), Float64(b - 0.5), Float64(log(y) * x)) + t) + a) tmp = 0.0 if (x <= -2.5e+172) tmp = t_1; elseif (x <= 3.3e+171) tmp = Float64(fma(i, y, Float64(fma(log(c), Float64(b - 0.5), t) + z)) + a); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + N[(N[Log[y], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision]}, If[LessEqual[x, -2.5e+172], t$95$1, If[LessEqual[x, 3.3e+171], N[(N[(i * y + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\mathsf{fma}\left(\log c, b - 0.5, \log y \cdot x\right) + t\right) + a\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{+172}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{+171}:\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, t\right) + z\right) + a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.5e172 or 3.29999999999999991e171 < x Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in i around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6455.0
Applied rewrites55.0%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6455.0
Applied rewrites55.0%
if -2.5e172 < x < 3.29999999999999991e171Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (+ t (fma x (log y) (* -0.5 (log c)))))))
(if (<= x -2.5e+172)
t_1
(if (<= x 2.1e+225)
(+ (fma i y (+ (fma (log c) (- b 0.5) t) z)) a)
t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (t + fma(x, log(y), (-0.5 * log(c))));
double tmp;
if (x <= -2.5e+172) {
tmp = t_1;
} else if (x <= 2.1e+225) {
tmp = fma(i, y, (fma(log(c), (b - 0.5), t) + z)) + a;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(t + fma(x, log(y), Float64(-0.5 * log(c))))) tmp = 0.0 if (x <= -2.5e+172) tmp = t_1; elseif (x <= 2.1e+225) tmp = Float64(fma(i, y, Float64(fma(log(c), Float64(b - 0.5), t) + z)) + a); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(t + N[(x * N[Log[y], $MachinePrecision] + N[(-0.5 * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.5e+172], t$95$1, If[LessEqual[x, 2.1e+225], N[(N[(i * y + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := a + \left(t + \mathsf{fma}\left(x, \log y, -0.5 \cdot \log c\right)\right)\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{+172}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, t\right) + z\right) + a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -2.5e172 or 2.1e225 < x Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in i around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6455.0
Applied rewrites55.0%
Taylor expanded in b around 0
lower-*.f64N/A
lower-log.f6439.4
Applied rewrites39.4%
if -2.5e172 < x < 2.1e225Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (* x (log y))))
(if (<= x -1.05e+281)
t_1
(if (<= x 2.6e+225)
(+ (fma i y (+ (fma (log c) (- b 0.5) t) z)) a)
t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = x * log(y);
double tmp;
if (x <= -1.05e+281) {
tmp = t_1;
} else if (x <= 2.6e+225) {
tmp = fma(i, y, (fma(log(c), (b - 0.5), t) + z)) + a;
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(x * log(y)) tmp = 0.0 if (x <= -1.05e+281) tmp = t_1; elseif (x <= 2.6e+225) tmp = Float64(fma(i, y, Float64(fma(log(c), Float64(b - 0.5), t) + z)) + a); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.05e+281], t$95$1, If[LessEqual[x, 2.6e+225], N[(N[(i * y + N[(N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision] + t), $MachinePrecision] + z), $MachinePrecision]), $MachinePrecision] + a), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := x \cdot \log y\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+281}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+225}:\\
\;\;\;\;\mathsf{fma}\left(i, y, \mathsf{fma}\left(\log c, b - 0.5, t\right) + z\right) + a\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.05000000000000003e281 or 2.60000000000000004e225 < x Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-log.f6416.9
Applied rewrites16.9%
if -1.05000000000000003e281 < x < 2.60000000000000004e225Initial program 99.8%
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (if (<= z -3.5e+87) (fma -0.5 (log c) (+ (fma i y (+ a z)) t)) (+ a (+ t (fma i y (* (log c) (- b 0.5)))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double tmp;
if (z <= -3.5e+87) {
tmp = fma(-0.5, log(c), (fma(i, y, (a + z)) + t));
} else {
tmp = a + (t + fma(i, y, (log(c) * (b - 0.5))));
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) tmp = 0.0 if (z <= -3.5e+87) tmp = fma(-0.5, log(c), Float64(fma(i, y, Float64(a + z)) + t)); else tmp = Float64(a + Float64(t + fma(i, y, Float64(log(c) * Float64(b - 0.5))))); end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[z, -3.5e+87], N[(-0.5 * N[Log[c], $MachinePrecision] + N[(N[(i * y + N[(a + z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], N[(a + N[(t + N[(i * y + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.5 \cdot 10^{+87}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log c, \mathsf{fma}\left(i, y, a + z\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;a + \left(t + \mathsf{fma}\left(i, y, \log c \cdot \left(b - 0.5\right)\right)\right)\\
\end{array}
\end{array}
if z < -3.49999999999999986e87Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
Taylor expanded in b around 0
Applied rewrites68.2%
if -3.49999999999999986e87 < z Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower--.f6461.8
Applied rewrites61.8%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (+ t (* (log c) (- b 0.5))))) (t_2 (* (- b 0.5) (log c))))
(if (<= t_2 -5e+214)
t_1
(if (<= t_2 2e+185) (fma -0.5 (log c) (+ (fma i y (+ a z)) t)) t_1))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (t + (log(c) * (b - 0.5)));
double t_2 = (b - 0.5) * log(c);
double tmp;
if (t_2 <= -5e+214) {
tmp = t_1;
} else if (t_2 <= 2e+185) {
tmp = fma(-0.5, log(c), (fma(i, y, (a + z)) + t));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(t + Float64(log(c) * Float64(b - 0.5)))) t_2 = Float64(Float64(b - 0.5) * log(c)) tmp = 0.0 if (t_2 <= -5e+214) tmp = t_1; elseif (t_2 <= 2e+185) tmp = fma(-0.5, log(c), Float64(fma(i, y, Float64(a + z)) + t)); else tmp = t_1; end return tmp end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(t + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e+214], t$95$1, If[LessEqual[t$95$2, 2e+185], N[(-0.5 * N[Log[c], $MachinePrecision] + N[(N[(i * y + N[(a + z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := a + \left(t + \log c \cdot \left(b - 0.5\right)\right)\\
t_2 := \left(b - 0.5\right) \cdot \log c\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+214}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+185}:\\
\;\;\;\;\mathsf{fma}\left(-0.5, \log c, \mathsf{fma}\left(i, y, a + z\right) + t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) < -4.99999999999999953e214 or 2e185 < (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in i around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6455.0
Applied rewrites55.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower--.f6439.8
Applied rewrites39.8%
if -4.99999999999999953e214 < (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c)) < 2e185Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in x around 0
Applied rewrites84.2%
Taylor expanded in b around 0
Applied rewrites68.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 -1e+21)
(* -1.0 (* -1.0 z))
(if (<= t_1 5e+305)
(+ a (+ t (* (log c) (- b 0.5))))
(* (+ 1.0 (/ (* y i) a)) a))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -1e+21) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = a + (t + (log(c) * (b - 0.5)));
} else {
tmp = (1.0 + ((y * i) / a)) * a;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= (-1d+21)) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else if (t_1 <= 5d+305) then
tmp = a + (t + (log(c) * (b - 0.5d0)))
else
tmp = (1.0d0 + ((y * i) / a)) * a
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -1e+21) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = a + (t + (Math.log(c) * (b - 0.5)));
} else {
tmp = (1.0 + ((y * i) / a)) * a;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= -1e+21: tmp = -1.0 * (-1.0 * z) elif t_1 <= 5e+305: tmp = a + (t + (math.log(c) * (b - 0.5))) else: tmp = (1.0 + ((y * i) / a)) * a return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= -1e+21) tmp = Float64(-1.0 * Float64(-1.0 * z)); elseif (t_1 <= 5e+305) tmp = Float64(a + Float64(t + Float64(log(c) * Float64(b - 0.5)))); else tmp = Float64(Float64(1.0 + Float64(Float64(y * i) / a)) * a); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= -1e+21)
tmp = -1.0 * (-1.0 * z);
elseif (t_1 <= 5e+305)
tmp = a + (t + (log(c) * (b - 0.5)));
else
tmp = (1.0 + ((y * i) / a)) * a;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, -1e+21], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+305], N[(a + N[(t + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(y * i), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{+21}:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;a + \left(t + \log c \cdot \left(b - 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{y \cdot i}{a}\right) \cdot a\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -1e21Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
if -1e21 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 5.00000000000000009e305Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in i around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6455.0
Applied rewrites55.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower--.f6439.8
Applied rewrites39.8%
if 5.00000000000000009e305 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f6441.6
Applied rewrites41.6%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
Applied rewrites41.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 -1e+21)
(* -1.0 (* -1.0 z))
(if (<= t_1 5e+305)
(+ a (+ t (* (log c) (- b 0.5))))
(* -1.0 (* a (- (* -1.0 (* y (/ i a))) 1.0))))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -1e+21) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = a + (t + (log(c) * (b - 0.5)));
} else {
tmp = -1.0 * (a * ((-1.0 * (y * (i / a))) - 1.0));
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= (-1d+21)) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else if (t_1 <= 5d+305) then
tmp = a + (t + (log(c) * (b - 0.5d0)))
else
tmp = (-1.0d0) * (a * (((-1.0d0) * (y * (i / a))) - 1.0d0))
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -1e+21) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = a + (t + (Math.log(c) * (b - 0.5)));
} else {
tmp = -1.0 * (a * ((-1.0 * (y * (i / a))) - 1.0));
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= -1e+21: tmp = -1.0 * (-1.0 * z) elif t_1 <= 5e+305: tmp = a + (t + (math.log(c) * (b - 0.5))) else: tmp = -1.0 * (a * ((-1.0 * (y * (i / a))) - 1.0)) return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= -1e+21) tmp = Float64(-1.0 * Float64(-1.0 * z)); elseif (t_1 <= 5e+305) tmp = Float64(a + Float64(t + Float64(log(c) * Float64(b - 0.5)))); else tmp = Float64(-1.0 * Float64(a * Float64(Float64(-1.0 * Float64(y * Float64(i / a))) - 1.0))); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= -1e+21)
tmp = -1.0 * (-1.0 * z);
elseif (t_1 <= 5e+305)
tmp = a + (t + (log(c) * (b - 0.5)));
else
tmp = -1.0 * (a * ((-1.0 * (y * (i / a))) - 1.0));
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, -1e+21], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+305], N[(a + N[(t + N[(N[Log[c], $MachinePrecision] * N[(b - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(a * N[(N[(-1.0 * N[(y * N[(i / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq -1 \cdot 10^{+21}:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;a + \left(t + \log c \cdot \left(b - 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(a \cdot \left(-1 \cdot \left(y \cdot \frac{i}{a}\right) - 1\right)\right)\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -1e21Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
if -1e21 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 5.00000000000000009e305Initial program 99.8%
Taylor expanded in z around 0
lower-+.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6477.1
Applied rewrites77.1%
Taylor expanded in i around inf
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6460.8
Applied rewrites60.8%
Taylor expanded in y around 0
lower-fma.f64N/A
lower-log.f64N/A
lower-*.f64N/A
lower-log.f64N/A
lower--.f6455.0
Applied rewrites55.0%
Taylor expanded in x around 0
lower-*.f64N/A
lower-log.f64N/A
lower--.f6439.8
Applied rewrites39.8%
if 5.00000000000000009e305 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f6441.6
Applied rewrites41.6%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6441.3
Applied rewrites41.3%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 200.0) (* -1.0 (* -1.0 z)) (* (+ 1.0 (/ (* y i) a)) a)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= 200.0) {
tmp = -1.0 * (-1.0 * z);
} else {
tmp = (1.0 + ((y * i) / a)) * a;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= 200.0d0) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else
tmp = (1.0d0 + ((y * i) / a)) * a
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= 200.0) {
tmp = -1.0 * (-1.0 * z);
} else {
tmp = (1.0 + ((y * i) / a)) * a;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= 200.0: tmp = -1.0 * (-1.0 * z) else: tmp = (1.0 + ((y * i) / a)) * a return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= 200.0) tmp = Float64(-1.0 * Float64(-1.0 * z)); else tmp = Float64(Float64(1.0 + Float64(Float64(y * i) / a)) * a); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= 200.0)
tmp = -1.0 * (-1.0 * z);
else
tmp = (1.0 + ((y * i) / a)) * a;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, 200.0], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(y * i), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq 200:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{y \cdot i}{a}\right) \cdot a\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 200Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
if 200 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f6441.6
Applied rewrites41.6%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
Applied rewrites41.6%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 -100.0)
(* -1.0 (* -1.0 z))
(if (<= t_1 5e+305) (* (+ 1.0 (/ z a)) a) (* i y))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -100.0) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = (1.0 + (z / a)) * a;
} else {
tmp = i * y;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= (-100.0d0)) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else if (t_1 <= 5d+305) then
tmp = (1.0d0 + (z / a)) * a
else
tmp = i * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -100.0) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = (1.0 + (z / a)) * a;
} else {
tmp = i * y;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= -100.0: tmp = -1.0 * (-1.0 * z) elif t_1 <= 5e+305: tmp = (1.0 + (z / a)) * a else: tmp = i * y return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= -100.0) tmp = Float64(-1.0 * Float64(-1.0 * z)); elseif (t_1 <= 5e+305) tmp = Float64(Float64(1.0 + Float64(z / a)) * a); else tmp = Float64(i * y); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= -100.0)
tmp = -1.0 * (-1.0 * z);
elseif (t_1 <= 5e+305)
tmp = (1.0 + (z / a)) * a;
else
tmp = i * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, -100.0], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+305], N[(N[(1.0 + N[(z / a), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(i * y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq -100:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\left(1 + \frac{z}{a}\right) \cdot a\\
\mathbf{else}:\\
\;\;\;\;i \cdot y\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307 or 5.00000000000000009e305 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -100Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
if -100 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 5.00000000000000009e305Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-/.f6437.2
Applied rewrites37.2%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
Applied rewrites37.2%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 -100.0)
(* -1.0 (* -1.0 z))
(if (<= t_1 5e+305) (* -1.0 (* a -1.0)) (* i y))))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -100.0) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = -1.0 * (a * -1.0);
} else {
tmp = i * y;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= (-100.0d0)) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else if (t_1 <= 5d+305) then
tmp = (-1.0d0) * (a * (-1.0d0))
else
tmp = i * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= -100.0) {
tmp = -1.0 * (-1.0 * z);
} else if (t_1 <= 5e+305) {
tmp = -1.0 * (a * -1.0);
} else {
tmp = i * y;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= -100.0: tmp = -1.0 * (-1.0 * z) elif t_1 <= 5e+305: tmp = -1.0 * (a * -1.0) else: tmp = i * y return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= -100.0) tmp = Float64(-1.0 * Float64(-1.0 * z)); elseif (t_1 <= 5e+305) tmp = Float64(-1.0 * Float64(a * -1.0)); else tmp = Float64(i * y); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= -100.0)
tmp = -1.0 * (-1.0 * z);
elseif (t_1 <= 5e+305)
tmp = -1.0 * (a * -1.0);
else
tmp = i * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, -100.0], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+305], N[(-1.0 * N[(a * -1.0), $MachinePrecision]), $MachinePrecision], N[(i * y), $MachinePrecision]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq -100:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;-1 \cdot \left(a \cdot -1\right)\\
\mathbf{else}:\\
\;\;\;\;i \cdot y\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307 or 5.00000000000000009e305 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -100Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
if -100 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 5.00000000000000009e305Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in a around inf
Applied rewrites22.5%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1
(+
(+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c)))
(* y i))))
(if (<= t_1 -5e+307)
(* i y)
(if (<= t_1 200.0) (* -1.0 (* -1.0 z)) (* i y)))))assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= 200.0) {
tmp = -1.0 * (-1.0 * z);
} else {
tmp = i * y;
}
return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
real(8) :: t_1
real(8) :: tmp
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5d0) * log(c))) + (y * i)
if (t_1 <= (-5d+307)) then
tmp = i * y
else if (t_1 <= 200.0d0) then
tmp = (-1.0d0) * ((-1.0d0) * z)
else
tmp = i * y
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = (((((x * Math.log(y)) + z) + t) + a) + ((b - 0.5) * Math.log(c))) + (y * i);
double tmp;
if (t_1 <= -5e+307) {
tmp = i * y;
} else if (t_1 <= 200.0) {
tmp = -1.0 * (-1.0 * z);
} else {
tmp = i * y;
}
return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): t_1 = (((((x * math.log(y)) + z) + t) + a) + ((b - 0.5) * math.log(c))) + (y * i) tmp = 0 if t_1 <= -5e+307: tmp = i * y elif t_1 <= 200.0: tmp = -1.0 * (-1.0 * z) else: tmp = i * y return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) t_1 = Float64(Float64(Float64(Float64(Float64(Float64(x * log(y)) + z) + t) + a) + Float64(Float64(b - 0.5) * log(c))) + Float64(y * i)) tmp = 0.0 if (t_1 <= -5e+307) tmp = Float64(i * y); elseif (t_1 <= 200.0) tmp = Float64(-1.0 * Float64(-1.0 * z)); else tmp = Float64(i * y); end return tmp end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
t_1 = (((((x * log(y)) + z) + t) + a) + ((b - 0.5) * log(c))) + (y * i);
tmp = 0.0;
if (t_1 <= -5e+307)
tmp = i * y;
elseif (t_1 <= 200.0)
tmp = -1.0 * (-1.0 * z);
else
tmp = i * y;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(N[(N[(x * N[Log[y], $MachinePrecision]), $MachinePrecision] + z), $MachinePrecision] + t), $MachinePrecision] + a), $MachinePrecision] + N[(N[(b - 0.5), $MachinePrecision] * N[Log[c], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+307], N[(i * y), $MachinePrecision], If[LessEqual[t$95$1, 200.0], N[(-1.0 * N[(-1.0 * z), $MachinePrecision]), $MachinePrecision], N[(i * y), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(\left(\left(x \cdot \log y + z\right) + t\right) + a\right) + \left(b - 0.5\right) \cdot \log c\right) + y \cdot i\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+307}:\\
\;\;\;\;i \cdot y\\
\mathbf{elif}\;t\_1 \leq 200:\\
\;\;\;\;-1 \cdot \left(-1 \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;i \cdot y\\
\end{array}
\end{array}
if (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < -5e307 or 200 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
if -5e307 < (+.f64 (+.f64 (+.f64 (+.f64 (+.f64 (*.f64 x (log.f64 y)) z) t) a) (*.f64 (-.f64 b #s(literal 1/2 binary64)) (log.f64 c))) (*.f64 y i)) < 200Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in z around inf
lower-*.f6423.1
Applied rewrites23.1%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (* i y))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * y;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = i * y
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return i * y;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): return i * y
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(i * y) end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
tmp = i * y;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(i * y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
i \cdot y
\end{array}
Initial program 99.8%
lift-+.f64N/A
lift-+.f64N/A
+-commutativeN/A
associate-+l+N/A
lift-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
associate-+r+N/A
associate-+r+N/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in y around inf
lower-*.f6423.9
Applied rewrites23.9%
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. (FPCore (x y z t a b c i) :precision binary64 (- (- t)))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return -(-t);
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
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, c, i)
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), intent (in) :: c
real(8), intent (in) :: i
code = -(-t)
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return -(-t);
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i]) def code(x, y, z, t, a, b, c, i): return -(-t)
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i]) function code(x, y, z, t, a, b, c, i) return Float64(-Float64(-t)) end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
tmp = -(-t);
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_, i_] := (-(-t))
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
-\left(-t\right)
\end{array}
Initial program 99.8%
Taylor expanded in a around -inf
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites78.9%
Taylor expanded in t around inf
lower-*.f642.9
Applied rewrites2.9%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f642.9
lift-*.f64N/A
mul-1-negN/A
lower-neg.f642.9
Applied rewrites2.9%
herbie shell --seed 2025143
(FPCore (x y z t a b c i)
:name "Numeric.SpecFunctions:logBeta from math-functions-0.1.5.2, B"
:precision binary64
(+ (+ (+ (+ (+ (* x (log y)) z) t) a) (* (- b 0.5) (log c))) (* y i)))