
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)) (t_1 (exp t_0)))
(if (<= n -1250000000.0)
(-
(fma
(pow (/ (log1p x) n) 3.0)
0.16666666666666666
(/ (fma (/ (pow (log1p x) 2.0) n) 0.5 (log1p x)) n))
(fma
(pow t_0 3.0)
0.16666666666666666
(/ (fma (/ (pow (log x) 2.0) n) 0.5 (log x)) n)))
(if (<= n 19000000000.0)
(- (exp (/ x n)) (pow x (pow n -1.0)))
(if (<= n 7.7e+99)
(/
(fma
t_1
(/
(+
(/
(-
(/ 0.16666666666666666 (pow n 3.0))
(/ (+ -0.3333333333333333 (/ 0.5 n)) n))
x)
(/ (+ -0.5 (/ 0.5 n)) n))
x)
(/ t_1 n))
x)
(/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double t_1 = exp(t_0);
double tmp;
if (n <= -1250000000.0) {
tmp = fma(pow((log1p(x) / n), 3.0), 0.16666666666666666, (fma((pow(log1p(x), 2.0) / n), 0.5, log1p(x)) / n)) - fma(pow(t_0, 3.0), 0.16666666666666666, (fma((pow(log(x), 2.0) / n), 0.5, log(x)) / n));
} else if (n <= 19000000000.0) {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
} else if (n <= 7.7e+99) {
tmp = fma(t_1, (((((0.16666666666666666 / pow(n, 3.0)) - ((-0.3333333333333333 + (0.5 / n)) / n)) / x) + ((-0.5 + (0.5 / n)) / n)) / x), (t_1 / n)) / x;
} else {
tmp = (log1p(x) - log(x)) / n;
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) t_1 = exp(t_0) tmp = 0.0 if (n <= -1250000000.0) tmp = Float64(fma((Float64(log1p(x) / n) ^ 3.0), 0.16666666666666666, Float64(fma(Float64((log1p(x) ^ 2.0) / n), 0.5, log1p(x)) / n)) - fma((t_0 ^ 3.0), 0.16666666666666666, Float64(fma(Float64((log(x) ^ 2.0) / n), 0.5, log(x)) / n))); elseif (n <= 19000000000.0) tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); elseif (n <= 7.7e+99) tmp = Float64(fma(t_1, Float64(Float64(Float64(Float64(Float64(0.16666666666666666 / (n ^ 3.0)) - Float64(Float64(-0.3333333333333333 + Float64(0.5 / n)) / n)) / x) + Float64(Float64(-0.5 + Float64(0.5 / n)) / n)) / x), Float64(t_1 / n)) / x); else tmp = Float64(Float64(log1p(x) - log(x)) / n); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[Exp[t$95$0], $MachinePrecision]}, If[LessEqual[n, -1250000000.0], N[(N[(N[Power[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision], 3.0], $MachinePrecision] * 0.16666666666666666 + N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(N[Power[t$95$0, 3.0], $MachinePrecision] * 0.16666666666666666 + N[(N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / n), $MachinePrecision] * 0.5 + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 19000000000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 7.7e+99], N[(N[(t$95$1 * N[(N[(N[(N[(N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-0.3333333333333333 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
t_1 := e^{t\_0}\\
\mathbf{if}\;n \leq -1250000000:\\
\;\;\;\;\mathsf{fma}\left({\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}^{3}, 0.16666666666666666, \frac{\mathsf{fma}\left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n}, 0.5, \mathsf{log1p}\left(x\right)\right)}{n}\right) - \mathsf{fma}\left({t\_0}^{3}, 0.16666666666666666, \frac{\mathsf{fma}\left(\frac{{\log x}^{2}}{n}, 0.5, \log x\right)}{n}\right)\\
\mathbf{elif}\;n \leq 19000000000:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\mathbf{elif}\;n \leq 7.7 \cdot 10^{+99}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_1, \frac{\frac{\frac{0.16666666666666666}{{n}^{3}} - \frac{-0.3333333333333333 + \frac{0.5}{n}}{n}}{x} + \frac{-0.5 + \frac{0.5}{n}}{n}}{x}, \frac{t\_1}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\end{array}
\end{array}
if n < -1.25e9Initial program 28.9%
Taylor expanded in n around inf
Applied rewrites79.7%
if -1.25e9 < n < 1.9e10Initial program 82.9%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
lower-/.f6497.8
Applied rewrites97.8%
if 1.9e10 < n < 7.70000000000000045e99Initial program 9.3%
Taylor expanded in x around inf
Applied rewrites74.6%
if 7.70000000000000045e99 < n Initial program 32.4%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6486.0
Applied rewrites86.0%
Final simplification88.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))) (t_1 (- (pow (+ x 1.0) (pow n -1.0)) t_0)))
(if (<= t_1 -0.05)
(- 1.0 t_0)
(if (<= t_1 0.0)
(/ (- (log1p x) (log x)) n)
(- (fma (/ (fma (+ (/ 0.5 n) -0.5) x 1.0) n) x 1.0) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double t_1 = pow((x + 1.0), pow(n, -1.0)) - t_0;
double tmp;
if (t_1 <= -0.05) {
tmp = 1.0 - t_0;
} else if (t_1 <= 0.0) {
tmp = (log1p(x) - log(x)) / n;
} else {
tmp = fma((fma(((0.5 / n) + -0.5), x, 1.0) / n), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) t_1 = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0) tmp = 0.0 if (t_1 <= -0.05) tmp = Float64(1.0 - t_0); elseif (t_1 <= 0.0) tmp = Float64(Float64(log1p(x) - log(x)) / n); else tmp = Float64(fma(Float64(fma(Float64(Float64(0.5 / n) + -0.5), x, 1.0) / n), x, 1.0) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -0.05], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] / n), $MachinePrecision] * x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left({n}^{-1}\right)}\\
t_1 := {\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -0.05:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{0.5}{n} + -0.5, x, 1\right)}{n}, x, 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))) < -0.050000000000000003Initial program 99.9%
Taylor expanded in x around 0
Applied rewrites99.9%
if -0.050000000000000003 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 41.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6477.9
Applied rewrites77.9%
if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) Initial program 59.0%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites59.3%
Applied rewrites67.3%
Final simplification79.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log x) n))))
(if (<= (pow n -1.0) -2e-25)
(/ (/ t_0 x) n)
(if (<= (pow n -1.0) 5e-111)
(/
(-
(fma 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n) (log1p x))
(log x))
n)
(if (<= (pow n -1.0) 5e-12)
(/
(fma
t_0
(/
(+
(/
(-
(/ 0.16666666666666666 (pow n 3.0))
(/ (+ -0.3333333333333333 (/ 0.5 n)) n))
x)
(/ (+ -0.5 (/ 0.5 n)) n))
x)
(/ t_0 n))
x)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double tmp;
if (pow(n, -1.0) <= -2e-25) {
tmp = (t_0 / x) / n;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (fma(0.5, ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n), log1p(x)) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = fma(t_0, (((((0.16666666666666666 / pow(n, 3.0)) - ((-0.3333333333333333 + (0.5 / n)) / n)) / x) + ((-0.5 + (0.5 / n)) / n)) / x), (t_0 / n)) / x;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) tmp = 0.0 if ((n ^ -1.0) <= -2e-25) tmp = Float64(Float64(t_0 / x) / n); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(fma(0.5, Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n), log1p(x)) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(fma(t_0, Float64(Float64(Float64(Float64(Float64(0.16666666666666666 / (n ^ 3.0)) - Float64(Float64(-0.3333333333333333 + Float64(0.5 / n)) / n)) / x) + Float64(Float64(-0.5 + Float64(0.5 / n)) / n)) / x), Float64(t_0 / n)) / x); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-25], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(t$95$0 * N[(N[(N[(N[(N[(0.16666666666666666 / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] - N[(N[(-0.3333333333333333 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}, \mathsf{log1p}\left(x\right)\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_0, \frac{\frac{\frac{0.16666666666666666}{{n}^{3}} - \frac{-0.3333333333333333 + \frac{0.5}{n}}{n}}{x} + \frac{-0.5 + \frac{0.5}{n}}{n}}{x}, \frac{t\_0}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000008e-25Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
Applied rewrites94.2%
if -2.00000000000000008e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
Applied rewrites84.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
Applied rewrites74.6%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log x) n))))
(if (<= (pow n -1.0) -2e-25)
(/ (/ t_0 x) n)
(if (<= (pow n -1.0) 5e-111)
(/
(-
(fma 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n) (log1p x))
(log x))
n)
(if (<= (pow n -1.0) 5e-12)
(/ (fma (/ (/ (+ -0.5 (/ 0.5 n)) n) x) t_0 (/ t_0 n)) x)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double tmp;
if (pow(n, -1.0) <= -2e-25) {
tmp = (t_0 / x) / n;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (fma(0.5, ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n), log1p(x)) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = fma((((-0.5 + (0.5 / n)) / n) / x), t_0, (t_0 / n)) / x;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) tmp = 0.0 if ((n ^ -1.0) <= -2e-25) tmp = Float64(Float64(t_0 / x) / n); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(fma(0.5, Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n), log1p(x)) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(fma(Float64(Float64(Float64(-0.5 + Float64(0.5 / n)) / n) / x), t_0, Float64(t_0 / n)) / x); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-25], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[Log[1 + x], $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision] * t$95$0 + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}, \mathsf{log1p}\left(x\right)\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{-0.5 + \frac{0.5}{n}}{n}}{x}, t\_0, \frac{t\_0}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000008e-25Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
Applied rewrites94.2%
if -2.00000000000000008e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
Applied rewrites84.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites74.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log x) n))))
(if (<= (pow n -1.0) -2e-25)
(/ (/ t_0 x) n)
(if (<= (pow n -1.0) 5e-111)
(/ (- (log1p x) (log x)) n)
(if (<= (pow n -1.0) 5e-12)
(/ (fma (/ (/ (+ -0.5 (/ 0.5 n)) n) x) t_0 (/ t_0 n)) x)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double tmp;
if (pow(n, -1.0) <= -2e-25) {
tmp = (t_0 / x) / n;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (log1p(x) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = fma((((-0.5 + (0.5 / n)) / n) / x), t_0, (t_0 / n)) / x;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) tmp = 0.0 if ((n ^ -1.0) <= -2e-25) tmp = Float64(Float64(t_0 / x) / n); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(fma(Float64(Float64(Float64(-0.5 + Float64(0.5 / n)) / n) / x), t_0, Float64(t_0 / n)) / x); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-25], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision] * t$95$0 + N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{t\_0}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\frac{-0.5 + \frac{0.5}{n}}{n}}{x}, t\_0, \frac{t\_0}{n}\right)}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000008e-25Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
Applied rewrites94.2%
if -2.00000000000000008e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites74.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= (pow n -1.0) -2e-25)
(/ (/ (exp t_0) x) n)
(if (<= (pow n -1.0) 5e-111)
(/ (- (log1p x) (log x)) n)
(if (<= (pow n -1.0) 5e-12)
(/
(/
(- (+ (+ (/ (fma -0.5 (log x) 0.5) (* n x)) t_0) 1.0) (/ 0.5 x))
n)
x)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if (pow(n, -1.0) <= -2e-25) {
tmp = (exp(t_0) / x) / n;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (log1p(x) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = (((((fma(-0.5, log(x), 0.5) / (n * x)) + t_0) + 1.0) - (0.5 / x)) / n) / x;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if ((n ^ -1.0) <= -2e-25) tmp = Float64(Float64(exp(t_0) / x) / n); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(Float64(Float64(Float64(Float64(Float64(fma(-0.5, log(x), 0.5) / Float64(n * x)) + t_0) + 1.0) - Float64(0.5 / x)) / n) / x); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-25], N[(N[(N[Exp[t$95$0], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(N[(N[(N[(N[(-0.5 * N[Log[x], $MachinePrecision] + 0.5), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{e^{t\_0}}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{\left(\left(\frac{\mathsf{fma}\left(-0.5, \log x, 0.5\right)}{n \cdot x} + t\_0\right) + 1\right) - \frac{0.5}{x}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000008e-25Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
Applied rewrites94.2%
if -2.00000000000000008e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites74.0%
Taylor expanded in n around inf
Applied rewrites74.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= (pow n -1.0) -2e-25)
(/ (/ (exp t_0) x) n)
(if (<= (pow n -1.0) 5e-111)
(/ (- (log1p x) (log x)) n)
(if (<= (pow n -1.0) 5e-12)
(/ (/ (+ t_0 1.0) x) n)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if (pow(n, -1.0) <= -2e-25) {
tmp = (exp(t_0) / x) / n;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (log1p(x) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = ((t_0 + 1.0) / x) / n;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log(x) / n;
double tmp;
if (Math.pow(n, -1.0) <= -2e-25) {
tmp = (Math.exp(t_0) / x) / n;
} else if (Math.pow(n, -1.0) <= 5e-111) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if (Math.pow(n, -1.0) <= 5e-12) {
tmp = ((t_0 + 1.0) / x) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, Math.pow(n, -1.0));
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / n tmp = 0 if math.pow(n, -1.0) <= -2e-25: tmp = (math.exp(t_0) / x) / n elif math.pow(n, -1.0) <= 5e-111: tmp = (math.log1p(x) - math.log(x)) / n elif math.pow(n, -1.0) <= 5e-12: tmp = ((t_0 + 1.0) / x) / n else: tmp = math.exp((x / n)) - math.pow(x, math.pow(n, -1.0)) return tmp
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if ((n ^ -1.0) <= -2e-25) tmp = Float64(Float64(exp(t_0) / x) / n); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(Float64(Float64(t_0 + 1.0) / x) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-25], N[(N[(N[Exp[t$95$0], $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(t$95$0 + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{e^{t\_0}}{x}}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{t\_0 + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2.00000000000000008e-25Initial program 92.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
Applied rewrites94.2%
if -2.00000000000000008e-25 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 29.9%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6484.2
Applied rewrites84.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6473.2
Applied rewrites73.2%
Taylor expanded in n around inf
Applied rewrites73.2%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) n)))
(if (<= (pow n -1.0) -2e-20)
(/ (exp t_0) (* n x))
(if (<= (pow n -1.0) 5e-111)
(/ (- (log1p x) (log x)) n)
(if (<= (pow n -1.0) 5e-12)
(/ (/ (+ t_0 1.0) x) n)
(- (exp (/ x n)) (pow x (pow n -1.0))))))))
double code(double x, double n) {
double t_0 = log(x) / n;
double tmp;
if (pow(n, -1.0) <= -2e-20) {
tmp = exp(t_0) / (n * x);
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (log1p(x) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = ((t_0 + 1.0) / x) / n;
} else {
tmp = exp((x / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log(x) / n;
double tmp;
if (Math.pow(n, -1.0) <= -2e-20) {
tmp = Math.exp(t_0) / (n * x);
} else if (Math.pow(n, -1.0) <= 5e-111) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if (Math.pow(n, -1.0) <= 5e-12) {
tmp = ((t_0 + 1.0) / x) / n;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, Math.pow(n, -1.0));
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / n tmp = 0 if math.pow(n, -1.0) <= -2e-20: tmp = math.exp(t_0) / (n * x) elif math.pow(n, -1.0) <= 5e-111: tmp = (math.log1p(x) - math.log(x)) / n elif math.pow(n, -1.0) <= 5e-12: tmp = ((t_0 + 1.0) / x) / n else: tmp = math.exp((x / n)) - math.pow(x, math.pow(n, -1.0)) return tmp
function code(x, n) t_0 = Float64(log(x) / n) tmp = 0.0 if ((n ^ -1.0) <= -2e-20) tmp = Float64(exp(t_0) / Float64(n * x)); elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(Float64(Float64(t_0 + 1.0) / x) / n); else tmp = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -2e-20], N[(N[Exp[t$95$0], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(t$95$0 + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;{n}^{-1} \leq -2 \cdot 10^{-20}:\\
\;\;\;\;\frac{e^{t\_0}}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{t\_0 + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999989e-20Initial program 92.2%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6494.1
Applied rewrites94.1%
if -1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6484.3
Applied rewrites84.3%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6473.2
Applied rewrites73.2%
Taylor expanded in n around inf
Applied rewrites73.2%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 59.0%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6496.5
Applied rewrites96.5%
Taylor expanded in x around 0
lower-/.f6496.5
Applied rewrites96.5%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- (exp (/ x n)) (pow x (pow n -1.0)))))
(if (<= (pow n -1.0) -5e-10)
t_0
(if (<= (pow n -1.0) 5e-111)
(/ (- (log1p x) (log x)) n)
(if (<= (pow n -1.0) 5e-12) (/ (/ (+ (/ (log x) n) 1.0) x) n) t_0)))))
double code(double x, double n) {
double t_0 = exp((x / n)) - pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -5e-10) {
tmp = t_0;
} else if (pow(n, -1.0) <= 5e-111) {
tmp = (log1p(x) - log(x)) / n;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = (((log(x) / n) + 1.0) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.exp((x / n)) - Math.pow(x, Math.pow(n, -1.0));
double tmp;
if (Math.pow(n, -1.0) <= -5e-10) {
tmp = t_0;
} else if (Math.pow(n, -1.0) <= 5e-111) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if (Math.pow(n, -1.0) <= 5e-12) {
tmp = (((Math.log(x) / n) + 1.0) / x) / n;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.exp((x / n)) - math.pow(x, math.pow(n, -1.0)) tmp = 0 if math.pow(n, -1.0) <= -5e-10: tmp = t_0 elif math.pow(n, -1.0) <= 5e-111: tmp = (math.log1p(x) - math.log(x)) / n elif math.pow(n, -1.0) <= 5e-12: tmp = (((math.log(x) / n) + 1.0) / x) / n else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(exp(Float64(x / n)) - (x ^ (n ^ -1.0))) tmp = 0.0 if ((n ^ -1.0) <= -5e-10) tmp = t_0; elseif ((n ^ -1.0) <= 5e-111) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(Float64(Float64(Float64(log(x) / n) + 1.0) / x) / n); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -5e-10], t$95$0, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-111], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[(N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{n}} - {x}^{\left({n}^{-1}\right)}\\
\mathbf{if}\;{n}^{-1} \leq -5 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-111}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\frac{\frac{\log x}{n} + 1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000031e-10 or 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 82.9%
lift-pow.f64N/A
pow-to-expN/A
lower-exp.f64N/A
lift-/.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-log1p.f6497.8
Applied rewrites97.8%
Taylor expanded in x around 0
lower-/.f6497.8
Applied rewrites97.8%
if -5.00000000000000031e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e-111Initial program 30.1%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6481.2
Applied rewrites81.2%
if 5.0000000000000003e-111 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 9.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6473.2
Applied rewrites73.2%
Taylor expanded in n around inf
Applied rewrites73.2%
Final simplification88.5%
(FPCore (x n)
:precision binary64
(if (<= x 6e-78)
(- (+ (/ x n) 1.0) (pow x (pow n -1.0)))
(if (<= x 0.74)
(/ (* n x) (* (* n x) (* n x)))
(if (<= x 3.5e+128) (/ (/ (- 1.0 (/ 0.5 x)) n) x) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = ((x / n) + 1.0) - pow(x, pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else if (x <= 3.5e+128) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6d-78) then
tmp = ((x / n) + 1.0d0) - (x ** (n ** (-1.0d0)))
else if (x <= 0.74d0) then
tmp = (n * x) / ((n * x) * (n * x))
else if (x <= 3.5d+128) then
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = ((x / n) + 1.0) - Math.pow(x, Math.pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else if (x <= 3.5e+128) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6e-78: tmp = ((x / n) + 1.0) - math.pow(x, math.pow(n, -1.0)) elif x <= 0.74: tmp = (n * x) / ((n * x) * (n * x)) elif x <= 3.5e+128: tmp = ((1.0 - (0.5 / x)) / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 6e-78) tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ (n ^ -1.0))); elseif (x <= 0.74) tmp = Float64(Float64(n * x) / Float64(Float64(n * x) * Float64(n * x))); elseif (x <= 3.5e+128) tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6e-78) tmp = ((x / n) + 1.0) - (x ^ (n ^ -1.0)); elseif (x <= 0.74) tmp = (n * x) / ((n * x) * (n * x)); elseif (x <= 3.5e+128) tmp = ((1.0 - (0.5 / x)) / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6e-78], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.74], N[(N[(n * x), $MachinePrecision] / N[(N[(n * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.5e+128], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-78}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left({n}^{-1}\right)}\\
\mathbf{elif}\;x \leq 0.74:\\
\;\;\;\;\frac{n \cdot x}{\left(n \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.99999999999999975e-78Initial program 52.8%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
lower-/.f6452.9
Applied rewrites52.9%
if 5.99999999999999975e-78 < x < 0.73999999999999999Initial program 30.2%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites23.8%
Taylor expanded in n around inf
Applied rewrites38.6%
if 0.73999999999999999 < x < 3.49999999999999969e128Initial program 46.2%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites83.9%
Taylor expanded in n around inf
Applied rewrites64.9%
if 3.49999999999999969e128 < x Initial program 75.1%
Taylor expanded in n around -inf
Applied rewrites75.1%
Applied rewrites75.1%
Taylor expanded in x around inf
Applied rewrites75.1%
Final simplification58.1%
(FPCore (x n)
:precision binary64
(if (<= x 6e-78)
(- 1.0 (pow x (pow n -1.0)))
(if (<= x 0.74)
(/ (* n x) (* (* n x) (* n x)))
(if (<= x 3.5e+128) (/ (/ (- 1.0 (/ 0.5 x)) n) x) 0.0))))
double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else if (x <= 3.5e+128) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6d-78) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else if (x <= 0.74d0) then
tmp = (n * x) / ((n * x) * (n * x))
else if (x <= 3.5d+128) then
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else if (x <= 3.5e+128) {
tmp = ((1.0 - (0.5 / x)) / n) / x;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6e-78: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) elif x <= 0.74: tmp = (n * x) / ((n * x) * (n * x)) elif x <= 3.5e+128: tmp = ((1.0 - (0.5 / x)) / n) / x else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 6e-78) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); elseif (x <= 0.74) tmp = Float64(Float64(n * x) / Float64(Float64(n * x) * Float64(n * x))); elseif (x <= 3.5e+128) tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6e-78) tmp = 1.0 - (x ^ (n ^ -1.0)); elseif (x <= 0.74) tmp = (n * x) / ((n * x) * (n * x)); elseif (x <= 3.5e+128) tmp = ((1.0 - (0.5 / x)) / n) / x; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6e-78], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.74], N[(N[(n * x), $MachinePrecision] / N[(N[(n * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.5e+128], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-78}:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{elif}\;x \leq 0.74:\\
\;\;\;\;\frac{n \cdot x}{\left(n \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 5.99999999999999975e-78Initial program 52.8%
Taylor expanded in x around 0
Applied rewrites52.8%
if 5.99999999999999975e-78 < x < 0.73999999999999999Initial program 30.2%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites23.8%
Taylor expanded in n around inf
Applied rewrites38.6%
if 0.73999999999999999 < x < 3.49999999999999969e128Initial program 46.2%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites83.9%
Taylor expanded in n around inf
Applied rewrites64.9%
if 3.49999999999999969e128 < x Initial program 75.1%
Taylor expanded in n around -inf
Applied rewrites75.1%
Applied rewrites75.1%
Taylor expanded in x around inf
Applied rewrites75.1%
Final simplification58.0%
(FPCore (x n)
:precision binary64
(if (<= x 6e-78)
(- 1.0 (pow x (pow n -1.0)))
(if (<= x 0.74)
(/ (* n x) (* (* n x) (* n x)))
(/ (/ (- 1.0 (/ 0.5 x)) n) x))))
double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else {
tmp = ((1.0 - (0.5 / x)) / 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 <= 6d-78) then
tmp = 1.0d0 - (x ** (n ** (-1.0d0)))
else if (x <= 0.74d0) then
tmp = (n * x) / ((n * x) * (n * x))
else
tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6e-78) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else if (x <= 0.74) {
tmp = (n * x) / ((n * x) * (n * x));
} else {
tmp = ((1.0 - (0.5 / x)) / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6e-78: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) elif x <= 0.74: tmp = (n * x) / ((n * x) * (n * x)) else: tmp = ((1.0 - (0.5 / x)) / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 6e-78) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); elseif (x <= 0.74) tmp = Float64(Float64(n * x) / Float64(Float64(n * x) * Float64(n * x))); else tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6e-78) tmp = 1.0 - (x ^ (n ^ -1.0)); elseif (x <= 0.74) tmp = (n * x) / ((n * x) * (n * x)); else tmp = ((1.0 - (0.5 / x)) / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6e-78], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.74], N[(N[(n * x), $MachinePrecision] / N[(N[(n * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-78}:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{elif}\;x \leq 0.74:\\
\;\;\;\;\frac{n \cdot x}{\left(n \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if x < 5.99999999999999975e-78Initial program 52.8%
Taylor expanded in x around 0
Applied rewrites52.8%
if 5.99999999999999975e-78 < x < 0.73999999999999999Initial program 30.2%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6424.6
Applied rewrites24.6%
Applied rewrites23.8%
Taylor expanded in n around inf
Applied rewrites38.6%
if 0.73999999999999999 < x Initial program 62.5%
Taylor expanded in x around inf
lower-/.f64N/A
Applied rewrites84.2%
Taylor expanded in n around inf
Applied rewrites64.5%
Final simplification55.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (pow n -1.0) x)))
(if (<= n -1.52e-7)
t_0
(if (<= n -1.65e-162)
(/ 0.0 (* n n))
(if (<= n 1e-183)
(pow (* n x) -1.0)
(if (<= n 1.9e-118) (/ (* n x) (* (* n x) (* n x))) t_0))))))
double code(double x, double n) {
double t_0 = pow(n, -1.0) / x;
double tmp;
if (n <= -1.52e-7) {
tmp = t_0;
} else if (n <= -1.65e-162) {
tmp = 0.0 / (n * n);
} else if (n <= 1e-183) {
tmp = pow((n * x), -1.0);
} else if (n <= 1.9e-118) {
tmp = (n * x) / ((n * x) * (n * x));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (n ** (-1.0d0)) / x
if (n <= (-1.52d-7)) then
tmp = t_0
else if (n <= (-1.65d-162)) then
tmp = 0.0d0 / (n * n)
else if (n <= 1d-183) then
tmp = (n * x) ** (-1.0d0)
else if (n <= 1.9d-118) then
tmp = (n * x) / ((n * x) * (n * x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(n, -1.0) / x;
double tmp;
if (n <= -1.52e-7) {
tmp = t_0;
} else if (n <= -1.65e-162) {
tmp = 0.0 / (n * n);
} else if (n <= 1e-183) {
tmp = Math.pow((n * x), -1.0);
} else if (n <= 1.9e-118) {
tmp = (n * x) / ((n * x) * (n * x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(n, -1.0) / x tmp = 0 if n <= -1.52e-7: tmp = t_0 elif n <= -1.65e-162: tmp = 0.0 / (n * n) elif n <= 1e-183: tmp = math.pow((n * x), -1.0) elif n <= 1.9e-118: tmp = (n * x) / ((n * x) * (n * x)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64((n ^ -1.0) / x) tmp = 0.0 if (n <= -1.52e-7) tmp = t_0; elseif (n <= -1.65e-162) tmp = Float64(0.0 / Float64(n * n)); elseif (n <= 1e-183) tmp = Float64(n * x) ^ -1.0; elseif (n <= 1.9e-118) tmp = Float64(Float64(n * x) / Float64(Float64(n * x) * Float64(n * x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = (n ^ -1.0) / x; tmp = 0.0; if (n <= -1.52e-7) tmp = t_0; elseif (n <= -1.65e-162) tmp = 0.0 / (n * n); elseif (n <= 1e-183) tmp = (n * x) ^ -1.0; elseif (n <= 1.9e-118) tmp = (n * x) / ((n * x) * (n * x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[n, -1.52e-7], t$95$0, If[LessEqual[n, -1.65e-162], N[(0.0 / N[(n * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e-183], N[Power[N[(n * x), $MachinePrecision], -1.0], $MachinePrecision], If[LessEqual[n, 1.9e-118], N[(N[(n * x), $MachinePrecision] / N[(N[(n * x), $MachinePrecision] * N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{{n}^{-1}}{x}\\
\mathbf{if}\;n \leq -1.52 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -1.65 \cdot 10^{-162}:\\
\;\;\;\;\frac{0}{n \cdot n}\\
\mathbf{elif}\;n \leq 10^{-183}:\\
\;\;\;\;{\left(n \cdot x\right)}^{-1}\\
\mathbf{elif}\;n \leq 1.9 \cdot 10^{-118}:\\
\;\;\;\;\frac{n \cdot x}{\left(n \cdot x\right) \cdot \left(n \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -1.52000000000000011e-7 or 1.9e-118 < n Initial program 36.4%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6444.6
Applied rewrites44.6%
Taylor expanded in n around inf
Applied rewrites43.0%
if -1.52000000000000011e-7 < n < -1.65000000000000007e-162Initial program 100.0%
Taylor expanded in n around -inf
Applied rewrites78.1%
Applied rewrites23.1%
Taylor expanded in x around inf
Applied rewrites59.6%
if -1.65000000000000007e-162 < n < 1.00000000000000001e-183Initial program 83.8%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6471.5
Applied rewrites71.5%
Taylor expanded in n around inf
Applied rewrites47.7%
Applied rewrites47.7%
if 1.00000000000000001e-183 < n < 1.9e-118Initial program 31.4%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f641.2
Applied rewrites1.2%
Applied rewrites0.0%
Taylor expanded in n around inf
Applied rewrites64.5%
Final simplification47.5%
(FPCore (x n) :precision binary64 (if (or (<= n -1.52e-7) (not (<= n -1.65e-162))) (/ (pow n -1.0) x) (/ 0.0 (* n n))))
double code(double x, double n) {
double tmp;
if ((n <= -1.52e-7) || !(n <= -1.65e-162)) {
tmp = pow(n, -1.0) / x;
} else {
tmp = 0.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) :: tmp
if ((n <= (-1.52d-7)) .or. (.not. (n <= (-1.65d-162)))) then
tmp = (n ** (-1.0d0)) / x
else
tmp = 0.0d0 / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -1.52e-7) || !(n <= -1.65e-162)) {
tmp = Math.pow(n, -1.0) / x;
} else {
tmp = 0.0 / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -1.52e-7) or not (n <= -1.65e-162): tmp = math.pow(n, -1.0) / x else: tmp = 0.0 / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n <= -1.52e-7) || !(n <= -1.65e-162)) tmp = Float64((n ^ -1.0) / x); else tmp = Float64(0.0 / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -1.52e-7) || ~((n <= -1.65e-162))) tmp = (n ^ -1.0) / x; else tmp = 0.0 / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -1.52e-7], N[Not[LessEqual[n, -1.65e-162]], $MachinePrecision]], N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision], N[(0.0 / N[(n * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.52 \cdot 10^{-7} \lor \neg \left(n \leq -1.65 \cdot 10^{-162}\right):\\
\;\;\;\;\frac{{n}^{-1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n \cdot n}\\
\end{array}
\end{array}
if n < -1.52000000000000011e-7 or -1.65000000000000007e-162 < n Initial program 45.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6447.0
Applied rewrites47.0%
Taylor expanded in n around inf
Applied rewrites41.4%
if -1.52000000000000011e-7 < n < -1.65000000000000007e-162Initial program 100.0%
Taylor expanded in n around -inf
Applied rewrites78.1%
Applied rewrites23.1%
Taylor expanded in x around inf
Applied rewrites59.6%
Final simplification44.2%
(FPCore (x n) :precision binary64 (if (or (<= n -1.52e-7) (not (<= n -1.65e-162))) (pow (* n x) -1.0) (/ 0.0 (* n n))))
double code(double x, double n) {
double tmp;
if ((n <= -1.52e-7) || !(n <= -1.65e-162)) {
tmp = pow((n * x), -1.0);
} else {
tmp = 0.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) :: tmp
if ((n <= (-1.52d-7)) .or. (.not. (n <= (-1.65d-162)))) then
tmp = (n * x) ** (-1.0d0)
else
tmp = 0.0d0 / (n * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -1.52e-7) || !(n <= -1.65e-162)) {
tmp = Math.pow((n * x), -1.0);
} else {
tmp = 0.0 / (n * n);
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -1.52e-7) or not (n <= -1.65e-162): tmp = math.pow((n * x), -1.0) else: tmp = 0.0 / (n * n) return tmp
function code(x, n) tmp = 0.0 if ((n <= -1.52e-7) || !(n <= -1.65e-162)) tmp = Float64(n * x) ^ -1.0; else tmp = Float64(0.0 / Float64(n * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -1.52e-7) || ~((n <= -1.65e-162))) tmp = (n * x) ^ -1.0; else tmp = 0.0 / (n * n); end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -1.52e-7], N[Not[LessEqual[n, -1.65e-162]], $MachinePrecision]], N[Power[N[(n * x), $MachinePrecision], -1.0], $MachinePrecision], N[(0.0 / N[(n * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.52 \cdot 10^{-7} \lor \neg \left(n \leq -1.65 \cdot 10^{-162}\right):\\
\;\;\;\;{\left(n \cdot x\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n \cdot n}\\
\end{array}
\end{array}
if n < -1.52000000000000011e-7 or -1.65000000000000007e-162 < n Initial program 45.3%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6447.0
Applied rewrites47.0%
Taylor expanded in n around inf
Applied rewrites41.4%
Applied rewrites40.9%
if -1.52000000000000011e-7 < n < -1.65000000000000007e-162Initial program 100.0%
Taylor expanded in n around -inf
Applied rewrites78.1%
Applied rewrites23.1%
Taylor expanded in x around inf
Applied rewrites59.6%
Final simplification43.7%
(FPCore (x n) :precision binary64 (pow (* n x) -1.0))
double code(double x, double n) {
return pow((n * x), -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 = (n * x) ** (-1.0d0)
end function
public static double code(double x, double n) {
return Math.pow((n * x), -1.0);
}
def code(x, n): return math.pow((n * x), -1.0)
function code(x, n) return Float64(n * x) ^ -1.0 end
function tmp = code(x, n) tmp = (n * x) ^ -1.0; end
code[x_, n_] := N[Power[N[(n * x), $MachinePrecision], -1.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(n \cdot x\right)}^{-1}
\end{array}
Initial program 53.6%
Taylor expanded in x around inf
lower-/.f64N/A
log-recN/A
mul-1-negN/A
associate-*r/N/A
mul-1-negN/A
distribute-lft-neg-inN/A
metadata-evalN/A
*-lft-identityN/A
lower-exp.f64N/A
lower-/.f64N/A
lower-log.f64N/A
lower-*.f6455.1
Applied rewrites55.1%
Taylor expanded in n around inf
Applied rewrites37.0%
Applied rewrites36.5%
Final simplification36.5%
herbie shell --seed 2024353
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))