
(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 -1.15e+21) (- x (/ 1.0 x)) (+ x (/ y (fma (- x) y (* (exp z) 1.1283791670955126))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+21) {
tmp = x - (1.0 / x);
} else {
tmp = x + (y / fma(-x, y, (exp(z) * 1.1283791670955126)));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.15e+21) tmp = Float64(x - Float64(1.0 / x)); else tmp = Float64(x + Float64(y / fma(Float64(-x), y, Float64(exp(z) * 1.1283791670955126)))); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+21], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[((-x) * y + N[(N[Exp[z], $MachinePrecision] * 1.1283791670955126), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+21}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\mathsf{fma}\left(-x, y, e^{z} \cdot 1.1283791670955126\right)}\\
\end{array}
\end{array}
if z < -1.15e21Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.15e21 < z Initial program 97.2%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-exp.f6499.6
Applied rewrites99.6%
(FPCore (x y z)
:precision binary64
(if (<= z -1.15e+21)
(- x (/ 1.0 x))
(if (<= z 0.000135)
(+ x (/ y (- (* 1.1283791670955126 (exp z)) (* x y))))
x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 0.000135) {
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 <= (-1.15d+21)) then
tmp = x - (1.0d0 / x)
else if (z <= 0.000135d0) 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 <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 0.000135) {
tmp = x + (y / ((1.1283791670955126 * Math.exp(z)) - (x * y)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.15e+21: tmp = x - (1.0 / x) elif z <= 0.000135: 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 <= -1.15e+21) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 0.000135) 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 <= -1.15e+21) tmp = x - (1.0 / x); elseif (z <= 0.000135) tmp = x + (y / ((1.1283791670955126 * exp(z)) - (x * y))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+21], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.000135], 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 -1.15 \cdot 10^{+21}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 0.000135:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 \cdot e^{z} - x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.15e21Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.15e21 < z < 1.35000000000000002e-4Initial program 99.4%
if 1.35000000000000002e-4 < z Initial program 93.1%
Taylor expanded in x around inf
Applied rewrites99.4%
(FPCore (x y z)
:precision binary64
(if (<= z -1.15e+21)
(- x (/ 1.0 x))
(if (<= z 2.1e-23)
(+ x (/ y (fma (- x) y 1.1283791670955126)))
(fma (/ y (exp z)) 0.8862269254527579 x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 2.1e-23) {
tmp = x + (y / fma(-x, y, 1.1283791670955126));
} else {
tmp = fma((y / exp(z)), 0.8862269254527579, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.15e+21) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 2.1e-23) tmp = Float64(x + Float64(y / fma(Float64(-x), y, 1.1283791670955126))); else tmp = fma(Float64(y / exp(z)), 0.8862269254527579, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+21], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.1e-23], N[(x + N[(y / N[((-x) * y + 1.1283791670955126), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / N[Exp[z], $MachinePrecision]), $MachinePrecision] * 0.8862269254527579 + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+21}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-23}:\\
\;\;\;\;x + \frac{y}{\mathsf{fma}\left(-x, y, 1.1283791670955126\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{e^{z}}, 0.8862269254527579, x\right)\\
\end{array}
\end{array}
if z < -1.15e21Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.15e21 < z < 2.1000000000000001e-23Initial program 99.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
Taylor expanded in z around 0
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites98.3%
if 2.1000000000000001e-23 < z Initial program 93.4%
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 -1.15e+21) (- x (/ 1.0 x)) (if (<= z 0.000135) (+ x (/ y (fma (- x) y 1.1283791670955126))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 0.000135) {
tmp = x + (y / fma(-x, y, 1.1283791670955126));
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.15e+21) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 0.000135) tmp = Float64(x + Float64(y / fma(Float64(-x), y, 1.1283791670955126))); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+21], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.000135], N[(x + N[(y / N[((-x) * y + 1.1283791670955126), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+21}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 0.000135:\\
\;\;\;\;x + \frac{y}{\mathsf{fma}\left(-x, y, 1.1283791670955126\right)}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.15e21Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.15e21 < z < 1.35000000000000002e-4Initial program 99.4%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-exp.f6499.4
Applied rewrites99.4%
Taylor expanded in z around 0
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites98.2%
if 1.35000000000000002e-4 < z Initial program 93.1%
Taylor expanded in x around inf
Applied rewrites99.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.15e+21) (- x (/ 1.0 x)) (if (<= z 0.000135) (+ x (/ y (- 1.1283791670955126 (* x y)))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 0.000135) {
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 <= (-1.15d+21)) then
tmp = x - (1.0d0 / x)
else if (z <= 0.000135d0) 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 <= -1.15e+21) {
tmp = x - (1.0 / x);
} else if (z <= 0.000135) {
tmp = x + (y / (1.1283791670955126 - (x * y)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.15e+21: tmp = x - (1.0 / x) elif z <= 0.000135: tmp = x + (y / (1.1283791670955126 - (x * y))) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.15e+21) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 0.000135) 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 <= -1.15e+21) tmp = x - (1.0 / x); elseif (z <= 0.000135) tmp = x + (y / (1.1283791670955126 - (x * y))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.15e+21], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.000135], 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 -1.15 \cdot 10^{+21}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 0.000135:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.15e21Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -1.15e21 < z < 1.35000000000000002e-4Initial program 99.4%
Taylor expanded in z around 0
Applied rewrites98.2%
if 1.35000000000000002e-4 < z Initial program 93.1%
Taylor expanded in x around inf
Applied rewrites99.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.7e-24) (- x (/ 1.0 x)) (if (<= z 7.8e-222) (fma y 0.8862269254527579 x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.7e-24) {
tmp = x - (1.0 / x);
} else if (z <= 7.8e-222) {
tmp = fma(y, 0.8862269254527579, x);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.7e-24) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 7.8e-222) tmp = fma(y, 0.8862269254527579, x); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.7e-24], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.8e-222], N[(y * 0.8862269254527579 + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-24}:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{-222}:\\
\;\;\;\;\mathsf{fma}\left(y, 0.8862269254527579, x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.69999999999999996e-24Initial program 88.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f6497.1
Applied rewrites97.1%
if -1.69999999999999996e-24 < z < 7.8000000000000002e-222Initial program 99.8%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6474.4
Applied rewrites74.4%
Taylor expanded in z around 0
Applied rewrites74.4%
if 7.8000000000000002e-222 < z Initial program 95.7%
Taylor expanded in x around inf
Applied rewrites84.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.08e+23) (/ -1.0 x) (if (<= z 7.8e-222) (fma y 0.8862269254527579 x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.08e+23) {
tmp = -1.0 / x;
} else if (z <= 7.8e-222) {
tmp = fma(y, 0.8862269254527579, x);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -1.08e+23) tmp = Float64(-1.0 / x); elseif (z <= 7.8e-222) tmp = fma(y, 0.8862269254527579, x); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -1.08e+23], N[(-1.0 / x), $MachinePrecision], If[LessEqual[z, 7.8e-222], N[(y * 0.8862269254527579 + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.08 \cdot 10^{+23}:\\
\;\;\;\;\frac{-1}{x}\\
\mathbf{elif}\;z \leq 7.8 \cdot 10^{-222}:\\
\;\;\;\;\mathsf{fma}\left(y, 0.8862269254527579, x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.0800000000000001e23Initial program 87.5%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in x around 0
lower-/.f6450.4
Applied rewrites50.4%
if -1.0800000000000001e23 < z < 7.8000000000000002e-222Initial program 99.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6471.3
Applied rewrites71.3%
Taylor expanded in z around 0
Applied rewrites71.9%
if 7.8000000000000002e-222 < z Initial program 95.7%
Taylor expanded in x around inf
Applied rewrites84.9%
(FPCore (x y z)
:precision binary64
(if (<= x -0.0005)
x
(if (<= x -3.7e-101)
(/ -1.0 x)
(if (<= x -9e-219)
x
(if (<= x 5.3e-170)
(* y 0.8862269254527579)
(if (<= x 0.012) (/ -1.0 x) x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -0.0005) {
tmp = x;
} else if (x <= -3.7e-101) {
tmp = -1.0 / x;
} else if (x <= -9e-219) {
tmp = x;
} else if (x <= 5.3e-170) {
tmp = y * 0.8862269254527579;
} else if (x <= 0.012) {
tmp = -1.0 / 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 (x <= (-0.0005d0)) then
tmp = x
else if (x <= (-3.7d-101)) then
tmp = (-1.0d0) / x
else if (x <= (-9d-219)) then
tmp = x
else if (x <= 5.3d-170) then
tmp = y * 0.8862269254527579d0
else if (x <= 0.012d0) then
tmp = (-1.0d0) / x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -0.0005) {
tmp = x;
} else if (x <= -3.7e-101) {
tmp = -1.0 / x;
} else if (x <= -9e-219) {
tmp = x;
} else if (x <= 5.3e-170) {
tmp = y * 0.8862269254527579;
} else if (x <= 0.012) {
tmp = -1.0 / x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -0.0005: tmp = x elif x <= -3.7e-101: tmp = -1.0 / x elif x <= -9e-219: tmp = x elif x <= 5.3e-170: tmp = y * 0.8862269254527579 elif x <= 0.012: tmp = -1.0 / x else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -0.0005) tmp = x; elseif (x <= -3.7e-101) tmp = Float64(-1.0 / x); elseif (x <= -9e-219) tmp = x; elseif (x <= 5.3e-170) tmp = Float64(y * 0.8862269254527579); elseif (x <= 0.012) tmp = Float64(-1.0 / x); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -0.0005) tmp = x; elseif (x <= -3.7e-101) tmp = -1.0 / x; elseif (x <= -9e-219) tmp = x; elseif (x <= 5.3e-170) tmp = y * 0.8862269254527579; elseif (x <= 0.012) tmp = -1.0 / x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -0.0005], x, If[LessEqual[x, -3.7e-101], N[(-1.0 / x), $MachinePrecision], If[LessEqual[x, -9e-219], x, If[LessEqual[x, 5.3e-170], N[(y * 0.8862269254527579), $MachinePrecision], If[LessEqual[x, 0.012], N[(-1.0 / x), $MachinePrecision], x]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -3.7 \cdot 10^{-101}:\\
\;\;\;\;\frac{-1}{x}\\
\mathbf{elif}\;x \leq -9 \cdot 10^{-219}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{-170}:\\
\;\;\;\;y \cdot 0.8862269254527579\\
\mathbf{elif}\;x \leq 0.012:\\
\;\;\;\;\frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -5.0000000000000001e-4 or -3.70000000000000005e-101 < x < -9.00000000000000029e-219 or 0.012 < x Initial program 95.9%
Taylor expanded in x around inf
Applied rewrites89.2%
if -5.0000000000000001e-4 < x < -3.70000000000000005e-101 or 5.3e-170 < x < 0.012Initial program 96.9%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f6444.9
Applied rewrites44.9%
Taylor expanded in x around 0
lower-/.f6444.2
Applied rewrites44.2%
if -9.00000000000000029e-219 < x < 5.3e-170Initial program 95.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-exp.f647.1
Applied rewrites7.1%
Taylor expanded in z around 0
Applied rewrites7.3%
(FPCore (x y z) :precision binary64 (if (<= x -9e-219) x (if (<= x 2.7e-56) (* y 0.8862269254527579) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e-219) {
tmp = x;
} else if (x <= 2.7e-56) {
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 <= (-9d-219)) then
tmp = x
else if (x <= 2.7d-56) 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 <= -9e-219) {
tmp = x;
} else if (x <= 2.7e-56) {
tmp = y * 0.8862269254527579;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9e-219: tmp = x elif x <= 2.7e-56: tmp = y * 0.8862269254527579 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9e-219) tmp = x; elseif (x <= 2.7e-56) tmp = Float64(y * 0.8862269254527579); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9e-219) tmp = x; elseif (x <= 2.7e-56) tmp = y * 0.8862269254527579; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9e-219], x, If[LessEqual[x, 2.7e-56], N[(y * 0.8862269254527579), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-219}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-56}:\\
\;\;\;\;y \cdot 0.8862269254527579\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -9.00000000000000029e-219 or 2.69999999999999995e-56 < x Initial program 96.3%
Taylor expanded in x around inf
Applied rewrites81.9%
if -9.00000000000000029e-219 < x < 2.69999999999999995e-56Initial program 91.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-exp.f6434.3
Applied rewrites34.3%
Taylor expanded in z around 0
Applied rewrites32.5%
(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.0%
Taylor expanded in x around inf
Applied rewrites68.8%
herbie shell --seed 2025120
(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)))))