
(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 12 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 -3100.0)
(- x (/ 1.0 x))
(if (<= z 2.9e-9)
(+ (/ y (- (* (exp z) 1.1283791670955126) (* y x))) x)
(fma (* 0.8862269254527579 y) (exp (- z)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 2.9e-9) {
tmp = (y / ((exp(z) * 1.1283791670955126) - (y * x))) + x;
} else {
tmp = fma((0.8862269254527579 * y), exp(-z), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 2.9e-9) tmp = Float64(Float64(y / Float64(Float64(exp(z) * 1.1283791670955126) - Float64(y * x))) + x); else tmp = fma(Float64(0.8862269254527579 * y), exp(Float64(-z)), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.9e-9], N[(N[(y / N[(N[(N[Exp[z], $MachinePrecision] * 1.1283791670955126), $MachinePrecision] - N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(0.8862269254527579 * y), $MachinePrecision] * N[Exp[(-z)], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-9}:\\
\;\;\;\;\frac{y}{e^{z} \cdot 1.1283791670955126 - y \cdot x} + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.8862269254527579 \cdot y, e^{-z}, x\right)\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z < 2.89999999999999991e-9Initial program 99.8%
lift-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-exp.f64N/A
+-commutativeN/A
lower-+.f64N/A
Applied rewrites99.8%
if 2.89999999999999991e-9 < z Initial program 94.0%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6494.0
Applied rewrites94.0%
Taylor expanded in x around 0
Applied rewrites76.3%
Taylor expanded in y around 0
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (if (<= z -3100.0) (- x (/ 1.0 x)) (+ x (/ y (* (- (/ 1.1283791670955126 (* (exp (- z)) y)) x) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else {
tmp = x + (y / (((1.1283791670955126 / (exp(-z) * y)) - x) * y));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-3100.0d0)) then
tmp = x - (1.0d0 / x)
else
tmp = x + (y / (((1.1283791670955126d0 / (exp(-z) * y)) - x) * y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else {
tmp = x + (y / (((1.1283791670955126 / (Math.exp(-z) * y)) - x) * y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3100.0: tmp = x - (1.0 / x) else: tmp = x + (y / (((1.1283791670955126 / (math.exp(-z) * y)) - x) * y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); else tmp = Float64(x + Float64(y / Float64(Float64(Float64(1.1283791670955126 / Float64(exp(Float64(-z)) * y)) - x) * y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3100.0) tmp = x - (1.0 / x); else tmp = x + (y / (((1.1283791670955126 / (exp(-z) * y)) - x) * y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(N[(N[(1.1283791670955126 / N[(N[Exp[(-z)], $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\left(\frac{1.1283791670955126}{e^{-z} \cdot y} - x\right) \cdot y}\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z Initial program 97.9%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in y around inf
negate-subN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
rec-expN/A
inv-powN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
mul-1-negN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
(FPCore (x y z)
:precision binary64
(if (<= z -3100.0)
(- x (/ 1.0 x))
(if (<= z 2.8e-9)
(+ x (/ y (* (- (/ 1.1283791670955126 y) x) y)))
(fma (* 0.8862269254527579 y) (exp (- z)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 2.8e-9) {
tmp = x + (y / (((1.1283791670955126 / y) - x) * y));
} else {
tmp = fma((0.8862269254527579 * y), exp(-z), x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 2.8e-9) tmp = Float64(x + Float64(y / Float64(Float64(Float64(1.1283791670955126 / y) - x) * y))); else tmp = fma(Float64(0.8862269254527579 * y), exp(Float64(-z)), x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e-9], N[(x + N[(y / N[(N[(N[(1.1283791670955126 / y), $MachinePrecision] - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.8862269254527579 * y), $MachinePrecision] * N[Exp[(-z)], $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;x + \frac{y}{\left(\frac{1.1283791670955126}{y} - x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.8862269254527579 \cdot y, e^{-z}, x\right)\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z < 2.79999999999999984e-9Initial program 99.8%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
negate-subN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
rec-expN/A
inv-powN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
mul-1-negN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites99.3%
if 2.79999999999999984e-9 < z Initial program 94.0%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6494.0
Applied rewrites94.0%
Taylor expanded in x around 0
Applied rewrites76.3%
Taylor expanded in y around 0
Applied rewrites99.3%
(FPCore (x y z)
:precision binary64
(if (<= z -3100.0)
(- x (/ 1.0 x))
(if (<= z 2.8e-9)
(+ x (/ y (* (- (/ 1.1283791670955126 y) x) y)))
(fma (/ y (exp z)) 0.8862269254527579 x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 2.8e-9) {
tmp = x + (y / (((1.1283791670955126 / y) - x) * y));
} else {
tmp = fma((y / exp(z)), 0.8862269254527579, x);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 2.8e-9) tmp = Float64(x + Float64(y / Float64(Float64(Float64(1.1283791670955126 / y) - x) * y))); else tmp = fma(Float64(y / exp(z)), 0.8862269254527579, x); end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e-9], N[(x + N[(y / N[(N[(N[(1.1283791670955126 / y), $MachinePrecision] - x), $MachinePrecision] * y), $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 -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{-9}:\\
\;\;\;\;x + \frac{y}{\left(\frac{1.1283791670955126}{y} - x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{e^{z}}, 0.8862269254527579, x\right)\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z < 2.79999999999999984e-9Initial program 99.8%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
negate-subN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
rec-expN/A
inv-powN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
mul-1-negN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites99.3%
if 2.79999999999999984e-9 < z Initial program 94.0%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6499.3
Applied rewrites99.3%
(FPCore (x y z) :precision binary64 (if (<= z -3100.0) (- x (/ 1.0 x)) (if (<= z 245.0) (+ x (/ y (* (- (/ 1.1283791670955126 y) x) y))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 245.0) {
tmp = x + (y / (((1.1283791670955126 / y) - 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 <= (-3100.0d0)) then
tmp = x - (1.0d0 / x)
else if (z <= 245.0d0) then
tmp = x + (y / (((1.1283791670955126d0 / y) - 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 <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 245.0) {
tmp = x + (y / (((1.1283791670955126 / y) - x) * y));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3100.0: tmp = x - (1.0 / x) elif z <= 245.0: tmp = x + (y / (((1.1283791670955126 / y) - x) * y)) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 245.0) tmp = Float64(x + Float64(y / Float64(Float64(Float64(1.1283791670955126 / y) - x) * y))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3100.0) tmp = x - (1.0 / x); elseif (z <= 245.0) tmp = x + (y / (((1.1283791670955126 / y) - x) * y)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 245.0], N[(x + N[(y / N[(N[(N[(1.1283791670955126 / y), $MachinePrecision] - x), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 245:\\
\;\;\;\;x + \frac{y}{\left(\frac{1.1283791670955126}{y} - x\right) \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z < 245Initial program 99.8%
lift-exp.f64N/A
unpow1N/A
metadata-evalN/A
pow-negN/A
inv-powN/A
lower-/.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in y around inf
negate-subN/A
mul-1-negN/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
rec-expN/A
inv-powN/A
pow-flipN/A
metadata-evalN/A
unpow1N/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
mul-1-negN/A
negate-subN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
Taylor expanded in z around 0
Applied rewrites98.9%
if 245 < z Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites99.9%
(FPCore (x y z) :precision binary64 (if (<= z -3100.0) (- x (/ 1.0 x)) (if (<= z 245.0) (+ x (/ y (- 1.1283791670955126 (* x y)))) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 245.0) {
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 <= (-3100.0d0)) then
tmp = x - (1.0d0 / x)
else if (z <= 245.0d0) 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 <= -3100.0) {
tmp = x - (1.0 / x);
} else if (z <= 245.0) {
tmp = x + (y / (1.1283791670955126 - (x * y)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3100.0: tmp = x - (1.0 / x) elif z <= 245.0: tmp = x + (y / (1.1283791670955126 - (x * y))) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3100.0) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 245.0) 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 <= -3100.0) tmp = x - (1.0 / x); elseif (z <= 245.0) tmp = x + (y / (1.1283791670955126 - (x * y))); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3100.0], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 245.0], 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 -3100:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 245:\\
\;\;\;\;x + \frac{y}{1.1283791670955126 - x \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -3100Initial program 89.0%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3100 < z < 245Initial program 99.8%
Taylor expanded in z around 0
Applied rewrites98.9%
if 245 < z Initial program 93.8%
Taylor expanded in x around inf
Applied rewrites99.9%
(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 -10.0)
t_0
(if (<= t_1 5.0) (fma (/ y (+ 1.0 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 <= -10.0) {
tmp = t_0;
} else if (t_1 <= 5.0) {
tmp = fma((y / (1.0 + 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 <= -10.0) tmp = t_0; elseif (t_1 <= 5.0) tmp = fma(Float64(y / Float64(1.0 + 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, -10.0], t$95$0, If[LessEqual[t$95$1, 5.0], N[(N[(y / N[(1.0 + 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 -10:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{1 + 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)))) < -10 or 5 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) Initial program 94.2%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f6491.1
Applied rewrites91.1%
if -10 < (+.f64 x (/.f64 y (-.f64 (*.f64 #s(literal 5641895835477563/5000000000000000 binary64) (exp.f64 z)) (*.f64 x y)))) < 5Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-exp.f6499.2
Applied rewrites99.2%
Taylor expanded in z around 0
lower-+.f6475.2
Applied rewrites75.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.0063) (- x (/ 1.0 x)) (if (<= z 7.4e-33) (- x (* -0.8862269254527579 y)) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0063) {
tmp = x - (1.0 / x);
} else if (z <= 7.4e-33) {
tmp = x - (-0.8862269254527579 * 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 <= (-0.0063d0)) then
tmp = x - (1.0d0 / x)
else if (z <= 7.4d-33) then
tmp = x - ((-0.8862269254527579d0) * y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.0063) {
tmp = x - (1.0 / x);
} else if (z <= 7.4e-33) {
tmp = x - (-0.8862269254527579 * y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0063: tmp = x - (1.0 / x) elif z <= 7.4e-33: tmp = x - (-0.8862269254527579 * y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0063) tmp = Float64(x - Float64(1.0 / x)); elseif (z <= 7.4e-33) tmp = Float64(x - Float64(-0.8862269254527579 * y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.0063) tmp = x - (1.0 / x); elseif (z <= 7.4e-33) tmp = x - (-0.8862269254527579 * y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0063], N[(x - N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.4e-33], N[(x - N[(-0.8862269254527579 * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0063:\\
\;\;\;\;x - \frac{1}{x}\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-33}:\\
\;\;\;\;x - -0.8862269254527579 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.0063Initial program 89.1%
Taylor expanded in y around inf
lower--.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
if -0.0063 < z < 7.40000000000000028e-33Initial program 99.9%
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
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6474.2
Applied rewrites74.2%
if 7.40000000000000028e-33 < z Initial program 94.4%
Taylor expanded in x around inf
Applied rewrites95.7%
(FPCore (x y z) :precision binary64 (if (<= z -0.0017) x (if (<= z 7.4e-33) (- x (* -0.8862269254527579 y)) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0017) {
tmp = x;
} else if (z <= 7.4e-33) {
tmp = x - (-0.8862269254527579 * 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 <= (-0.0017d0)) then
tmp = x
else if (z <= 7.4d-33) then
tmp = x - ((-0.8862269254527579d0) * y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -0.0017) {
tmp = x;
} else if (z <= 7.4e-33) {
tmp = x - (-0.8862269254527579 * y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -0.0017: tmp = x elif z <= 7.4e-33: tmp = x - (-0.8862269254527579 * y) else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -0.0017) tmp = x; elseif (z <= 7.4e-33) tmp = Float64(x - Float64(-0.8862269254527579 * y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -0.0017) tmp = x; elseif (z <= 7.4e-33) tmp = x - (-0.8862269254527579 * y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -0.0017], x, If[LessEqual[z, 7.4e-33], N[(x - N[(-0.8862269254527579 * y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0017:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-33}:\\
\;\;\;\;x - -0.8862269254527579 \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.00169999999999999991 or 7.40000000000000028e-33 < z Initial program 91.9%
Taylor expanded in x around inf
Applied rewrites73.6%
if -0.00169999999999999991 < z < 7.40000000000000028e-33Initial 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
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
lift-fma.f64N/A
+-commutativeN/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6474.2
Applied rewrites74.2%
(FPCore (x y z) :precision binary64 (if (<= z -0.0017) x (if (<= z 7.4e-33) (fma 0.8862269254527579 y x) x)))
double code(double x, double y, double z) {
double tmp;
if (z <= -0.0017) {
tmp = x;
} else if (z <= 7.4e-33) {
tmp = fma(0.8862269254527579, y, x);
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (z <= -0.0017) tmp = x; elseif (z <= 7.4e-33) tmp = fma(0.8862269254527579, y, x); else tmp = x; end return tmp end
code[x_, y_, z_] := If[LessEqual[z, -0.0017], x, If[LessEqual[z, 7.4e-33], N[(0.8862269254527579 * y + x), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0017:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 7.4 \cdot 10^{-33}:\\
\;\;\;\;\mathsf{fma}\left(0.8862269254527579, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -0.00169999999999999991 or 7.40000000000000028e-33 < z Initial program 91.9%
Taylor expanded in x around inf
Applied rewrites73.6%
if -0.00169999999999999991 < z < 7.40000000000000028e-33Initial 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
+-commutativeN/A
lower-fma.f6474.2
Applied rewrites74.2%
(FPCore (x y z) :precision binary64 (if (<= x -7e-192) x (if (<= x 2.9e-147) (* y 0.8862269254527579) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -7e-192) {
tmp = x;
} else if (x <= 2.9e-147) {
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 <= (-7d-192)) then
tmp = x
else if (x <= 2.9d-147) 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 <= -7e-192) {
tmp = x;
} else if (x <= 2.9e-147) {
tmp = y * 0.8862269254527579;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -7e-192: tmp = x elif x <= 2.9e-147: tmp = y * 0.8862269254527579 else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -7e-192) tmp = x; elseif (x <= 2.9e-147) tmp = Float64(y * 0.8862269254527579); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -7e-192) tmp = x; elseif (x <= 2.9e-147) tmp = y * 0.8862269254527579; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -7e-192], x, If[LessEqual[x, 2.9e-147], N[(y * 0.8862269254527579), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{-192}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.9 \cdot 10^{-147}:\\
\;\;\;\;y \cdot 0.8862269254527579\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.00000000000000029e-192 or 2.9000000000000001e-147 < x Initial program 97.1%
Taylor expanded in x around inf
Applied rewrites79.7%
if -7.00000000000000029e-192 < x < 2.9000000000000001e-147Initial program 90.6%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift-exp.f6440.1
Applied rewrites40.1%
Taylor expanded in z around 0
Applied rewrites37.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.6%
Taylor expanded in x around inf
Applied rewrites69.0%
herbie shell --seed 2025110
(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)))))