
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
double code(double x, double y) {
return exp((x * log((x / (x + y))))) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp((x * log((x / (x + y))))) / x
end function
public static double code(double x, double y) {
return Math.exp((x * Math.log((x / (x + y))))) / x;
}
def code(x, y): return math.exp((x * math.log((x / (x + y))))) / x
function code(x, y) return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x) end
function tmp = code(x, y) tmp = exp((x * log((x / (x + y))))) / x; end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (exp (* x (log (/ x (+ x y))))) x))
double code(double x, double y) {
return exp((x * log((x / (x + y))))) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = exp((x * log((x / (x + y))))) / x
end function
public static double code(double x, double y) {
return Math.exp((x * Math.log((x / (x + y))))) / x;
}
def code(x, y): return math.exp((x * math.log((x / (x + y))))) / x
function code(x, y) return Float64(exp(Float64(x * log(Float64(x / Float64(x + y))))) / x) end
function tmp = code(x, y) tmp = exp((x * log((x / (x + y))))) / x; end
code[x_, y_] := N[(N[Exp[N[(x * N[Log[N[(x / N[(x + y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / x), $MachinePrecision]
\frac{e^{x \cdot \log \left(\frac{x}{x + y}\right)}}{x}
(FPCore (x y)
:precision binary64
(if (<= x -122000000000)
(/ 1 (* (exp (- (- y))) x))
(if (<=
x
7049479487983089/6129982163463555433433388108601236734474956488734408704)
(/ 1 x)
(/ (exp (- y)) x))))double code(double x, double y) {
double tmp;
if (x <= -122000000000.0) {
tmp = 1.0 / (exp(-(-y)) * x);
} else if (x <= 1.15e-39) {
tmp = 1.0 / x;
} else {
tmp = exp(-y) / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-122000000000.0d0)) then
tmp = 1.0d0 / (exp(-(-y)) * x)
else if (x <= 1.15d-39) then
tmp = 1.0d0 / x
else
tmp = exp(-y) / x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -122000000000.0) {
tmp = 1.0 / (Math.exp(-(-y)) * x);
} else if (x <= 1.15e-39) {
tmp = 1.0 / x;
} else {
tmp = Math.exp(-y) / x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -122000000000.0: tmp = 1.0 / (math.exp(-(-y)) * x) elif x <= 1.15e-39: tmp = 1.0 / x else: tmp = math.exp(-y) / x return tmp
function code(x, y) tmp = 0.0 if (x <= -122000000000.0) tmp = Float64(1.0 / Float64(exp(Float64(-Float64(-y))) * x)); elseif (x <= 1.15e-39) tmp = Float64(1.0 / x); else tmp = Float64(exp(Float64(-y)) / x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -122000000000.0) tmp = 1.0 / (exp(-(-y)) * x); elseif (x <= 1.15e-39) tmp = 1.0 / x; else tmp = exp(-y) / x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -122000000000], N[(1 / N[(N[Exp[(-(-y))], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7049479487983089/6129982163463555433433388108601236734474956488734408704], N[(1 / x), $MachinePrecision], N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -122000000000:\\
\;\;\;\;\frac{1}{e^{-\left(-y\right)} \cdot x}\\
\mathbf{elif}\;x \leq \frac{7049479487983089}{6129982163463555433433388108601236734474956488734408704}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{-y}}{x}\\
\end{array}
if x < -1.22e11Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6483.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
lift-exp.f64N/A
rec-expN/A
lower-exp.f64N/A
lower-neg.f6483.3%
Applied rewrites83.3%
if -1.22e11 < x < 1.15e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
if 1.15e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ (exp (- y)) x)))
(if (<= x -122000000000)
t_0
(if (<=
x
7049479487983089/6129982163463555433433388108601236734474956488734408704)
(/ 1 x)
t_0))))double code(double x, double y) {
double t_0 = exp(-y) / x;
double tmp;
if (x <= -122000000000.0) {
tmp = t_0;
} else if (x <= 1.15e-39) {
tmp = 1.0 / x;
} 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = exp(-y) / x
if (x <= (-122000000000.0d0)) then
tmp = t_0
else if (x <= 1.15d-39) then
tmp = 1.0d0 / x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = Math.exp(-y) / x;
double tmp;
if (x <= -122000000000.0) {
tmp = t_0;
} else if (x <= 1.15e-39) {
tmp = 1.0 / x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = math.exp(-y) / x tmp = 0 if x <= -122000000000.0: tmp = t_0 elif x <= 1.15e-39: tmp = 1.0 / x else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(exp(Float64(-y)) / x) tmp = 0.0 if (x <= -122000000000.0) tmp = t_0; elseif (x <= 1.15e-39) tmp = Float64(1.0 / x); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = exp(-y) / x; tmp = 0.0; if (x <= -122000000000.0) tmp = t_0; elseif (x <= 1.15e-39) tmp = 1.0 / x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[Exp[(-y)], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, -122000000000], t$95$0, If[LessEqual[x, 7049479487983089/6129982163463555433433388108601236734474956488734408704], N[(1 / x), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{e^{-y}}{x}\\
\mathbf{if}\;x \leq -122000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq \frac{7049479487983089}{6129982163463555433433388108601236734474956488734408704}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -1.22e11 or 1.15e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
if -1.22e11 < x < 1.15e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
(FPCore (x y)
:precision binary64
(if (<= x -450000000000)
(/ (/ (* (- 1 y) x) x) x)
(if (<=
x
98175495586721/11972621413014756705924586149611790497021399392059392)
(/ 1 x)
(/
1
(+
x
(*
y
(-
(* -1 (* y (+ (* -1 x) (* x (+ 1/2 (* 1/2 (/ 1 x)))))))
(* -1 x))))))))double code(double x, double y) {
double tmp;
if (x <= -450000000000.0) {
tmp = (((1.0 - y) * x) / x) / x;
} else if (x <= 8.2e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (y * ((-1.0 * (y * ((-1.0 * x) + (x * (0.5 + (0.5 * (1.0 / x))))))) - (-1.0 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-450000000000.0d0)) then
tmp = (((1.0d0 - y) * x) / x) / x
else if (x <= 8.2d-39) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (y * (((-1.0d0) * (y * (((-1.0d0) * x) + (x * (0.5d0 + (0.5d0 * (1.0d0 / x))))))) - ((-1.0d0) * x))))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -450000000000.0) {
tmp = (((1.0 - y) * x) / x) / x;
} else if (x <= 8.2e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (y * ((-1.0 * (y * ((-1.0 * x) + (x * (0.5 + (0.5 * (1.0 / x))))))) - (-1.0 * x))));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -450000000000.0: tmp = (((1.0 - y) * x) / x) / x elif x <= 8.2e-39: tmp = 1.0 / x else: tmp = 1.0 / (x + (y * ((-1.0 * (y * ((-1.0 * x) + (x * (0.5 + (0.5 * (1.0 / x))))))) - (-1.0 * x)))) return tmp
function code(x, y) tmp = 0.0 if (x <= -450000000000.0) tmp = Float64(Float64(Float64(Float64(1.0 - y) * x) / x) / x); elseif (x <= 8.2e-39) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(y * Float64(Float64(-1.0 * Float64(y * Float64(Float64(-1.0 * x) + Float64(x * Float64(0.5 + Float64(0.5 * Float64(1.0 / x))))))) - Float64(-1.0 * x))))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -450000000000.0) tmp = (((1.0 - y) * x) / x) / x; elseif (x <= 8.2e-39) tmp = 1.0 / x; else tmp = 1.0 / (x + (y * ((-1.0 * (y * ((-1.0 * x) + (x * (0.5 + (0.5 * (1.0 / x))))))) - (-1.0 * x)))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -450000000000], N[(N[(N[(N[(1 - y), $MachinePrecision] * x), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 98175495586721/11972621413014756705924586149611790497021399392059392], N[(1 / x), $MachinePrecision], N[(1 / N[(x + N[(y * N[(N[(-1 * N[(y * N[(N[(-1 * x), $MachinePrecision] + N[(x * N[(1/2 + N[(1/2 * N[(1 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -450000000000:\\
\;\;\;\;\frac{\frac{\left(1 - y\right) \cdot x}{x}}{x}\\
\mathbf{elif}\;x \leq \frac{98175495586721}{11972621413014756705924586149611790497021399392059392}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + y \cdot \left(-1 \cdot \left(y \cdot \left(-1 \cdot x + x \cdot \left(\frac{1}{2} + \frac{1}{2} \cdot \frac{1}{x}\right)\right)\right) - -1 \cdot x\right)}\\
\end{array}
if x < -4.5e11Initial program 78.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6459.6%
Applied rewrites59.6%
Applied rewrites65.9%
if -4.5e11 < x < 8.1999999999999996e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
if 8.1999999999999996e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6483.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites63.4%
(FPCore (x y)
:precision binary64
(if (<= x -450000000000)
(/ (/ (* (- 1 y) x) x) x)
(if (<=
x
8888474137022155/3064991081731777716716694054300618367237478244367204352)
(/ 1 x)
(/ 1 (+ x (* x y))))))double code(double x, double y) {
double tmp;
if (x <= -450000000000.0) {
tmp = (((1.0 - y) * x) / x) / x;
} else if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-450000000000.0d0)) then
tmp = (((1.0d0 - y) * x) / x) / x
else if (x <= 2.9d-39) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -450000000000.0) {
tmp = (((1.0 - y) * x) / x) / x;
} else if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -450000000000.0: tmp = (((1.0 - y) * x) / x) / x elif x <= 2.9e-39: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -450000000000.0) tmp = Float64(Float64(Float64(Float64(1.0 - y) * x) / x) / x); elseif (x <= 2.9e-39) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -450000000000.0) tmp = (((1.0 - y) * x) / x) / x; elseif (x <= 2.9e-39) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -450000000000], N[(N[(N[(N[(1 - y), $MachinePrecision] * x), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 8888474137022155/3064991081731777716716694054300618367237478244367204352], N[(1 / x), $MachinePrecision], N[(1 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -450000000000:\\
\;\;\;\;\frac{\frac{\left(1 - y\right) \cdot x}{x}}{x}\\
\mathbf{elif}\;x \leq \frac{8888474137022155}{3064991081731777716716694054300618367237478244367204352}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
if x < -4.5e11Initial program 78.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6459.6%
Applied rewrites59.6%
Applied rewrites65.9%
if -4.5e11 < x < 2.8999999999999999e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
if 2.8999999999999999e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6483.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6465.1%
Applied rewrites65.1%
(FPCore (x y)
:precision binary64
(if (<= x -510000000000)
(/ (+ 1 (* y (- (* y 1/2) 1))) x)
(if (<=
x
8888474137022155/3064991081731777716716694054300618367237478244367204352)
(/ 1 x)
(/ 1 (+ x (* x y))))))double code(double x, double y) {
double tmp;
if (x <= -510000000000.0) {
tmp = (1.0 + (y * ((y * 0.5) - 1.0))) / x;
} else if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-510000000000.0d0)) then
tmp = (1.0d0 + (y * ((y * 0.5d0) - 1.0d0))) / x
else if (x <= 2.9d-39) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -510000000000.0) {
tmp = (1.0 + (y * ((y * 0.5) - 1.0))) / x;
} else if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -510000000000.0: tmp = (1.0 + (y * ((y * 0.5) - 1.0))) / x elif x <= 2.9e-39: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= -510000000000.0) tmp = Float64(Float64(1.0 + Float64(y * Float64(Float64(y * 0.5) - 1.0))) / x); elseif (x <= 2.9e-39) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -510000000000.0) tmp = (1.0 + (y * ((y * 0.5) - 1.0))) / x; elseif (x <= 2.9e-39) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -510000000000], N[(N[(1 + N[(y * N[(N[(y * 1/2), $MachinePrecision] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 8888474137022155/3064991081731777716716694054300618367237478244367204352], N[(1 / x), $MachinePrecision], N[(1 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq -510000000000:\\
\;\;\;\;\frac{1 + y \cdot \left(y \cdot \frac{1}{2} - 1\right)}{x}\\
\mathbf{elif}\;x \leq \frac{8888474137022155}{3064991081731777716716694054300618367237478244367204352}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
if x < -5.1e11Initial program 78.0%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f6460.5%
Applied rewrites60.5%
Taylor expanded in x around inf
Applied rewrites65.3%
if -5.1e11 < x < 2.8999999999999999e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
if 2.8999999999999999e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6483.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6465.1%
Applied rewrites65.1%
(FPCore (x y)
:precision binary64
(if (<=
x
8888474137022155/3064991081731777716716694054300618367237478244367204352)
(/ 1 x)
(/ 1 (+ x (* x y)))))double code(double x, double y) {
double tmp;
if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 2.9d-39) then
tmp = 1.0d0 / x
else
tmp = 1.0d0 / (x + (x * y))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 2.9e-39) {
tmp = 1.0 / x;
} else {
tmp = 1.0 / (x + (x * y));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 2.9e-39: tmp = 1.0 / x else: tmp = 1.0 / (x + (x * y)) return tmp
function code(x, y) tmp = 0.0 if (x <= 2.9e-39) tmp = Float64(1.0 / x); else tmp = Float64(1.0 / Float64(x + Float64(x * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 2.9e-39) tmp = 1.0 / x; else tmp = 1.0 / (x + (x * y)); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 8888474137022155/3064991081731777716716694054300618367237478244367204352], N[(1 / x), $MachinePrecision], N[(1 / N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq \frac{8888474137022155}{3064991081731777716716694054300618367237478244367204352}:\\
\;\;\;\;\frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + x \cdot y}\\
\end{array}
if x < 2.8999999999999999e-39Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
if 2.8999999999999999e-39 < x Initial program 78.0%
Taylor expanded in x around inf
lower-*.f6483.3%
Applied rewrites83.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6483.3%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6483.3%
Applied rewrites83.3%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f6465.1%
Applied rewrites65.1%
(FPCore (x y) :precision binary64 (/ 1 x))
double code(double x, double y) {
return 1.0 / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / x
end function
public static double code(double x, double y) {
return 1.0 / x;
}
def code(x, y): return 1.0 / x
function code(x, y) return Float64(1.0 / x) end
function tmp = code(x, y) tmp = 1.0 / x; end
code[x_, y_] := N[(1 / x), $MachinePrecision]
\frac{1}{x}
Initial program 78.0%
Taylor expanded in x around 0
Applied rewrites75.7%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, F"
:precision binary64
(/ (exp (* x (log (/ x (+ x y))))) x))