
(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]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
Herbie found 18 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]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (- x -1.0))))
(if (<= x 33000.0)
(/
(+
(/
(fma
-0.16666666666666666
(/ (- (pow t_0 3.0) (pow (log x) 3.0)) n)
(- (* 0.5 (- (* t_0 t_0) (* (log x) (log x))))))
n)
(log (/ x (- x -1.0))))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x))))double code(double x, double n) {
double t_0 = log((x - -1.0));
double tmp;
if (x <= 33000.0) {
tmp = ((fma(-0.16666666666666666, ((pow(t_0, 3.0) - pow(log(x), 3.0)) / n), -(0.5 * ((t_0 * t_0) - (log(x) * log(x))))) / n) + log((x / (x - -1.0)))) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) t_0 = log(Float64(x - -1.0)) tmp = 0.0 if (x <= 33000.0) tmp = Float64(Float64(Float64(fma(-0.16666666666666666, Float64(Float64((t_0 ^ 3.0) - (log(x) ^ 3.0)) / n), Float64(-Float64(0.5 * Float64(Float64(t_0 * t_0) - Float64(log(x) * log(x)))))) / n) + log(Float64(x / Float64(x - -1.0)))) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 33000.0], N[(N[(N[(N[(-0.16666666666666666 * N[(N[(N[Power[t$95$0, 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + (-N[(0.5 * N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / n), $MachinePrecision] + N[Log[N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
t_0 := \log \left(x - -1\right)\\
\mathbf{if}\;x \leq 33000:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(-0.16666666666666666, \frac{{t\_0}^{3} - {\log x}^{3}}{n}, -0.5 \cdot \left(t\_0 \cdot t\_0 - \log x \cdot \log x\right)\right)}{n} + \log \left(\frac{x}{x - -1}\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
if x < 33000Initial program 53.5%
Taylor expanded in n around -inf
Applied rewrites73.4%
Applied rewrites73.5%
if 33000 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
(FPCore (x n)
:precision binary64
(if (<= x 33000.0)
(/
(-
(log (/ x (- x -1.0)))
(/
(fma
(* 0.5 (log (* (- x -1.0) x)))
(log (/ (- x -1.0) x))
(*
(/ (- (pow (log (- x -1.0)) 3.0) (pow (log x) 3.0)) n)
0.16666666666666666))
n))
(- n))
(/ (/ (pow x (/ 1.0 n)) n) x)))double code(double x, double n) {
double tmp;
if (x <= 33000.0) {
tmp = (log((x / (x - -1.0))) - (fma((0.5 * log(((x - -1.0) * x))), log(((x - -1.0) / x)), (((pow(log((x - -1.0)), 3.0) - pow(log(x), 3.0)) / n) * 0.16666666666666666)) / n)) / -n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 33000.0) tmp = Float64(Float64(log(Float64(x / Float64(x - -1.0))) - Float64(fma(Float64(0.5 * log(Float64(Float64(x - -1.0) * x))), log(Float64(Float64(x - -1.0) / x)), Float64(Float64(Float64((log(Float64(x - -1.0)) ^ 3.0) - (log(x) ^ 3.0)) / n) * 0.16666666666666666)) / n)) / Float64(-n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 33000.0], N[(N[(N[Log[N[(x / N[(x - -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(0.5 * N[Log[N[(N[(x - -1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(N[Power[N[Log[N[(x - -1.0), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 33000:\\
\;\;\;\;\frac{\log \left(\frac{x}{x - -1}\right) - \frac{\mathsf{fma}\left(0.5 \cdot \log \left(\left(x - -1\right) \cdot x\right), \log \left(\frac{x - -1}{x}\right), \frac{{\log \left(x - -1\right)}^{3} - {\log x}^{3}}{n} \cdot 0.16666666666666666\right)}{n}}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
if x < 33000Initial program 53.5%
Taylor expanded in n around -inf
Applied rewrites73.4%
Applied rewrites73.5%
Applied rewrites55.5%
if 33000 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (/ (- x -1.0) x))))
(if (<= x 33000.0)
(/
(-
t_0
(/
(fma
(* -0.5 (log (* (- x -1.0) x)))
t_0
(*
(/ (- (pow (log (- x -1.0)) 3.0) (pow (log x) 3.0)) n)
-0.16666666666666666))
n))
n)
(/ (/ (pow x (/ 1.0 n)) n) x))))double code(double x, double n) {
double t_0 = log(((x - -1.0) / x));
double tmp;
if (x <= 33000.0) {
tmp = (t_0 - (fma((-0.5 * log(((x - -1.0) * x))), t_0, (((pow(log((x - -1.0)), 3.0) - pow(log(x), 3.0)) / n) * -0.16666666666666666)) / n)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) t_0 = log(Float64(Float64(x - -1.0) / x)) tmp = 0.0 if (x <= 33000.0) tmp = Float64(Float64(t_0 - Float64(fma(Float64(-0.5 * log(Float64(Float64(x - -1.0) * x))), t_0, Float64(Float64(Float64((log(Float64(x - -1.0)) ^ 3.0) - (log(x) ^ 3.0)) / n) * -0.16666666666666666)) / n)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 33000.0], N[(N[(t$95$0 - N[(N[(N[(-0.5 * N[Log[N[(N[(x - -1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0 + N[(N[(N[(N[Power[N[Log[N[(x - -1.0), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
t_0 := \log \left(\frac{x - -1}{x}\right)\\
\mathbf{if}\;x \leq 33000:\\
\;\;\;\;\frac{t\_0 - \frac{\mathsf{fma}\left(-0.5 \cdot \log \left(\left(x - -1\right) \cdot x\right), t\_0, \frac{{\log \left(x - -1\right)}^{3} - {\log x}^{3}}{n} \cdot -0.16666666666666666\right)}{n}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
if x < 33000Initial program 53.5%
Taylor expanded in n around -inf
Applied rewrites73.4%
Applied rewrites73.5%
Applied rewrites55.5%
if 33000 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
(FPCore (x n)
:precision binary64
(if (<= x 0.78)
(/
(-
(- (log x))
(/
(fma
(* 0.5 (log x))
(log x)
(* 0.16666666666666666 (/ (pow (log x) 3.0) n)))
n))
n)
(/ (/ (pow x (/ 1.0 n)) n) x)))double code(double x, double n) {
double tmp;
if (x <= 0.78) {
tmp = (-log(x) - (fma((0.5 * log(x)), log(x), (0.16666666666666666 * (pow(log(x), 3.0) / n))) / n)) / n;
} else {
tmp = (pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 0.78) tmp = Float64(Float64(Float64(-log(x)) - Float64(fma(Float64(0.5 * log(x)), log(x), Float64(0.16666666666666666 * Float64((log(x) ^ 3.0) / n))) / n)) / n); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[x, 0.78], N[(N[((-N[Log[x], $MachinePrecision]) - N[(N[(N[(0.5 * N[Log[x], $MachinePrecision]), $MachinePrecision] * N[Log[x], $MachinePrecision] + N[(0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 0.78:\\
\;\;\;\;\frac{\left(-\log x\right) - \frac{\mathsf{fma}\left(0.5 \cdot \log x, \log x, 0.16666666666666666 \cdot \frac{{\log x}^{3}}{n}\right)}{n}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
if x < 0.78000000000000003Initial program 53.5%
Taylor expanded in n around -inf
Applied rewrites73.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites45.5%
lift-*.f64N/A
mul-1-negN/A
Applied rewrites45.5%
if 0.78000000000000003 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x -1.0) x)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(* (/ t_1 n) (/ 1.0 x))
(if (<= (/ 1.0 n) 1.5e-11)
(/ (log t_0) n)
(if (<= (/ 1.0 n) 2e+134)
(- (pow (- x -1.0) (/ 1.0 n)) t_1)
(log (pow t_0 (/ 1.0 n))))))))double code(double x, double n) {
double t_0 = (x - -1.0) / x;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_1 / n) * (1.0 / x);
} else if ((1.0 / n) <= 1.5e-11) {
tmp = log(t_0) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = pow((x - -1.0), (1.0 / n)) - t_1;
} else {
tmp = log(pow(t_0, (1.0 / 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)) / x
t_1 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-18)) then
tmp = (t_1 / n) * (1.0d0 / x)
else if ((1.0d0 / n) <= 1.5d-11) then
tmp = log(t_0) / n
else if ((1.0d0 / n) <= 2d+134) then
tmp = ((x - (-1.0d0)) ** (1.0d0 / n)) - t_1
else
tmp = log((t_0 ** (1.0d0 / n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - -1.0) / x;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_1 / n) * (1.0 / x);
} else if ((1.0 / n) <= 1.5e-11) {
tmp = Math.log(t_0) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = Math.pow((x - -1.0), (1.0 / n)) - t_1;
} else {
tmp = Math.log(Math.pow(t_0, (1.0 / n)));
}
return tmp;
}
def code(x, n): t_0 = (x - -1.0) / x t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_1 / n) * (1.0 / x) elif (1.0 / n) <= 1.5e-11: tmp = math.log(t_0) / n elif (1.0 / n) <= 2e+134: tmp = math.pow((x - -1.0), (1.0 / n)) - t_1 else: tmp = math.log(math.pow(t_0, (1.0 / n))) return tmp
function code(x, n) t_0 = Float64(Float64(x - -1.0) / x) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_1 / n) * Float64(1.0 / x)); elseif (Float64(1.0 / n) <= 1.5e-11) tmp = Float64(log(t_0) / n); elseif (Float64(1.0 / n) <= 2e+134) tmp = Float64((Float64(x - -1.0) ^ Float64(1.0 / n)) - t_1); else tmp = log((t_0 ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) t_0 = (x - -1.0) / x; t_1 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-18) tmp = (t_1 / n) * (1.0 / x); elseif ((1.0 / n) <= 1.5e-11) tmp = log(t_0) / n; elseif ((1.0 / n) <= 2e+134) tmp = ((x - -1.0) ^ (1.0 / n)) - t_1; else tmp = log((t_0 ^ (1.0 / n))); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[(t$95$1 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.5e-11], N[(N[Log[t$95$0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+134], N[(N[Power[N[(x - -1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision], N[Log[N[Power[t$95$0, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{x - -1}{x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{t\_1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\log t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+134}:\\
\;\;\;\;{\left(x - -1\right)}^{\left(\frac{1}{n}\right)} - t\_1\\
\mathbf{else}:\\
\;\;\;\;\log \left({t\_0}^{\left(\frac{1}{n}\right)}\right)\\
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
Applied rewrites58.6%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 1.5e-11Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 1.5e-11 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999984e134Initial program 53.5%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6453.5%
Applied rewrites53.5%
if 1.99999999999999984e134 < (/.f64 #s(literal 1 binary64) n) Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
log-pow-revN/A
lower-log.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6451.2%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6451.2%
Applied rewrites51.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (- x -1.0) x)) (t_1 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(* (/ t_1 n) (/ 1.0 x))
(if (<= (/ 1.0 n) 2.0)
(/ (log t_0) n)
(if (<= (/ 1.0 n) 2e+134)
(- (+ 1.0 (/ x n)) t_1)
(log (pow t_0 (/ 1.0 n))))))))double code(double x, double n) {
double t_0 = (x - -1.0) / x;
double t_1 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_1 / n) * (1.0 / x);
} else if ((1.0 / n) <= 2.0) {
tmp = log(t_0) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = log(pow(t_0, (1.0 / 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)) / x
t_1 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-18)) then
tmp = (t_1 / n) * (1.0d0 / x)
else if ((1.0d0 / n) <= 2.0d0) then
tmp = log(t_0) / n
else if ((1.0d0 / n) <= 2d+134) then
tmp = (1.0d0 + (x / n)) - t_1
else
tmp = log((t_0 ** (1.0d0 / n)))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x - -1.0) / x;
double t_1 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_1 / n) * (1.0 / x);
} else if ((1.0 / n) <= 2.0) {
tmp = Math.log(t_0) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_1;
} else {
tmp = Math.log(Math.pow(t_0, (1.0 / n)));
}
return tmp;
}
def code(x, n): t_0 = (x - -1.0) / x t_1 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_1 / n) * (1.0 / x) elif (1.0 / n) <= 2.0: tmp = math.log(t_0) / n elif (1.0 / n) <= 2e+134: tmp = (1.0 + (x / n)) - t_1 else: tmp = math.log(math.pow(t_0, (1.0 / n))) return tmp
function code(x, n) t_0 = Float64(Float64(x - -1.0) / x) t_1 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_1 / n) * Float64(1.0 / x)); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(log(t_0) / n); elseif (Float64(1.0 / n) <= 2e+134) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1); else tmp = log((t_0 ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) t_0 = (x - -1.0) / x; t_1 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-18) tmp = (t_1 / n) * (1.0 / x); elseif ((1.0 / n) <= 2.0) tmp = log(t_0) / n; elseif ((1.0 / n) <= 2e+134) tmp = (1.0 + (x / n)) - t_1; else tmp = log((t_0 ^ (1.0 / n))); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[(t$95$1 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Log[t$95$0], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+134], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], N[Log[N[Power[t$95$0, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{x - -1}{x}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{t\_1}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{\log t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+134}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;\log \left({t\_0}^{\left(\frac{1}{n}\right)}\right)\\
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
Applied rewrites58.6%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999984e134Initial program 53.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.3%
Applied rewrites31.3%
if 1.99999999999999984e134 < (/.f64 #s(literal 1 binary64) n) Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
log-pow-revN/A
lower-log.f64N/A
lower-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6451.2%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6451.2%
Applied rewrites51.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(* (/ t_0 n) (/ 1.0 x))
(if (<= (/ 1.0 n) 2.0)
(/ (log (/ (- x -1.0) x)) n)
(if (<= (/ 1.0 n) 2e+134)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ n x) (* n n)))))))double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) * (1.0 / x);
} else if ((1.0 / n) <= 2.0) {
tmp = log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * 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) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-18)) then
tmp = (t_0 / n) * (1.0d0 / x)
else if ((1.0d0 / n) <= 2.0d0) then
tmp = log(((x - (-1.0d0)) / x)) / n
else if ((1.0d0 / n) <= 2d+134) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (n / x) / (n * 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 tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) * (1.0 / x);
} else if ((1.0 / n) <= 2.0) {
tmp = Math.log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_0 / n) * (1.0 / x) elif (1.0 / n) <= 2.0: tmp = math.log(((x - -1.0) / x)) / n elif (1.0 / n) <= 2e+134: tmp = (1.0 + (x / n)) - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_0 / n) * Float64(1.0 / x)); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(log(Float64(Float64(x - -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+134) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-18) tmp = (t_0 / n) * (1.0 / x); elseif ((1.0 / n) <= 2.0) tmp = log(((x - -1.0) / x)) / n; elseif ((1.0 / n) <= 2e+134) tmp = (1.0 + (x / n)) - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+134], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{t\_0}{n} \cdot \frac{1}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{\log \left(\frac{x - -1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+134}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
Applied rewrites58.6%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999984e134Initial program 53.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.3%
Applied rewrites31.3%
if 1.99999999999999984e134 < (/.f64 #s(literal 1 binary64) n) Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2.0)
(/ (log (/ (- x -1.0) x)) n)
(if (<= (/ 1.0 n) 2e+134)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ n x) (* n n)))))))double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2.0) {
tmp = log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * 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) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-18)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2.0d0) then
tmp = log(((x - (-1.0d0)) / x)) / n
else if ((1.0d0 / n) <= 2d+134) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (n / x) / (n * 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 tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2.0) {
tmp = Math.log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_0 / n) / x elif (1.0 / n) <= 2.0: tmp = math.log(((x - -1.0) / x)) / n elif (1.0 / n) <= 2e+134: tmp = (1.0 + (x / n)) - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(log(Float64(Float64(x - -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+134) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-18) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2.0) tmp = log(((x - -1.0) / x)) / n; elseif ((1.0 / n) <= 2e+134) tmp = (1.0 + (x / n)) - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+134], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{\log \left(\frac{x - -1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+134}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999984e134Initial program 53.5%
Taylor expanded in x around 0
lower-+.f64N/A
lower-/.f6431.3%
Applied rewrites31.3%
if 1.99999999999999984e134 < (/.f64 #s(literal 1 binary64) n) Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-18)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 2.0)
(/ (log (/ (- x -1.0) x)) n)
(if (<= (/ 1.0 n) 2e+134) (- 1.0 t_0) (/ (/ n x) (* n n)))))))double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2.0) {
tmp = log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * 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) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-18)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 2.0d0) then
tmp = log(((x - (-1.0d0)) / x)) / n
else if ((1.0d0 / n) <= 2d+134) then
tmp = 1.0d0 - t_0
else
tmp = (n / x) / (n * 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 tmp;
if ((1.0 / n) <= -5e-18) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 2.0) {
tmp = Math.log(((x - -1.0) / x)) / n;
} else if ((1.0 / n) <= 2e+134) {
tmp = 1.0 - t_0;
} else {
tmp = (n / x) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-18: tmp = (t_0 / n) / x elif (1.0 / n) <= 2.0: tmp = math.log(((x - -1.0) / x)) / n elif (1.0 / n) <= 2e+134: tmp = 1.0 - t_0 else: tmp = (n / x) / (n * n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-18) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(log(Float64(Float64(x - -1.0) / x)) / n); elseif (Float64(1.0 / n) <= 2e+134) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(n / x) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-18) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 2.0) tmp = log(((x - -1.0) / x)) / n; elseif ((1.0 / n) <= 2e+134) tmp = 1.0 - t_0; else tmp = (n / x) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-18], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+134], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-18}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{\log \left(\frac{x - -1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+134}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000036e-18Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
if -5.00000000000000036e-18 < (/.f64 #s(literal 1 binary64) n) < 2Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999984e134Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.9%
if 1.99999999999999984e134 < (/.f64 #s(literal 1 binary64) n) Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.8%
(FPCore (x n) :precision binary64 (if (<= x 0.42) (* -1.0 (/ (- (* 0.5 (/ (pow (log x) 2.0) n)) (* -1.0 (log x))) n)) (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.42) {
tmp = -1.0 * (((0.5 * (pow(log(x), 2.0) / n)) - (-1.0 * log(x))) / n);
} else {
tmp = (pow(x, (1.0 / n)) / n) / 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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.42d0) then
tmp = (-1.0d0) * (((0.5d0 * ((log(x) ** 2.0d0) / n)) - ((-1.0d0) * log(x))) / n)
else
tmp = ((x ** (1.0d0 / n)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.42) {
tmp = -1.0 * (((0.5 * (Math.pow(Math.log(x), 2.0) / n)) - (-1.0 * Math.log(x))) / n);
} else {
tmp = (Math.pow(x, (1.0 / n)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.42: tmp = -1.0 * (((0.5 * (math.pow(math.log(x), 2.0) / n)) - (-1.0 * math.log(x))) / n) else: tmp = (math.pow(x, (1.0 / n)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.42) tmp = Float64(-1.0 * Float64(Float64(Float64(0.5 * Float64((log(x) ^ 2.0) / n)) - Float64(-1.0 * log(x))) / n)); else tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.42) tmp = -1.0 * (((0.5 * ((log(x) ^ 2.0) / n)) - (-1.0 * log(x))) / n); else tmp = ((x ^ (1.0 / n)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.42], N[(-1.0 * N[(N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x \leq 0.42:\\
\;\;\;\;-1 \cdot \frac{0.5 \cdot \frac{{\log x}^{2}}{n} - -1 \cdot \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\
\end{array}
if x < 0.419999999999999984Initial program 53.5%
Taylor expanded in n around -inf
Applied rewrites73.4%
Taylor expanded in x around 0
lower-*.f64N/A
lower-/.f64N/A
Applied rewrites45.5%
Taylor expanded in n around inf
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
lower-log.f6437.4%
Applied rewrites37.4%
if 0.419999999999999984 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Applied rewrites58.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (log (/ (- x -1.0) x)))
(t_1 (pow x (/ 1.0 n)))
(t_2 (- (pow (+ x 1.0) (/ 1.0 n)) t_1)))
(if (<= t_2 -5e-7)
(- 1.0 t_1)
(if (<= t_2 2e-9) (/ t_0 n) (/ (* n t_0) (* n n))))))double code(double x, double n) {
double t_0 = log(((x - -1.0) / x));
double t_1 = pow(x, (1.0 / n));
double t_2 = pow((x + 1.0), (1.0 / n)) - t_1;
double tmp;
if (t_2 <= -5e-7) {
tmp = 1.0 - t_1;
} else if (t_2 <= 2e-9) {
tmp = t_0 / n;
} else {
tmp = (n * t_0) / (n * 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) :: t_2
real(8) :: tmp
t_0 = log(((x - (-1.0d0)) / x))
t_1 = x ** (1.0d0 / n)
t_2 = ((x + 1.0d0) ** (1.0d0 / n)) - t_1
if (t_2 <= (-5d-7)) then
tmp = 1.0d0 - t_1
else if (t_2 <= 2d-9) then
tmp = t_0 / n
else
tmp = (n * t_0) / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((x - -1.0) / x));
double t_1 = Math.pow(x, (1.0 / n));
double t_2 = Math.pow((x + 1.0), (1.0 / n)) - t_1;
double tmp;
if (t_2 <= -5e-7) {
tmp = 1.0 - t_1;
} else if (t_2 <= 2e-9) {
tmp = t_0 / n;
} else {
tmp = (n * t_0) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.log(((x - -1.0) / x)) t_1 = math.pow(x, (1.0 / n)) t_2 = math.pow((x + 1.0), (1.0 / n)) - t_1 tmp = 0 if t_2 <= -5e-7: tmp = 1.0 - t_1 elif t_2 <= 2e-9: tmp = t_0 / n else: tmp = (n * t_0) / (n * n) return tmp
function code(x, n) t_0 = log(Float64(Float64(x - -1.0) / x)) t_1 = x ^ Float64(1.0 / n) t_2 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_1) tmp = 0.0 if (t_2 <= -5e-7) tmp = Float64(1.0 - t_1); elseif (t_2 <= 2e-9) tmp = Float64(t_0 / n); else tmp = Float64(Float64(n * t_0) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = log(((x - -1.0) / x)); t_1 = x ^ (1.0 / n); t_2 = ((x + 1.0) ^ (1.0 / n)) - t_1; tmp = 0.0; if (t_2 <= -5e-7) tmp = 1.0 - t_1; elseif (t_2 <= 2e-9) tmp = t_0 / n; else tmp = (n * t_0) / (n * n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-7], N[(1.0 - t$95$1), $MachinePrecision], If[LessEqual[t$95$2, 2e-9], N[(t$95$0 / n), $MachinePrecision], N[(N[(n * t$95$0), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \log \left(\frac{x - -1}{x}\right)\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_1\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-7}:\\
\;\;\;\;1 - t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t\_0}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot t\_0}{n \cdot n}\\
\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))) < -4.99999999999999977e-7Initial program 53.5%
Taylor expanded in x around 0
Applied rewrites38.9%
if -4.99999999999999977e-7 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 2.00000000000000012e-9Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2.00000000000000012e-9 < (-.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
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
lift-log.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
+-commutativeN/A
lift-log.f64N/A
lower-*.f64N/A
diff-logN/A
lower-log.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6449.4%
Applied rewrites49.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n)))))
(if (<= t_0 (- INFINITY))
(/ (/ n x) (* n n))
(if (<= t_0 1e-7)
(/ (log (/ (- x -1.0) x)) n)
(/ (* -1.0 (* n (log x))) (* n n))))))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 <= -((double) INFINITY)) {
tmp = (n / x) / (n * n);
} else if (t_0 <= 1e-7) {
tmp = log(((x - -1.0) / x)) / n;
} else {
tmp = (-1.0 * (n * log(x))) / (n * n);
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = (n / x) / (n * n);
} else if (t_0 <= 1e-7) {
tmp = Math.log(((x - -1.0) / x)) / n;
} else {
tmp = (-1.0 * (n * Math.log(x))) / (n * n);
}
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 <= -math.inf: tmp = (n / x) / (n * n) elif t_0 <= 1e-7: tmp = math.log(((x - -1.0) / x)) / n else: tmp = (-1.0 * (n * math.log(x))) / (n * n) 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 <= Float64(-Inf)) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif (t_0 <= 1e-7) tmp = Float64(log(Float64(Float64(x - -1.0) / x)) / n); else tmp = Float64(Float64(-1.0 * Float64(n * log(x))) / Float64(n * n)); 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 <= -Inf) tmp = (n / x) / (n * n); elseif (t_0 <= 1e-7) tmp = log(((x - -1.0) / x)) / n; else tmp = (-1.0 * (n * log(x))) / (n * n); 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, (-Infinity)], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-7], N[(N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(-1.0 * N[(n * N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]
\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 -\infty:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x - -1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1 \cdot \left(n \cdot \log x\right)}{n \cdot n}\\
\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))) < -inf.0Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.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))) < 9.9999999999999995e-8Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 9.9999999999999995e-8 < (-.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
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around 0
lower-*.f64N/A
lower-*.f64N/A
lower-log.f6437.8%
Applied rewrites37.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(t_1 (log (/ (- x -1.0) x))))
(if (<= t_0 (- INFINITY))
(/ (/ n x) (* n n))
(if (<= t_0 2e-9) (/ t_1 n) (/ (* n t_1) (* n n))))))double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double t_1 = log(((x - -1.0) / x));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (n / x) / (n * n);
} else if (t_0 <= 2e-9) {
tmp = t_1 / n;
} else {
tmp = (n * t_1) / (n * n);
}
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 t_1 = Math.log(((x - -1.0) / x));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (n / x) / (n * n);
} else if (t_0 <= 2e-9) {
tmp = t_1 / n;
} else {
tmp = (n * t_1) / (n * n);
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) t_1 = math.log(((x - -1.0) / x)) tmp = 0 if t_0 <= -math.inf: tmp = (n / x) / (n * n) elif t_0 <= 2e-9: tmp = t_1 / n else: tmp = (n * t_1) / (n * n) return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) t_1 = log(Float64(Float64(x - -1.0) / x)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(n / x) / Float64(n * n)); elseif (t_0 <= 2e-9) tmp = Float64(t_1 / n); else tmp = Float64(Float64(n * t_1) / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); t_1 = log(((x - -1.0) / x)); tmp = 0.0; if (t_0 <= -Inf) tmp = (n / x) / (n * n); elseif (t_0 <= 2e-9) tmp = t_1 / n; else tmp = (n * t_1) / (n * n); 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]}, Block[{t$95$1 = N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-9], N[(t$95$1 / n), $MachinePrecision], N[(N[(n * t$95$1), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \log \left(\frac{x - -1}{x}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{t\_1}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{n \cdot t\_1}{n \cdot n}\\
\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))) < -inf.0Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.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))) < 2.00000000000000012e-9Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
if 2.00000000000000012e-9 < (-.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
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-out--N/A
lift-log.f64N/A
lift--.f64N/A
metadata-evalN/A
add-flipN/A
+-commutativeN/A
lift-log.f64N/A
lower-*.f64N/A
diff-logN/A
lower-log.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lift--.f64N/A
lower-/.f6449.4%
Applied rewrites49.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(t_1 (/ (/ n x) (* n n))))
(if (<= t_0 (- INFINITY))
t_1
(if (<= t_0 1e-7) (/ (log (/ (- x -1.0) x)) n) t_1))))double code(double x, double n) {
double t_0 = pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
double t_1 = (n / x) / (n * n);
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_0 <= 1e-7) {
tmp = log(((x - -1.0) / x)) / n;
} else {
tmp = t_1;
}
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 t_1 = (n / x) / (n * n);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_0 <= 1e-7) {
tmp = Math.log(((x - -1.0) / x)) / n;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, n): t_0 = math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n)) t_1 = (n / x) / (n * n) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= 1e-7: tmp = math.log(((x - -1.0) / x)) / n else: tmp = t_1 return tmp
function code(x, n) t_0 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(n / x) / Float64(n * n)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = t_1; elseif (t_0 <= 1e-7) tmp = Float64(log(Float64(Float64(x - -1.0) / x)) / n); else tmp = t_1; end return tmp end
function tmp_2 = code(x, n) t_0 = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); t_1 = (n / x) / (n * n); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1; elseif (t_0 <= 1e-7) tmp = log(((x - -1.0) / x)) / n; else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, 1e-7], N[(N[Log[N[(N[(x - -1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{n}{x}}{n \cdot n}\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 10^{-7}:\\
\;\;\;\;\frac{\log \left(\frac{x - -1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\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))) < -inf.0 or 9.9999999999999995e-8 < (-.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
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
unpow2N/A
lift-pow.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f6449.2%
lift-pow.f64N/A
unpow2N/A
lower-*.f6449.2%
Applied rewrites49.2%
Taylor expanded in x around inf
lower-/.f6440.8%
Applied rewrites40.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))) < 9.9999999999999995e-8Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
lift--.f64N/A
lift-log.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
lower-/.f6459.3%
lift-+.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6459.3%
Applied rewrites59.3%
(FPCore (x n) :precision binary64 (if (<= x 2.4e-299) (/ 1.0 (* n x)) (if (<= x 0.42) (/ (- x (log x)) n) (/ (/ 1.0 n) x))))
double code(double x, double n) {
double tmp;
if (x <= 2.4e-299) {
tmp = 1.0 / (n * x);
} else if (x <= 0.42) {
tmp = (x - log(x)) / n;
} else {
tmp = (1.0 / n) / 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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.4d-299) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.42d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.4e-299) {
tmp = 1.0 / (n * x);
} else if (x <= 0.42) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.4e-299: tmp = 1.0 / (n * x) elif x <= 0.42: tmp = (x - math.log(x)) / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 2.4e-299) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.42) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.4e-299) tmp = 1.0 / (n * x); elseif (x <= 0.42) tmp = (x - log(x)) / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.4e-299], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.42], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{-299}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.42:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
if x < 2.40000000000000019e-299Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6440.1%
Applied rewrites40.1%
if 2.40000000000000019e-299 < x < 0.419999999999999984Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
Taylor expanded in x around 0
Applied rewrites31.4%
if 0.419999999999999984 < x Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Taylor expanded in n around inf
lower-/.f6440.7%
Applied rewrites40.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / 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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\frac{\frac{1}{n}}{x}
Initial program 53.5%
Taylor expanded in x around inf
Applied rewrites34.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-/.f6458.6%
Applied rewrites58.6%
Taylor expanded in n around inf
lower-/.f6440.7%
Applied rewrites40.7%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / 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 = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\frac{\frac{1}{x}}{n}
Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6440.1%
Applied rewrites40.1%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6440.7%
Applied rewrites40.7%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * 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, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\frac{1}{n \cdot x}
Initial program 53.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log.f64N/A
lower-+.f64N/A
lower-log.f6459.3%
Applied rewrites59.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-*.f6440.1%
Applied rewrites40.1%
herbie shell --seed 2025189
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))