
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 0.0)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_1 2.0)
(-
(+
1.0
(*
x
(fma x (- (* 0.5 (/ 1.0 (pow n 2.0))) (* 0.5 (/ 1.0 n))) (/ 1.0 n))))
t_0)
(/ (- (* -1.0 (log (/ 1.0 x))) (log x)) n)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_1 <= 2.0) {
tmp = (1.0 + (x * fma(x, ((0.5 * (1.0 / pow(n, 2.0))) - (0.5 * (1.0 / n))), (1.0 / n)))) - t_0;
} else {
tmp = ((-1.0 * log((1.0 / x))) - log(x)) / n;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_1 <= 2.0) tmp = Float64(Float64(1.0 + Float64(x * fma(x, Float64(Float64(0.5 * Float64(1.0 / (n ^ 2.0))) - Float64(0.5 * Float64(1.0 / n))), Float64(1.0 / n)))) - t_0); else tmp = Float64(Float64(Float64(-1.0 * log(Float64(1.0 / x))) - log(x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[(1.0 + N[(x * N[(x * N[(N[(0.5 * N[(1.0 / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\left(1 + x \cdot \mathsf{fma}\left(x, 0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{1}{n}\right)\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \log \left(\frac{1}{x}\right) - \log x}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 2Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites23.3%
if 2 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites30.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n)))))
(if (<= t_0 0.0)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_0 INFINITY) t_0 (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if t_0 <= 0.0: tmp = (math.log((1.0 + x)) - math.log(x)) / n elif t_0 <= math.inf: tmp = t_0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_0 <= Inf) tmp = t_0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); tmp = 0.0; if (t_0 <= 0.0) tmp = (log((1.0 + x)) - log(x)) / n; elseif (t_0 <= Inf) tmp = t_0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$0, Infinity], t$95$0, N[(1.0 - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 0.0)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_1 2.0)
(- (+ 1.0 (/ x n)) t_0)
(/ (- (* -1.0 (log (/ 1.0 x))) (log x)) n)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_1 <= 2.0) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((-1.0 * log((1.0 / x))) - log(x)) / n;
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if (t_1 <= 0.0d0) then
tmp = (log((1.0d0 + x)) - log(x)) / n
else if (t_1 <= 2.0d0) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (((-1.0d0) * log((1.0d0 / x))) - log(x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
} else if (t_1 <= 2.0) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((-1.0 * Math.log((1.0 / x))) - Math.log(x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= 0.0: tmp = (math.log((1.0 + x)) - math.log(x)) / n elif t_1 <= 2.0: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((-1.0 * math.log((1.0 / x))) - math.log(x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_1 <= 2.0) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(-1.0 * log(Float64(1.0 / x))) - log(x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= 0.0) tmp = (log((1.0 + x)) - log(x)) / n; elseif (t_1 <= 2.0) tmp = (1.0 + (x / n)) - t_0; else tmp = ((-1.0 * log((1.0 / x))) - log(x)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \log \left(\frac{1}{x}\right) - \log x}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 2Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites31.5%
if 2 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites30.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 0.0)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_1 2.0)
(- 1.0 t_0)
(/ (- (* -1.0 (log (/ 1.0 x))) (log x)) n)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_1 <= 2.0) {
tmp = 1.0 - t_0;
} else {
tmp = ((-1.0 * log((1.0 / x))) - log(x)) / n;
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = ((x + 1.0d0) ** (1.0d0 / n)) - t_0
if (t_1 <= 0.0d0) then
tmp = (log((1.0d0 + x)) - log(x)) / n
else if (t_1 <= 2.0d0) then
tmp = 1.0d0 - t_0
else
tmp = (((-1.0d0) * log((1.0d0 / x))) - log(x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
} else if (t_1 <= 2.0) {
tmp = 1.0 - t_0;
} else {
tmp = ((-1.0 * Math.log((1.0 / x))) - Math.log(x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= 0.0: tmp = (math.log((1.0 + x)) - math.log(x)) / n elif t_1 <= 2.0: tmp = 1.0 - t_0 else: tmp = ((-1.0 * math.log((1.0 / x))) - math.log(x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_1 <= 2.0) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(Float64(-1.0 * log(Float64(1.0 / x))) - log(x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= 0.0) tmp = (log((1.0 + x)) - log(x)) / n; elseif (t_1 <= 2.0) tmp = 1.0 - t_0; else tmp = ((-1.0 * log((1.0 / x))) - log(x)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(-1.0 * N[Log[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \log \left(\frac{1}{x}\right) - \log x}{n}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 2Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
if 2 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites30.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
(if (<= t_1 0.0)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_1 INFINITY) (- 1.0 t_0) (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_1 <= ((double) INFINITY)) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= 0.0) {
tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0 tmp = 0 if t_1 <= 0.0: tmp = (math.log((1.0 + x)) - math.log(x)) / n elif t_1 <= math.inf: tmp = 1.0 - t_0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= 0.0) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_1 <= Inf) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0; tmp = 0.0; if (t_1 <= 0.0) tmp = (log((1.0 + x)) - log(x)) / n; elseif (t_1 <= Inf) tmp = 1.0 - t_0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n)))))
(if (<= t_0 0.04)
(/ (- (log (+ 1.0 x)) (log x)) n)
(if (<= t_0 INFINITY) 1.0 (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.04) {
tmp = (log((1.0 + x)) - log(x)) / n;
} else if (t_0 <= ((double) INFINITY)) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.04) {
tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if t_0 <= 0.04: tmp = (math.log((1.0 + x)) - math.log(x)) / n elif t_0 <= math.inf: tmp = 1.0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (t_0 <= 0.04) tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n); elseif (t_0 <= Inf) tmp = 1.0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); tmp = 0.0; if (t_0 <= 0.04) tmp = (log((1.0 + x)) - log(x)) / n; elseif (t_0 <= Inf) tmp = 1.0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.04], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$0, Infinity], 1.0, N[(1.0 - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;t\_0 \leq 0.04:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0400000000000000008Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
if 0.0400000000000000008 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x (log x)) n)))
(if (<= x 3.5e-272)
t_0
(if (<= x 5e-227)
(/ (- 1.0 (* 0.5 (/ 1.0 x))) (* n x))
(if (<= x 1.5e-68)
t_0
(if (<= x 10.2) (- (exp (/ 1.0 n)) (/ 1.0 n)) (- 1.0 1.0)))))))
double code(double x, double n) {
double t_0 = (x - log(x)) / n;
double tmp;
if (x <= 3.5e-272) {
tmp = t_0;
} else if (x <= 5e-227) {
tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x);
} else if (x <= 1.5e-68) {
tmp = t_0;
} else if (x <= 10.2) {
tmp = exp((1.0 / n)) - (1.0 / n);
} else {
tmp = 1.0 - 1.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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x - log(x)) / n
if (x <= 3.5d-272) then
tmp = t_0
else if (x <= 5d-227) then
tmp = (1.0d0 - (0.5d0 * (1.0d0 / x))) / (n * x)
else if (x <= 1.5d-68) then
tmp = t_0
else if (x <= 10.2d0) then
tmp = exp((1.0d0 / n)) - (1.0d0 / n)
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - Math.log(x)) / n;
double tmp;
if (x <= 3.5e-272) {
tmp = t_0;
} else if (x <= 5e-227) {
tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x);
} else if (x <= 1.5e-68) {
tmp = t_0;
} else if (x <= 10.2) {
tmp = Math.exp((1.0 / n)) - (1.0 / n);
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = (x - math.log(x)) / n tmp = 0 if x <= 3.5e-272: tmp = t_0 elif x <= 5e-227: tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x) elif x <= 1.5e-68: tmp = t_0 elif x <= 10.2: tmp = math.exp((1.0 / n)) - (1.0 / n) else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64(Float64(x - log(x)) / n) tmp = 0.0 if (x <= 3.5e-272) tmp = t_0; elseif (x <= 5e-227) tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(1.0 / x))) / Float64(n * x)); elseif (x <= 1.5e-68) tmp = t_0; elseif (x <= 10.2) tmp = Float64(exp(Float64(1.0 / n)) - Float64(1.0 / n)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = (x - log(x)) / n; tmp = 0.0; if (x <= 3.5e-272) tmp = t_0; elseif (x <= 5e-227) tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x); elseif (x <= 1.5e-68) tmp = t_0; elseif (x <= 10.2) tmp = exp((1.0 / n)) - (1.0 / n); else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 3.5e-272], t$95$0, If[LessEqual[x, 5e-227], N[(N[(1.0 - N[(0.5 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.5e-68], t$95$0, If[LessEqual[x, 10.2], N[(N[Exp[N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(1.0 / n), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;x \leq 3.5 \cdot 10^{-272}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-227}:\\
\;\;\;\;\frac{1 - 0.5 \cdot \frac{1}{x}}{n \cdot x}\\
\mathbf{elif}\;x \leq 1.5 \cdot 10^{-68}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 10.2:\\
\;\;\;\;e^{\frac{1}{n}} - \frac{1}{n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 3.4999999999999997e-272 or 4.99999999999999961e-227 < x < 1.5e-68Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Applied rewrites30.9%
if 3.4999999999999997e-272 < x < 4.99999999999999961e-227Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites28.1%
Taylor expanded in n around 0
Applied rewrites27.7%
if 1.5e-68 < x < 10.199999999999999Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites19.3%
Applied rewrites9.7%
if 10.199999999999999 < x Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x (log x)) n)))
(if (<= x 3.5e-272)
t_0
(if (<= x 5e-227)
(/ (- 1.0 (* 0.5 (/ 1.0 x))) (* n x))
(if (<= x 25000.0) t_0 (- 1.0 1.0))))))
double code(double x, double n) {
double t_0 = (x - log(x)) / n;
double tmp;
if (x <= 3.5e-272) {
tmp = t_0;
} else if (x <= 5e-227) {
tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x);
} else if (x <= 25000.0) {
tmp = t_0;
} else {
tmp = 1.0 - 1.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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x - log(x)) / n
if (x <= 3.5d-272) then
tmp = t_0
else if (x <= 5d-227) then
tmp = (1.0d0 - (0.5d0 * (1.0d0 / x))) / (n * x)
else if (x <= 25000.0d0) then
tmp = t_0
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - Math.log(x)) / n;
double tmp;
if (x <= 3.5e-272) {
tmp = t_0;
} else if (x <= 5e-227) {
tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x);
} else if (x <= 25000.0) {
tmp = t_0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = (x - math.log(x)) / n tmp = 0 if x <= 3.5e-272: tmp = t_0 elif x <= 5e-227: tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x) elif x <= 25000.0: tmp = t_0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64(Float64(x - log(x)) / n) tmp = 0.0 if (x <= 3.5e-272) tmp = t_0; elseif (x <= 5e-227) tmp = Float64(Float64(1.0 - Float64(0.5 * Float64(1.0 / x))) / Float64(n * x)); elseif (x <= 25000.0) tmp = t_0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = (x - log(x)) / n; tmp = 0.0; if (x <= 3.5e-272) tmp = t_0; elseif (x <= 5e-227) tmp = (1.0 - (0.5 * (1.0 / x))) / (n * x); elseif (x <= 25000.0) tmp = t_0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 3.5e-272], t$95$0, If[LessEqual[x, 5e-227], N[(N[(1.0 - N[(0.5 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 25000.0], t$95$0, N[(1.0 - 1.0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;x \leq 3.5 \cdot 10^{-272}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-227}:\\
\;\;\;\;\frac{1 - 0.5 \cdot \frac{1}{x}}{n \cdot x}\\
\mathbf{elif}\;x \leq 25000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 3.4999999999999997e-272 or 4.99999999999999961e-227 < x < 25000Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Applied rewrites30.9%
if 3.4999999999999997e-272 < x < 4.99999999999999961e-227Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites28.1%
Taylor expanded in n around 0
Applied rewrites27.7%
if 25000 < x Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 (if (<= x 1.5e-224) 1.0 (if (<= x 25000.0) (/ (- x (log x)) n) (- 1.0 1.0))))
double code(double x, double n) {
double tmp;
if (x <= 1.5e-224) {
tmp = 1.0;
} else if (x <= 25000.0) {
tmp = (x - log(x)) / n;
} else {
tmp = 1.0 - 1.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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.5d-224) then
tmp = 1.0d0
else if (x <= 25000.0d0) then
tmp = (x - log(x)) / n
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.5e-224) {
tmp = 1.0;
} else if (x <= 25000.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.5e-224: tmp = 1.0 elif x <= 25000.0: tmp = (x - math.log(x)) / n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.5e-224) tmp = 1.0; elseif (x <= 25000.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.5e-224) tmp = 1.0; elseif (x <= 25000.0) tmp = (x - log(x)) / n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.5e-224], 1.0, If[LessEqual[x, 25000.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{-224}:\\
\;\;\;\;1\\
\mathbf{elif}\;x \leq 25000:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.49999999999999991e-224Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if 1.49999999999999991e-224 < x < 25000Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Applied rewrites30.9%
if 25000 < x Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 (let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))) (if (<= t_0 0.0) (/ (/ 1.0 x) n) (if (<= t_0 INFINITY) 1.0 (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 / x) / n;
} else if (t_0 <= ((double) INFINITY)) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 / x) / n;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if t_0 <= 0.0: tmp = (1.0 / x) / n elif t_0 <= math.inf: tmp = 1.0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(1.0 / x) / n); elseif (t_0 <= Inf) tmp = 1.0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); tmp = 0.0; if (t_0 <= 0.0) tmp = (1.0 / x) / n; elseif (t_0 <= Inf) tmp = 1.0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[t$95$0, Infinity], 1.0, N[(1.0 - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites40.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 (let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))) (if (<= t_0 0.0) (/ (/ 1.0 n) x) (if (<= t_0 INFINITY) 1.0 (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 / n) / x;
} else if (t_0 <= ((double) INFINITY)) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = (1.0 / n) / x;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if t_0 <= 0.0: tmp = (1.0 / n) / x elif t_0 <= math.inf: tmp = 1.0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(1.0 / n) / x); elseif (t_0 <= Inf) tmp = 1.0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); tmp = 0.0; if (t_0 <= 0.0) tmp = (1.0 / n) / x; elseif (t_0 <= Inf) tmp = 1.0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, Infinity], 1.0, N[(1.0 - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites28.1%
Taylor expanded in x around inf
Applied rewrites40.3%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 (let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))) (if (<= t_0 0.0) (/ 1.0 (* n x)) (if (<= t_0 INFINITY) 1.0 (- 1.0 1.0)))))
double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = 1.0 / (n * x);
} else if (t_0 <= ((double) INFINITY)) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
double tmp;
if (t_0 <= 0.0) {
tmp = 1.0 / (n * x);
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) tmp = 0 if t_0 <= 0.0: tmp = 1.0 / (n * x) elif t_0 <= math.inf: tmp = 1.0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(1.0 / Float64(n * x)); elseif (t_0 <= Inf) tmp = 1.0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); tmp = 0.0; if (t_0 <= 0.0) tmp = 1.0 / (n * x); elseif (t_0 <= Inf) tmp = 1.0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], 1.0, N[(1.0 - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites58.3%
Taylor expanded in x around inf
Applied rewrites39.8%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < +inf.0Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if +inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 (if (<= x 1.45e-18) 1.0 (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if (x <= 1.45e-18) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.45d-18) then
tmp = 1.0d0
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.45e-18) {
tmp = 1.0;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.45e-18: tmp = 1.0 else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.45e-18) tmp = 1.0; else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.45e-18) tmp = 1.0; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.45e-18], 1.0, N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.45 \cdot 10^{-18}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if x < 1.45e-18Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
if 1.45e-18 < x Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.8%
Applied rewrites30.6%
(FPCore (x n) :precision binary64 1.0)
double code(double x, double n) {
return 1.0;
}
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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0
end function
public static double code(double x, double n) {
return 1.0;
}
def code(x, n): return 1.0
function code(x, n) return 1.0 end
function tmp = code(x, n) tmp = 1.0; end
code[x_, n_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 53.5%
Taylor expanded in n around inf
Applied rewrites64.3%
Applied rewrites7.9%
Applied rewrites9.8%
herbie shell --seed 2025159
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))