
(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}
Sampling outcomes in binary64 precision:
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
(if (<= x 7200.0)
(/
(fma
-1.0
(+
(log1p x)
(/
(fma
(/
(* -0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
n)
-1.0
(* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))))
n))
(log x))
(- n))
(/ (exp (/ (log x) n)) (* n x))))
double code(double x, double n) {
double tmp;
if (x <= 7200.0) {
tmp = fma(-1.0, (log1p(x) + (fma(((-0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n), -1.0, (0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0)))) / n)), log(x)) / -n;
} else {
tmp = exp((log(x) / n)) / (n * x);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 7200.0) tmp = Float64(fma(-1.0, Float64(log1p(x) + Float64(fma(Float64(Float64(-0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n), -1.0, Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)))) / n)), log(x)) / Float64(-n)); else tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); end return tmp end
code[x_, n_] := If[LessEqual[x, 7200.0], N[(N[(-1.0 * N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * -1.0 + N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7200:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(\frac{-0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}, -1, 0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)\right)}{n}, \log x\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\end{array}
\end{array}
if x < 7200Initial program 46.5%
Taylor expanded in n around -inf
Applied rewrites81.8%
if 7200 < x Initial program 62.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
lower-/.f64N/A
lift-log.f6499.7
Applied rewrites99.7%
Final simplification88.7%
(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 -1e-8)
(- 1.0 t_0)
(if (<= t_1 5e-10) (/ (log (/ (+ 1.0 x) x)) n) (- (+ (/ x n) 1.0) t_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 <= -1e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-10) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = ((x / n) + 1.0) - t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, 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 <= (-1d-8)) then
tmp = 1.0d0 - t_0
else if (t_1 <= 5d-10) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = ((x / n) + 1.0d0) - t_0
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 <= -1e-8) {
tmp = 1.0 - t_0;
} else if (t_1 <= 5e-10) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = ((x / n) + 1.0) - t_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 <= -1e-8: tmp = 1.0 - t_0 elif t_1 <= 5e-10: tmp = math.log(((1.0 + x) / x)) / n else: tmp = ((x / n) + 1.0) - t_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 <= -1e-8) tmp = Float64(1.0 - t_0); elseif (t_1 <= 5e-10) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(Float64(x / n) + 1.0) - t_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 <= -1e-8) tmp = 1.0 - t_0; elseif (t_1 <= 5e-10) tmp = log(((1.0 + x) / x)) / n; else tmp = ((x / n) + 1.0) - t_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, -1e-8], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 5e-10], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$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 -1 \cdot 10^{-8}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - t\_0\\
\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))) < -1e-8Initial program 99.0%
Taylor expanded in x around 0
Applied rewrites99.0%
if -1e-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))) < 5.00000000000000031e-10Initial program 39.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.4
Applied rewrites76.4%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lower-/.f64N/A
lower-+.f6476.4
Applied rewrites76.4%
if 5.00000000000000031e-10 < (-.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 56.2%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6457.1
Applied rewrites57.1%
(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 (or (<= t_1 -1e-8) (not (<= t_1 5e-10)))
(- 1.0 t_0)
(/ (log (/ (+ 1.0 x) 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 <= -1e-8) || !(t_1 <= 5e-10)) {
tmp = 1.0 - t_0;
} else {
tmp = log(((1.0 + x) / 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 <= (-1d-8)) .or. (.not. (t_1 <= 5d-10))) then
tmp = 1.0d0 - t_0
else
tmp = log(((1.0d0 + x) / 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 <= -1e-8) || !(t_1 <= 5e-10)) {
tmp = 1.0 - t_0;
} else {
tmp = Math.log(((1.0 + x) / 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 <= -1e-8) or not (t_1 <= 5e-10): tmp = 1.0 - t_0 else: tmp = math.log(((1.0 + x) / 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 <= -1e-8) || !(t_1 <= 5e-10)) tmp = Float64(1.0 - t_0); else tmp = Float64(log(Float64(Float64(1.0 + x) / 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 <= -1e-8) || ~((t_1 <= 5e-10))) tmp = 1.0 - t_0; else tmp = log(((1.0 + x) / 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[Or[LessEqual[t$95$1, -1e-8], N[Not[LessEqual[t$95$1, 5e-10]], $MachinePrecision]], N[(1.0 - t$95$0), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / 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 -1 \cdot 10^{-8} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-10}\right):\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{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))) < -1e-8 or 5.00000000000000031e-10 < (-.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 77.3%
Taylor expanded in x around 0
Applied rewrites77.3%
if -1e-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))) < 5.00000000000000031e-10Initial program 39.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6476.4
Applied rewrites76.4%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lower-/.f64N/A
lower-+.f6476.4
Applied rewrites76.4%
Final simplification76.7%
(FPCore (x n)
:precision binary64
(if (<= x 1.45e-5)
(/
(fma
-1.0
(/
(fma
-0.5
(pow (log x) 2.0)
(* -0.16666666666666666 (/ (pow (log x) 3.0) n)))
n)
(log x))
(- n))
(/ (exp (/ (log x) n)) (* n x))))
double code(double x, double n) {
double tmp;
if (x <= 1.45e-5) {
tmp = fma(-1.0, (fma(-0.5, pow(log(x), 2.0), (-0.16666666666666666 * (pow(log(x), 3.0) / n))) / n), log(x)) / -n;
} else {
tmp = exp((log(x) / n)) / (n * x);
}
return tmp;
}
function code(x, n) tmp = 0.0 if (x <= 1.45e-5) tmp = Float64(fma(-1.0, Float64(fma(-0.5, (log(x) ^ 2.0), Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) / n))) / n), log(x)) / Float64(-n)); else tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.45e-5], N[(N[(-1.0 * N[(N[(-0.5 * N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.45 \cdot 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-0.5, {\log x}^{2}, -0.16666666666666666 \cdot \frac{{\log x}^{3}}{n}\right)}{n}, \log x\right)}{-n}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\end{array}
\end{array}
if x < 1.45e-5Initial program 46.4%
Taylor expanded in n around -inf
Applied rewrites70.4%
Taylor expanded in x around 0
lower-fma.f64N/A
Applied rewrites69.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower-fma.f64N/A
lift-pow.f64N/A
lift-log.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
lift-log.f6481.1
Applied rewrites81.1%
if 1.45e-5 < x Initial program 62.0%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-*.f6499.1
Applied rewrites99.1%
Taylor expanded in x around 0
lower-/.f64N/A
lift-log.f6499.1
Applied rewrites99.1%
Final simplification88.2%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -4e-90)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4e-90) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4e-90) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -4e-90: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-90) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-90], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-90}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999998e-90Initial program 88.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in x around 0
lower-/.f64N/A
lift-log.f6494.4
Applied rewrites94.4%
if -3.99999999999999998e-90 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 27.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6474.6
Applied rewrites74.6%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lower-/.f64N/A
lower-+.f6474.6
Applied rewrites74.6%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) Initial program 56.2%
Taylor expanded in n around 0
lower-exp.f64N/A
lower-/.f64N/A
lower-log1p.f6498.6
Applied rewrites98.6%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -4e-90)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 5e-9)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+164)
(- (+ (/ x n) 1.0) (pow x (/ 1.0 n)))
(/
(/ (- (+ 1.0 (/ 0.3333333333333333 (* x x))) (* 0.5 (pow x -1.0))) x)
n)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4e-90) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+164) {
tmp = ((x / n) + 1.0) - pow(x, (1.0 / n));
} else {
tmp = (((1.0 + (0.3333333333333333 / (x * x))) - (0.5 * pow(x, -1.0))) / 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) :: tmp
if ((1.0d0 / n) <= (-4d-90)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 5d-9) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+164) then
tmp = ((x / n) + 1.0d0) - (x ** (1.0d0 / n))
else
tmp = (((1.0d0 + (0.3333333333333333d0 / (x * x))) - (0.5d0 * (x ** (-1.0d0)))) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -4e-90) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 5e-9) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+164) {
tmp = ((x / n) + 1.0) - Math.pow(x, (1.0 / n));
} else {
tmp = (((1.0 + (0.3333333333333333 / (x * x))) - (0.5 * Math.pow(x, -1.0))) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -4e-90: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 5e-9: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+164: tmp = ((x / n) + 1.0) - math.pow(x, (1.0 / n)) else: tmp = (((1.0 + (0.3333333333333333 / (x * x))) - (0.5 * math.pow(x, -1.0))) / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -4e-90) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 5e-9) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+164) tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(Float64(Float64(1.0 + Float64(0.3333333333333333 / Float64(x * x))) - Float64(0.5 * (x ^ -1.0))) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -4e-90) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 5e-9) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+164) tmp = ((x / n) + 1.0) - (x ^ (1.0 / n)); else tmp = (((1.0 + (0.3333333333333333 / (x * x))) - (0.5 * (x ^ -1.0))) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e-90], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-9], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+164], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 + N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-90}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+164}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(1 + \frac{0.3333333333333333}{x \cdot x}\right) - 0.5 \cdot {x}^{-1}}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -3.99999999999999998e-90Initial program 88.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in x around 0
lower-/.f64N/A
lift-log.f6494.4
Applied rewrites94.4%
if -3.99999999999999998e-90 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000001e-9Initial program 27.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6474.6
Applied rewrites74.6%
lift--.f64N/A
lift-log1p.f64N/A
lift-log.f64N/A
diff-logN/A
lower-log.f64N/A
lower-/.f64N/A
lower-+.f6474.6
Applied rewrites74.6%
if 5.0000000000000001e-9 < (/.f64 #s(literal 1 binary64) n) < 1e164Initial program 88.3%
Taylor expanded in x around 0
+-commutativeN/A
lower-+.f64N/A
lower-/.f6489.4
Applied rewrites89.4%
if 1e164 < (/.f64 #s(literal 1 binary64) n) Initial program 17.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f646.6
Applied rewrites6.6%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6485.5
Applied rewrites85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)))
(if (<= n -8.5)
t_0
(if (<= n 4.3e-165)
(/ (/ (/ 0.3333333333333333 (* x x)) x) n)
(if (<= n 23000000000.0)
(- 1.0 (pow x (/ 1.0 n)))
(if (or (<= n 1.26e+73) (not (<= n 6.2e+168)))
(/ (- x (log x)) n)
t_0))))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 4.3e-165) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if (n <= 23000000000.0) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = (x - log(x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / x) / n
if (n <= (-8.5d0)) then
tmp = t_0
else if (n <= 4.3d-165) then
tmp = ((0.3333333333333333d0 / (x * x)) / x) / n
else if (n <= 23000000000.0d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if ((n <= 1.26d+73) .or. (.not. (n <= 6.2d+168))) then
tmp = (x - log(x)) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 4.3e-165) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if (n <= 23000000000.0) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n tmp = 0 if n <= -8.5: tmp = t_0 elif n <= 4.3e-165: tmp = ((0.3333333333333333 / (x * x)) / x) / n elif n <= 23000000000.0: tmp = 1.0 - math.pow(x, (1.0 / n)) elif (n <= 1.26e+73) or not (n <= 6.2e+168): tmp = (x - math.log(x)) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (n <= -8.5) tmp = t_0; elseif (n <= 4.3e-165) tmp = Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) / x) / n); elseif (n <= 23000000000.0) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif ((n <= 1.26e+73) || !(n <= 6.2e+168)) tmp = Float64(Float64(x - log(x)) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; tmp = 0.0; if (n <= -8.5) tmp = t_0; elseif (n <= 4.3e-165) tmp = ((0.3333333333333333 / (x * x)) / x) / n; elseif (n <= 23000000000.0) tmp = 1.0 - (x ^ (1.0 / n)); elseif ((n <= 1.26e+73) || ~((n <= 6.2e+168))) tmp = (x - log(x)) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -8.5], t$95$0, If[LessEqual[n, 4.3e-165], N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 23000000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 1.26e+73], N[Not[LessEqual[n, 6.2e+168]], $MachinePrecision]], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 4.3 \cdot 10^{-165}:\\
\;\;\;\;\frac{\frac{\frac{0.3333333333333333}{x \cdot x}}{x}}{n}\\
\mathbf{elif}\;n \leq 23000000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 1.26 \cdot 10^{+73} \lor \neg \left(n \leq 6.2 \cdot 10^{+168}\right):\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.5 or 1.25999999999999993e73 < n < 6.19999999999999993e168Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6466.8
Applied rewrites66.8%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6457.6
Applied rewrites57.6%
Taylor expanded in x around inf
Applied rewrites58.5%
if -8.5 < n < 4.30000000000000007e-165Initial program 81.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6435.8
Applied rewrites35.8%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6459.8
Applied rewrites59.8%
Taylor expanded in x around 0
pow2N/A
lift-/.f64N/A
lift-*.f6480.0
Applied rewrites80.0%
if 4.30000000000000007e-165 < n < 2.3e10Initial program 82.1%
Taylor expanded in x around 0
Applied rewrites81.7%
if 2.3e10 < n < 1.25999999999999993e73 or 6.19999999999999993e168 < n Initial program 24.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6482.4
Applied rewrites82.4%
Taylor expanded in x around 0
Applied rewrites65.6%
Final simplification69.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)))
(if (<= n -8.5)
t_0
(if (<= n 7e-102)
(/ (/ (/ 0.3333333333333333 (* x x)) x) n)
(if (or (<= n 1.26e+73) (not (<= n 6.2e+168)))
(/ (- x (log x)) n)
t_0)))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 7e-102) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = (x - log(x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / x) / n
if (n <= (-8.5d0)) then
tmp = t_0
else if (n <= 7d-102) then
tmp = ((0.3333333333333333d0 / (x * x)) / x) / n
else if ((n <= 1.26d+73) .or. (.not. (n <= 6.2d+168))) then
tmp = (x - log(x)) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 7e-102) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n tmp = 0 if n <= -8.5: tmp = t_0 elif n <= 7e-102: tmp = ((0.3333333333333333 / (x * x)) / x) / n elif (n <= 1.26e+73) or not (n <= 6.2e+168): tmp = (x - math.log(x)) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (n <= -8.5) tmp = t_0; elseif (n <= 7e-102) tmp = Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) / x) / n); elseif ((n <= 1.26e+73) || !(n <= 6.2e+168)) tmp = Float64(Float64(x - log(x)) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; tmp = 0.0; if (n <= -8.5) tmp = t_0; elseif (n <= 7e-102) tmp = ((0.3333333333333333 / (x * x)) / x) / n; elseif ((n <= 1.26e+73) || ~((n <= 6.2e+168))) tmp = (x - log(x)) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -8.5], t$95$0, If[LessEqual[n, 7e-102], N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[n, 1.26e+73], N[Not[LessEqual[n, 6.2e+168]], $MachinePrecision]], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-102}:\\
\;\;\;\;\frac{\frac{\frac{0.3333333333333333}{x \cdot x}}{x}}{n}\\
\mathbf{elif}\;n \leq 1.26 \cdot 10^{+73} \lor \neg \left(n \leq 6.2 \cdot 10^{+168}\right):\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.5 or 1.25999999999999993e73 < n < 6.19999999999999993e168Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6466.8
Applied rewrites66.8%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6457.6
Applied rewrites57.6%
Taylor expanded in x around inf
Applied rewrites58.5%
if -8.5 < n < 6.99999999999999973e-102Initial program 80.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6433.9
Applied rewrites33.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
pow2N/A
lift-/.f64N/A
lift-*.f6477.3
Applied rewrites77.3%
if 6.99999999999999973e-102 < n < 1.25999999999999993e73 or 6.19999999999999993e168 < n Initial program 42.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6463.1
Applied rewrites63.1%
Taylor expanded in x around 0
Applied rewrites50.9%
Final simplification63.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (/ 1.0 x) n)))
(if (<= n -8.5)
t_0
(if (<= n 7e-102)
(/ (/ (/ 0.3333333333333333 (* x x)) x) n)
(if (or (<= n 1.26e+73) (not (<= n 6.2e+168)))
(/ (- (log x)) n)
t_0)))))
double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 7e-102) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = -log(x) / n;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (1.0d0 / x) / n
if (n <= (-8.5d0)) then
tmp = t_0
else if (n <= 7d-102) then
tmp = ((0.3333333333333333d0 / (x * x)) / x) / n
else if ((n <= 1.26d+73) .or. (.not. (n <= 6.2d+168))) then
tmp = -log(x) / n
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (1.0 / x) / n;
double tmp;
if (n <= -8.5) {
tmp = t_0;
} else if (n <= 7e-102) {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
} else if ((n <= 1.26e+73) || !(n <= 6.2e+168)) {
tmp = -Math.log(x) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = (1.0 / x) / n tmp = 0 if n <= -8.5: tmp = t_0 elif n <= 7e-102: tmp = ((0.3333333333333333 / (x * x)) / x) / n elif (n <= 1.26e+73) or not (n <= 6.2e+168): tmp = -math.log(x) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(Float64(1.0 / x) / n) tmp = 0.0 if (n <= -8.5) tmp = t_0; elseif (n <= 7e-102) tmp = Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) / x) / n); elseif ((n <= 1.26e+73) || !(n <= 6.2e+168)) tmp = Float64(Float64(-log(x)) / n); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (1.0 / x) / n; tmp = 0.0; if (n <= -8.5) tmp = t_0; elseif (n <= 7e-102) tmp = ((0.3333333333333333 / (x * x)) / x) / n; elseif ((n <= 1.26e+73) || ~((n <= 6.2e+168))) tmp = -log(x) / n; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -8.5], t$95$0, If[LessEqual[n, 7e-102], N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[n, 1.26e+73], N[Not[LessEqual[n, 6.2e+168]], $MachinePrecision]], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{x}}{n}\\
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-102}:\\
\;\;\;\;\frac{\frac{\frac{0.3333333333333333}{x \cdot x}}{x}}{n}\\
\mathbf{elif}\;n \leq 1.26 \cdot 10^{+73} \lor \neg \left(n \leq 6.2 \cdot 10^{+168}\right):\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -8.5 or 1.25999999999999993e73 < n < 6.19999999999999993e168Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6466.8
Applied rewrites66.8%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6457.6
Applied rewrites57.6%
Taylor expanded in x around inf
Applied rewrites58.5%
if -8.5 < n < 6.99999999999999973e-102Initial program 80.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6433.9
Applied rewrites33.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
pow2N/A
lift-/.f64N/A
lift-*.f6477.3
Applied rewrites77.3%
if 6.99999999999999973e-102 < n < 1.25999999999999993e73 or 6.19999999999999993e168 < n Initial program 42.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6463.1
Applied rewrites63.1%
Taylor expanded in x around 0
log-pow-revN/A
inv-powN/A
neg-logN/A
lift-log.f64N/A
lift-neg.f6450.0
Applied rewrites50.0%
Final simplification63.2%
(FPCore (x n) :precision binary64 (if (or (<= n -8.5) (not (<= n 3.3e-100))) (/ (/ 1.0 x) n) (/ (/ (/ 0.3333333333333333 (* x x)) x) n)))
double code(double x, double n) {
double tmp;
if ((n <= -8.5) || !(n <= 3.3e-100)) {
tmp = (1.0 / x) / n;
} else {
tmp = ((0.3333333333333333 / (x * x)) / 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) :: tmp
if ((n <= (-8.5d0)) .or. (.not. (n <= 3.3d-100))) then
tmp = (1.0d0 / x) / n
else
tmp = ((0.3333333333333333d0 / (x * x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -8.5) || !(n <= 3.3e-100)) {
tmp = (1.0 / x) / n;
} else {
tmp = ((0.3333333333333333 / (x * x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -8.5) or not (n <= 3.3e-100): tmp = (1.0 / x) / n else: tmp = ((0.3333333333333333 / (x * x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if ((n <= -8.5) || !(n <= 3.3e-100)) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -8.5) || ~((n <= 3.3e-100))) tmp = (1.0 / x) / n; else tmp = ((0.3333333333333333 / (x * x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -8.5], N[Not[LessEqual[n, 3.3e-100]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5 \lor \neg \left(n \leq 3.3 \cdot 10^{-100}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.3333333333333333}{x \cdot x}}{x}}{n}\\
\end{array}
\end{array}
if n < -8.5 or 3.29999999999999996e-100 < n Initial program 35.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6465.2
Applied rewrites65.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6444.0
Applied rewrites44.0%
Taylor expanded in x around inf
Applied rewrites44.8%
if -8.5 < n < 3.29999999999999996e-100Initial program 80.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6433.9
Applied rewrites33.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6458.3
Applied rewrites58.3%
Taylor expanded in x around 0
pow2N/A
lift-/.f64N/A
lift-*.f6477.3
Applied rewrites77.3%
Final simplification57.1%
(FPCore (x n) :precision binary64 (if (or (<= n -8.5) (not (<= n 3.3e-100))) (/ (/ 1.0 x) n) (/ (/ 0.3333333333333333 (* n (* x x))) x)))
double code(double x, double n) {
double tmp;
if ((n <= -8.5) || !(n <= 3.3e-100)) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.3333333333333333 / (n * (x * x))) / 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 ((n <= (-8.5d0)) .or. (.not. (n <= 3.3d-100))) then
tmp = (1.0d0 / x) / n
else
tmp = (0.3333333333333333d0 / (n * (x * x))) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -8.5) || !(n <= 3.3e-100)) {
tmp = (1.0 / x) / n;
} else {
tmp = (0.3333333333333333 / (n * (x * x))) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -8.5) or not (n <= 3.3e-100): tmp = (1.0 / x) / n else: tmp = (0.3333333333333333 / (n * (x * x))) / x return tmp
function code(x, n) tmp = 0.0 if ((n <= -8.5) || !(n <= 3.3e-100)) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(Float64(0.3333333333333333 / Float64(n * Float64(x * x))) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -8.5) || ~((n <= 3.3e-100))) tmp = (1.0 / x) / n; else tmp = (0.3333333333333333 / (n * (x * x))) / x; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -8.5], N[Not[LessEqual[n, 3.3e-100]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(N[(0.3333333333333333 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5 \lor \neg \left(n \leq 3.3 \cdot 10^{-100}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n \cdot \left(x \cdot x\right)}}{x}\\
\end{array}
\end{array}
if n < -8.5 or 3.29999999999999996e-100 < n Initial program 35.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6465.2
Applied rewrites65.2%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6444.0
Applied rewrites44.0%
Taylor expanded in x around inf
Applied rewrites44.8%
if -8.5 < n < 3.29999999999999996e-100Initial program 80.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6433.9
Applied rewrites33.9%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64N/A
lower-/.f64N/A
lift-*.f6425.1
Applied rewrites25.1%
Taylor expanded in x around 0
pow2N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f6472.4
Applied rewrites72.4%
Final simplification55.3%
(FPCore (x n) :precision binary64 (if (or (<= n -0.36) (not (<= n -2e-264))) (/ (/ 1.0 x) n) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if ((n <= -0.36) || !(n <= -2e-264)) {
tmp = (1.0 / 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 ((n <= (-0.36d0)) .or. (.not. (n <= (-2d-264)))) then
tmp = (1.0d0 / 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 ((n <= -0.36) || !(n <= -2e-264)) {
tmp = (1.0 / x) / n;
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.36) or not (n <= -2e-264): tmp = (1.0 / x) / n else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.36) || !(n <= -2e-264)) tmp = Float64(Float64(1.0 / x) / n); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.36) || ~((n <= -2e-264))) tmp = (1.0 / x) / n; else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.36], N[Not[LessEqual[n, -2e-264]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.36 \lor \neg \left(n \leq -2 \cdot 10^{-264}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if n < -0.35999999999999999 or -2e-264 < n Initial program 38.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.3
Applied rewrites55.3%
Taylor expanded in x around inf
lower-/.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
inv-powN/A
lower-pow.f6449.9
Applied rewrites49.9%
Taylor expanded in x around inf
Applied rewrites47.2%
if -0.35999999999999999 < n < -2e-264Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites55.7%
Taylor expanded in n around inf
Applied rewrites46.6%
Final simplification47.1%
(FPCore (x n) :precision binary64 (if (or (<= n -0.36) (not (<= n -2e-264))) (/ 1.0 (* n x)) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if ((n <= -0.36) || !(n <= -2e-264)) {
tmp = 1.0 / (n * x);
} 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 ((n <= (-0.36d0)) .or. (.not. (n <= (-2d-264)))) then
tmp = 1.0d0 / (n * x)
else
tmp = 1.0d0 - 1.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -0.36) || !(n <= -2e-264)) {
tmp = 1.0 / (n * x);
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -0.36) or not (n <= -2e-264): tmp = 1.0 / (n * x) else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -0.36) || !(n <= -2e-264)) tmp = Float64(1.0 / Float64(n * x)); else tmp = Float64(1.0 - 1.0); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -0.36) || ~((n <= -2e-264))) tmp = 1.0 / (n * x); else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -0.36], N[Not[LessEqual[n, -2e-264]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.36 \lor \neg \left(n \leq -2 \cdot 10^{-264}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if n < -0.35999999999999999 or -2e-264 < n Initial program 38.4%
Taylor expanded in x around inf
lower-/.f64N/A
lower-exp.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-log.f64N/A
lower-*.f6443.4
Applied rewrites43.4%
Taylor expanded in n around inf
Applied rewrites47.1%
if -0.35999999999999999 < n < -2e-264Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites55.7%
Taylor expanded in n around inf
Applied rewrites46.6%
Final simplification47.0%
(FPCore (x n) :precision binary64 (- 1.0 1.0))
double code(double x, double n) {
return 1.0 - 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 - 1.0d0
end function
public static double code(double x, double n) {
return 1.0 - 1.0;
}
def code(x, n): return 1.0 - 1.0
function code(x, n) return Float64(1.0 - 1.0) end
function tmp = code(x, n) tmp = 1.0 - 1.0; end
code[x_, n_] := N[(1.0 - 1.0), $MachinePrecision]
\begin{array}{l}
\\
1 - 1
\end{array}
Initial program 52.6%
Taylor expanded in x around 0
Applied rewrites41.1%
Taylor expanded in n around inf
Applied rewrites26.1%
herbie shell --seed 2025064
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))