
(FPCore (x y z) :precision binary64 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
end function
public static double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
def code(x, y, z): return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
function code(x, y, z) return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) end
function tmp = code(x, y, z) tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))
double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
end function
public static double code(double x, double y, double z) {
return x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
}
def code(x, y, z): return x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y)))
function code(x, y, z) return Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) end
function tmp = code(x, y, z) tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); end
code[x_, y_, z_] := N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -13500000000.0) (+ x (/ -1.0 x)) (+ (/ y (fma (- x) y (* (exp z) 1.1283791670955126))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -13500000000.0) {
tmp = x + (-1.0 / x);
} else {
tmp = (y / fma(-x, y, (exp(z) * 1.1283791670955126))) + x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -13500000000.0) tmp = Float64(x + Float64(-1.0 / x)); else tmp = Float64(Float64(y / fma(Float64(-x), y, Float64(exp(z) * 1.1283791670955126))) + x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -13500000000.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[((-x) * y + N[(N[Exp[z], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -13500000000:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\mathsf{fma}\left(-x, y, e^{z} \cdot 1.1283791670955126\right)} + x\\
\end{array}
\end{array}
if z < -1.35e10Initial program 89.0%
Taylor expanded in x around inf
lower-/.f64100.0
Applied rewrites100.0%
if -1.35e10 < z Initial program 97.7%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -13500000000.0)
(+ x (/ -1.0 x))
(if (<= z 1.4e-26)
(+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))
x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -13500000000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.4e-26) {
tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-13500000000.0d0)) then
tmp = x + ((-1.0d0) / x)
else if (z <= 1.4d-26) then
tmp = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -13500000000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.4e-26) {
tmp = x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -13500000000.0: tmp = x + (-1.0 / x) elif z <= 1.4e-26: tmp = x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y))) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -13500000000.0) tmp = Float64(x + Float64(-1.0 / x)); elseif (z <= 1.4e-26) tmp = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -13500000000.0) tmp = x + (-1.0 / x); elseif (z <= 1.4e-26) tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -13500000000.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e-26], N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -13500000000:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-26}:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.35e10Initial program 89.0%
Taylor expanded in x around inf
lower-/.f64100.0
Applied rewrites100.0%
if -1.35e10 < z < 1.4000000000000001e-26Initial program 99.8%
if 1.4000000000000001e-26 < z Initial program 93.9%
Taylor expanded in x around inf
Applied rewrites97.0%
(FPCore (x y z) :precision binary64 (if (<= z -13500000000.0) (+ x (/ -1.0 x)) (if (<= z 1.4e-26) (+ x (/ y (- 1.1283791670955126 (* x y)))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -13500000000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.4e-26) {
tmp = x + (y / (1.1283791670955126 - (x * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-13500000000.0d0)) then
tmp = x + ((-1.0d0) / x)
else if (z <= 1.4d-26) then
tmp = x + (y / (1.1283791670955126d0 - (x * y)))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -13500000000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.4e-26) {
tmp = x + (y / (1.1283791670955126 - (x * y)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -13500000000.0: tmp = x + (-1.0 / x) elif z <= 1.4e-26: tmp = x + (y / (1.1283791670955126 - (x * y))) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -13500000000.0) tmp = Float64(x + Float64(-1.0 / x)); elseif (z <= 1.4e-26) tmp = Float64(x + Float64(y / Float64(1.1283791670955126 - Float64(x * y)))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -13500000000.0) tmp = x + (-1.0 / x); elseif (z <= 1.4e-26) tmp = x + (y / (1.1283791670955126 - (x * y))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -13500000000.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.4e-26], N[(x + N[(y / N[(1.1283791670955126 - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -13500000000:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{-26}:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.35e10Initial program 89.0%
Taylor expanded in x around inf
lower-/.f64100.0
Applied rewrites100.0%
if -1.35e10 < z < 1.4000000000000001e-26Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites99.1%
if 1.4000000000000001e-26 < z Initial program 93.9%
Taylor expanded in x around inf
Applied rewrites97.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ -1.0 x)))
(t_1 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))))
(if (<= t_1 -4000.0)
t_0
(if (<= t_1 4.0) (+ x (/ y (* (exp z) 1.1283791670955126))) t_0))))
double code(double x, double y, double z) {
double t_0 = x + (-1.0 / x);
double t_1 = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
double tmp;
if (t_1 <= -4000.0) {
tmp = t_0;
} else if (t_1 <= 4.0) {
tmp = x + (y / (exp(z) * 1.1283791670955126));
} else {
tmp = t_0;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x + ((-1.0d0) / x)
t_1 = x + (y / ((1.1283791670955126d0 * exp(z)) - (x * y)))
if (t_1 <= (-4000.0d0)) then
tmp = t_0
else if (t_1 <= 4.0d0) then
tmp = x + (y / (exp(z) * 1.1283791670955126d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x + (-1.0 / x);
double t_1 = x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
double tmp;
if (t_1 <= -4000.0) {
tmp = t_0;
} else if (t_1 <= 4.0) {
tmp = x + (y / (Math.exp(z) * 1.1283791670955126));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x + (-1.0 / x) t_1 = x + (y / ((1.1283791670955126 * math.exp(z)) - (x * y))) tmp = 0 if t_1 <= -4000.0: tmp = t_0 elif t_1 <= 4.0: tmp = x + (y / (math.exp(z) * 1.1283791670955126)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x + Float64(-1.0 / x)) t_1 = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) tmp = 0.0 if (t_1 <= -4000.0) tmp = t_0; elseif (t_1 <= 4.0) tmp = Float64(x + Float64(y / Float64(exp(z) * 1.1283791670955126))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x + (-1.0 / x); t_1 = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); tmp = 0.0; if (t_1 <= -4000.0) tmp = t_0; elseif (t_1 <= 4.0) tmp = x + (y / (exp(z) * 1.1283791670955126)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4000.0], t$95$0, If[LessEqual[t$95$1, 4.0], N[(x + N[(y / N[(N[Exp[z], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{-1}{x}\\
t_1 := x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\
\mathbf{if}\;t\_1 \leq -4000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 4:\\
\;\;\;\;x + \frac{y}{e^{z} \cdot 1.1283791670955126}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < -4e3 or 4 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) Initial program 94.3%
Taylor expanded in x around inf
lower-/.f6491.2
Applied rewrites91.2%
if -4e3 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < 4Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lift-exp.f6498.4
Applied rewrites98.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ x (/ -1.0 x)))
(t_1 (+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))))
(if (<= t_1 -4000.0)
t_0
(if (<= t_1 4.0) (fma (/ y (exp z)) 0.8862269254527579 x) t_0))))
double code(double x, double y, double z) {
double t_0 = x + (-1.0 / x);
double t_1 = x + (y / ((1.1283791670955126 * exp(z)) - (x * y)));
double tmp;
if (t_1 <= -4000.0) {
tmp = t_0;
} else if (t_1 <= 4.0) {
tmp = fma((y / exp(z)), 0.8862269254527579, x);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x + Float64(-1.0 / x)) t_1 = Float64(x + Float64(y / Float64(Float64(1.1283791670955126 * exp(z)) - Float64(x * y)))) tmp = 0.0 if (t_1 <= -4000.0) tmp = t_0; elseif (t_1 <= 4.0) tmp = fma(Float64(y / exp(z)), 0.8862269254527579, x); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x + N[(y / N[(N[(1.1283791670955126 * N[Exp[z], $MachinePrecision]), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -4000.0], t$95$0, If[LessEqual[t$95$1, 4.0], N[(N[(y / N[Exp[z], $MachinePrecision]), $MachinePrecision] * 0.8862269254527579 + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x + \frac{-1}{x}\\
t_1 := x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\
\mathbf{if}\;t\_1 \leq -4000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 4:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{e^{z}}, 0.8862269254527579, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < -4e3 or 4 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) Initial program 94.3%
Taylor expanded in x around inf
lower-/.f6491.2
Applied rewrites91.2%
if -4e3 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < 4Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6498.3
Applied rewrites98.3%
(FPCore (x y z) :precision binary64 (if (<= z -600000.0) (+ x (/ -1.0 x)) (if (<= z 1.12e-68) (+ (/ y 1.1283791670955126) x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -600000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.12e-68) {
tmp = (y / 1.1283791670955126) + x;
} 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-600000.0d0)) then
tmp = x + ((-1.0d0) / x)
else if (z <= 1.12d-68) then
tmp = (y / 1.1283791670955126d0) + x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -600000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.12e-68) {
tmp = (y / 1.1283791670955126) + x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -600000.0: tmp = x + (-1.0 / x) elif z <= 1.12e-68: tmp = (y / 1.1283791670955126) + x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -600000.0) tmp = Float64(x + Float64(-1.0 / x)); elseif (z <= 1.12e-68) tmp = Float64(Float64(y / 1.1283791670955126) + x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -600000.0) tmp = x + (-1.0 / x); elseif (z <= 1.12e-68) tmp = (y / 1.1283791670955126) + x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -600000.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.12e-68], N[(N[(y / 1.1283791670955126), $MachinePrecision] + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{-68}:\\
\;\;\;\;\frac{y}{1.1283791670955126} + x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6e5Initial program 89.0%
Taylor expanded in x around inf
lower-/.f64100.0
Applied rewrites100.0%
if -6e5 < z < 1.11999999999999992e-68Initial program 99.8%
lift-+.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
distribute-lft-neg-outN/A
mul-1-negN/A
+-commutativeN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
lift-neg.f6499.2
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites72.9%
if 1.11999999999999992e-68 < z Initial program 94.6%
Taylor expanded in x around inf
Applied rewrites92.8%
(FPCore (x y z) :precision binary64 (if (<= z -600000.0) (+ x (/ -1.0 x)) (if (<= z 1.96e-28) (fma y 0.8862269254527579 x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -600000.0) {
tmp = x + (-1.0 / x);
} else if (z <= 1.96e-28) {
tmp = fma(y, 0.8862269254527579, x);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -600000.0) tmp = Float64(x + Float64(-1.0 / x)); elseif (z <= 1.96e-28) tmp = fma(y, 0.8862269254527579, x); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -600000.0], N[(x + N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.96e-28], N[(y * 0.8862269254527579 + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000:\\
\;\;\;\;x + \frac{-1}{x}\\
\mathbf{elif}\;z \leq 1.96 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(y, 0.8862269254527579, x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6e5Initial program 89.0%
Taylor expanded in x around inf
lower-/.f64100.0
Applied rewrites100.0%
if -6e5 < z < 1.9599999999999999e-28Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6473.2
Applied rewrites73.2%
Taylor expanded in z around 0
Applied rewrites73.0%
if 1.9599999999999999e-28 < z Initial program 93.9%
Taylor expanded in x around inf
Applied rewrites96.9%
(FPCore (x y z) :precision binary64 (if (<= z -600000.0) x (if (<= z 1.96e-28) (fma y 0.8862269254527579 x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -600000.0) {
tmp = x;
} else if (z <= 1.96e-28) {
tmp = fma(y, 0.8862269254527579, x);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -600000.0) tmp = x; elseif (z <= 1.96e-28) tmp = fma(y, 0.8862269254527579, x); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -600000.0], x, If[LessEqual[z, 1.96e-28], N[(y * 0.8862269254527579 + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.96 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(y, 0.8862269254527579, x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6e5 or 1.9599999999999999e-28 < z Initial program 91.6%
Taylor expanded in x around inf
Applied rewrites75.8%
if -6e5 < z < 1.9599999999999999e-28Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6473.2
Applied rewrites73.2%
Taylor expanded in z around 0
Applied rewrites73.0%
(FPCore (x y z) :precision binary64 (if (<= x -2.05e-179) x (if (<= x 4.1e-159) (* y 0.8862269254527579) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e-179) {
tmp = x;
} else if (x <= 4.1e-159) {
tmp = y * 0.8862269254527579;
} 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-2.05d-179)) then
tmp = x
else if (x <= 4.1d-159) then
tmp = y * 0.8862269254527579d0
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.05e-179) {
tmp = x;
} else if (x <= 4.1e-159) {
tmp = y * 0.8862269254527579;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.05e-179: tmp = x elif x <= 4.1e-159: tmp = y * 0.8862269254527579 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.05e-179) tmp = x; elseif (x <= 4.1e-159) tmp = Float64(y * 0.8862269254527579); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.05e-179) tmp = x; elseif (x <= 4.1e-159) tmp = y * 0.8862269254527579; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.05e-179], x, If[LessEqual[x, 4.1e-159], N[(y * 0.8862269254527579), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.05 \cdot 10^{-179}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.1 \cdot 10^{-159}:\\
\;\;\;\;y \cdot 0.8862269254527579\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.05e-179 or 4.10000000000000014e-159 < x Initial program 96.9%
Taylor expanded in x around inf
Applied rewrites80.4%
if -2.05e-179 < x < 4.10000000000000014e-159Initial program 91.7%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-exp.f6442.9
Applied rewrites42.9%
Taylor expanded in z around 0
Applied rewrites40.8%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.7%
Taylor expanded in x around inf
Applied rewrites69.3%
herbie shell --seed 2025101
(FPCore (x y z)
:name "Numeric.SpecFunctions:invErfc from math-functions-0.1.5.2, A"
:precision binary64
(+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y)))))