
(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 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\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 (exp (/ (log x) n))))
(if (<= (/ 1.0 n) -1e-13)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 1.5e-182)
(/
(-
(fma 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n) (log1p x))
(log x))
n)
(if (<= (/ 1.0 n) 50.0)
(/ (fma (/ (/ (+ -0.5 (/ 0.5 n)) n) x) t_0 (/ t_0 n)) x)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double tmp;
if ((1.0 / n) <= -1e-13) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1.5e-182) {
tmp = (fma(0.5, ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n), log1p(x)) - log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = fma((((-0.5 + (0.5 / n)) / n) / x), t_0, (t_0 / n)) / x;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) tmp = 0.0 if (Float64(1.0 / n) <= -1e-13) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 1.5e-182) tmp = Float64(Float64(fma(0.5, Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n), log1p(x)) - log(x)) / n); elseif (Float64(1.0 / n) <= 50.0) 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 ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-13], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.5e-182], 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[(1.0 / n), $MachinePrecision], 50.0], 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[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-13}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.5 \cdot 10^{-182}:\\
\;\;\;\;\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}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\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(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1e-13Initial program 96.5%
Taylor expanded in x around inf
Applied rewrites98.8%
if -1e-13 < (/.f64 #s(literal 1 binary64) n) < 1.5000000000000001e-182Initial program 41.3%
Taylor expanded in n around inf
Applied rewrites83.7%
if 1.5000000000000001e-182 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 20.0%
Taylor expanded in x around inf
Applied rewrites67.7%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
Taylor expanded in n around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(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 -2.0)
(- 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, (1.0 / n));
double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
double tmp;
if (t_1 <= -2.0) {
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 ^ Float64(1.0 / n) t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) tmp = 0.0 if (t_1 <= -2.0) 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[(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, -2.0], 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(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -2:\\
\;\;\;\;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))) < -2Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
if -2 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0Initial program 50.7%
Taylor expanded in n around inf
Applied rewrites79.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 50.1%
Taylor expanded in n around 0
Applied rewrites98.0%
Taylor expanded in x around 0
Applied rewrites75.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (exp (/ (log x) n))))
(if (<= (/ 1.0 n) -5e-122)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 1.5e-182)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 50.0)
(/ (fma (/ (/ (+ -0.5 (/ 0.5 n)) n) x) t_0 (/ t_0 n)) x)
(- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n));
double tmp;
if ((1.0 / n) <= -5e-122) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 1.5e-182) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = fma((((-0.5 + (0.5 / n)) / n) / x), t_0, (t_0 / n)) / x;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
function code(x, n) t_0 = exp(Float64(log(x) / n)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-122) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 1.5e-182) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 50.0) 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 ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-122], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1.5e-182], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], 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[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\log x}{n}}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-122}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 1.5 \cdot 10^{-182}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\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(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999999e-122Initial program 81.4%
Taylor expanded in x around inf
Applied rewrites90.6%
if -4.9999999999999999e-122 < (/.f64 #s(literal 1 binary64) n) < 1.5000000000000001e-182Initial program 46.7%
Taylor expanded in n around inf
Applied rewrites91.1%
if 1.5000000000000001e-182 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 20.0%
Taylor expanded in x around inf
Applied rewrites67.7%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
Taylor expanded in n around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (exp (/ (log x) n)) (* n x))))
(if (<= (/ 1.0 n) -5e-122)
t_0
(if (<= (/ 1.0 n) 2e-188)
(/ (- (log1p x) (log x)) n)
(if (<= (/ 1.0 n) 50.0) t_0 (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
double t_0 = exp((log(x) / n)) / (n * x);
double tmp;
if ((1.0 / n) <= -5e-122) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-188) {
tmp = (log1p(x) - log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = t_0;
} else {
tmp = exp((x / n)) - pow(x, (1.0 / n));
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.exp((Math.log(x) / n)) / (n * x);
double tmp;
if ((1.0 / n) <= -5e-122) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-188) {
tmp = (Math.log1p(x) - Math.log(x)) / n;
} else if ((1.0 / n) <= 50.0) {
tmp = t_0;
} else {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): t_0 = math.exp((math.log(x) / n)) / (n * x) tmp = 0 if (1.0 / n) <= -5e-122: tmp = t_0 elif (1.0 / n) <= 2e-188: tmp = (math.log1p(x) - math.log(x)) / n elif (1.0 / n) <= 50.0: tmp = t_0 else: tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) return tmp
function code(x, n) t_0 = Float64(exp(Float64(log(x) / n)) / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -5e-122) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-188) tmp = Float64(Float64(log1p(x) - log(x)) / n); elseif (Float64(1.0 / n) <= 50.0) tmp = t_0; else tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-122], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-188], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], t$95$0, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-122}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-188}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4.9999999999999999e-122 or 1.9999999999999999e-188 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 64.1%
Taylor expanded in x around inf
Applied rewrites84.0%
if -4.9999999999999999e-122 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e-188Initial program 47.9%
Taylor expanded in n around inf
Applied rewrites92.3%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
Taylor expanded in n around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
(FPCore (x n) :precision binary64 (if (or (<= (/ 1.0 n) -0.005) (not (<= (/ 1.0 n) 50.0))) (- (exp (/ x n)) (pow x (/ 1.0 n))) (/ (- (log1p x) (log x)) n)))
double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -0.005) || !((1.0 / n) <= 50.0)) {
tmp = exp((x / n)) - pow(x, (1.0 / n));
} else {
tmp = (log1p(x) - log(x)) / n;
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (((1.0 / n) <= -0.005) || !((1.0 / n) <= 50.0)) {
tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
} else {
tmp = (Math.log1p(x) - Math.log(x)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if ((1.0 / n) <= -0.005) or not ((1.0 / n) <= 50.0): tmp = math.exp((x / n)) - math.pow(x, (1.0 / n)) else: tmp = (math.log1p(x) - math.log(x)) / n return tmp
function code(x, n) tmp = 0.0 if ((Float64(1.0 / n) <= -0.005) || !(Float64(1.0 / n) <= 50.0)) tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(log1p(x) - log(x)) / n); end return tmp end
code[x_, n_] := If[Or[LessEqual[N[(1.0 / n), $MachinePrecision], -0.005], N[Not[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0]], $MachinePrecision]], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -0.005 \lor \neg \left(\frac{1}{n} \leq 50\right):\\
\;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.0050000000000000001 or 50 < (/.f64 #s(literal 1 binary64) n) Initial program 81.0%
Taylor expanded in n around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites100.0%
if -0.0050000000000000001 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.4%
Taylor expanded in n around inf
Applied rewrites72.8%
Final simplification86.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e+233)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -1e+124)
(- 1.0 1.0)
(if (<= (/ 1.0 n) -4000.0)
(/ (+ (* (log x) x) (* n x)) (* (* (* n x) x) n))
(if (<= (/ 1.0 n) 50.0)
(/ (- (/ (log x) (* n x)) (/ -1.0 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, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -1e+124) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= -4000.0) {
tmp = ((log(x) * x) + (n * x)) / (((n * x) * x) * n);
} else if ((1.0 / n) <= 50.0) {
tmp = ((log(x) / (n * x)) - (-1.0 / 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 ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -1e+124) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(Float64(Float64(log(x) * x) + Float64(n * x)) / Float64(Float64(Float64(n * x) * x) * n)); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(Float64(Float64(log(x) / Float64(n * x)) - Float64(-1.0 / 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[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+124], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(N[(N[(N[Log[x], $MachinePrecision] * x), $MachinePrecision] + N[(n * x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(n * x), $MachinePrecision] * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(N[(N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / 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(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{+124}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;\frac{\log x \cdot x + n \cdot x}{\left(\left(n \cdot x\right) \cdot x\right) \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{\frac{\log x}{n \cdot x} - \frac{-1}{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 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites70.5%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -9.99999999999999948e123Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites16.3%
Taylor expanded in n around inf
Applied rewrites86.6%
if -9.99999999999999948e123 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Taylor expanded in n around -inf
Applied rewrites29.4%
Applied rewrites68.9%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.9%
Taylor expanded in x around inf
Applied rewrites59.3%
Taylor expanded in n around -inf
Applied rewrites57.9%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
Taylor expanded in n around 0
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites76.8%
Final simplification66.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e+233)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -1e+124)
(- 1.0 1.0)
(if (<= (/ 1.0 n) -4000.0)
(/ (+ (* (log x) x) (* n x)) (* (* (* n x) x) n))
(if (<= (/ 1.0 n) 50.0)
(/ (- (/ (log x) (* n x)) (/ -1.0 x)) n)
(- (fma (* (- (/ 0.5 n) 0.5) (/ x n)) x 1.0) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -1e+124) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= -4000.0) {
tmp = ((log(x) * x) + (n * x)) / (((n * x) * x) * n);
} else if ((1.0 / n) <= 50.0) {
tmp = ((log(x) / (n * x)) - (-1.0 / x)) / n;
} else {
tmp = fma((((0.5 / n) - 0.5) * (x / n)), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -1e+124) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(Float64(Float64(log(x) * x) + Float64(n * x)) / Float64(Float64(Float64(n * x) * x) * n)); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(Float64(Float64(log(x) / Float64(n * x)) - Float64(-1.0 / x)) / n); else tmp = Float64(fma(Float64(Float64(Float64(0.5 / n) - 0.5) * Float64(x / n)), x, 1.0) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+124], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(N[(N[(N[Log[x], $MachinePrecision] * x), $MachinePrecision] + N[(n * x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(n * x), $MachinePrecision] * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(N[(N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(0.5 / n), $MachinePrecision] - 0.5), $MachinePrecision] * N[(x / n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{+124}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;\frac{\log x \cdot x + n \cdot x}{\left(\left(n \cdot x\right) \cdot x\right) \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{\frac{\log x}{n \cdot x} - \frac{-1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{0.5}{n} - 0.5\right) \cdot \frac{x}{n}, x, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites70.5%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -9.99999999999999948e123Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites16.3%
Taylor expanded in n around inf
Applied rewrites86.6%
if -9.99999999999999948e123 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Taylor expanded in n around -inf
Applied rewrites29.4%
Applied rewrites68.9%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.9%
Taylor expanded in x around inf
Applied rewrites59.3%
Taylor expanded in n around -inf
Applied rewrites57.9%
if 50 < (/.f64 #s(literal 1 binary64) n) Initial program 51.1%
Taylor expanded in x around 0
Applied rewrites70.8%
Taylor expanded in x around inf
Applied rewrites75.1%
Final simplification66.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e+233)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -1e+124)
(- 1.0 1.0)
(if (<= (/ 1.0 n) -4000.0)
(/ (+ (* (log x) x) (* n x)) (* (* (* n x) x) n))
(if (<= (/ 1.0 n) 50.0)
(/ (- (/ (log x) (* n x)) (/ -1.0 x)) n)
(if (<= (/ 1.0 n) 1e+188)
(- (- (/ x n) -1.0) t_0)
(- (fma (/ n (* n n)) x 1.0) 1.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -1e+124) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= -4000.0) {
tmp = ((log(x) * x) + (n * x)) / (((n * x) * x) * n);
} else if ((1.0 / n) <= 50.0) {
tmp = ((log(x) / (n * x)) - (-1.0 / x)) / n;
} else if ((1.0 / n) <= 1e+188) {
tmp = ((x / n) - -1.0) - t_0;
} else {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -1e+124) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(Float64(Float64(log(x) * x) + Float64(n * x)) / Float64(Float64(Float64(n * x) * x) * n)); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(Float64(Float64(log(x) / Float64(n * x)) - Float64(-1.0 / x)) / n); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(Float64(Float64(x / n) - -1.0) - t_0); else tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+124], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(N[(N[(N[Log[x], $MachinePrecision] * x), $MachinePrecision] + N[(n * x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(n * x), $MachinePrecision] * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(N[(N[(N[Log[x], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(-1.0 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(N[(N[(x / n), $MachinePrecision] - -1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{+124}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;\frac{\log x \cdot x + n \cdot x}{\left(\left(n \cdot x\right) \cdot x\right) \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{\frac{\log x}{n \cdot x} - \frac{-1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;\left(\frac{x}{n} - -1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites70.5%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -9.99999999999999948e123Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites16.3%
Taylor expanded in n around inf
Applied rewrites86.6%
if -9.99999999999999948e123 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites100.0%
Taylor expanded in n around -inf
Applied rewrites29.4%
Applied rewrites68.9%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.9%
Taylor expanded in x around inf
Applied rewrites59.3%
Taylor expanded in n around -inf
Applied rewrites57.9%
if 50 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 72.7%
Taylor expanded in x around 0
Applied rewrites72.1%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 13.9%
Taylor expanded in x around 0
Applied rewrites89.2%
Taylor expanded in n around inf
Applied rewrites89.2%
Taylor expanded in n around 0
Applied rewrites89.2%
Taylor expanded in x around 0
Applied rewrites89.2%
Final simplification66.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -1e+233)
(- 1.0 t_0)
(if (<= (/ 1.0 n) -4000.0)
(- 1.0 1.0)
(if (<= (/ 1.0 n) 50.0)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 1e+188)
(- (- (/ x n) -1.0) t_0)
(- (fma (/ n (* n n)) x 1.0) 1.0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = 1.0 - t_0;
} else if ((1.0 / n) <= -4000.0) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= 50.0) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 1e+188) {
tmp = ((x / n) - -1.0) - t_0;
} else {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(1.0 - t_0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 1e+188) tmp = Float64(Float64(Float64(x / n) - -1.0) - t_0); else tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], N[(N[(N[(x / n), $MachinePrecision] - -1.0), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;\left(\frac{x}{n} - -1\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites70.5%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.9%
Taylor expanded in x around inf
Applied rewrites59.3%
Taylor expanded in n around -inf
Applied rewrites57.9%
Taylor expanded in n around inf
Applied rewrites57.3%
if 50 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 72.7%
Taylor expanded in x around 0
Applied rewrites72.1%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 13.9%
Taylor expanded in x around 0
Applied rewrites89.2%
Taylor expanded in n around inf
Applied rewrites89.2%
Taylor expanded in n around 0
Applied rewrites89.2%
Taylor expanded in x around 0
Applied rewrites89.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -1e+233)
t_0
(if (<= (/ 1.0 n) -4000.0)
(- 1.0 1.0)
(if (<= (/ 1.0 n) 50.0)
(/ (/ 1.0 n) x)
(if (<= (/ 1.0 n) 1e+188) t_0 (- (fma (/ n (* n n)) x 1.0) 1.0)))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = t_0;
} else if ((1.0 / n) <= -4000.0) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= 50.0) {
tmp = (1.0 / n) / x;
} else if ((1.0 / n) <= 1e+188) {
tmp = t_0;
} else {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
}
return tmp;
}
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = t_0; elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= 50.0) tmp = Float64(Float64(1.0 / n) / x); elseif (Float64(1.0 / n) <= 1e+188) tmp = t_0; else tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+188], t$95$0, N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq 50:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+188}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232 or 50 < (/.f64 #s(literal 1 binary64) n) < 1e188Initial program 84.3%
Taylor expanded in x around 0
Applied rewrites70.0%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 50Initial program 34.9%
Taylor expanded in x around inf
Applied rewrites59.3%
Taylor expanded in n around -inf
Applied rewrites57.9%
Taylor expanded in n around inf
Applied rewrites57.3%
if 1e188 < (/.f64 #s(literal 1 binary64) n) Initial program 13.9%
Taylor expanded in x around 0
Applied rewrites89.2%
Taylor expanded in n around inf
Applied rewrites89.2%
Taylor expanded in n around 0
Applied rewrites89.2%
Taylor expanded in x around 0
Applied rewrites89.2%
(FPCore (x n)
:precision binary64
(if (<= n -200.0)
(/ (+ (/ (log x) n) 1.0) (* n x))
(if (<= n -4.6e-117)
(/ (+ (* (log x) x) (* n x)) (* (* (* n x) x) n))
(if (<= n -1e-227)
(- 1.0 1.0)
(if (<= n 3.5e-190)
(- (fma (/ n (* n n)) x 1.0) 1.0)
(if (<= n 0.03)
(- (- (/ x n) -1.0) (pow x (/ 1.0 n)))
(/ (/ 1.0 n) x)))))))
double code(double x, double n) {
double tmp;
if (n <= -200.0) {
tmp = ((log(x) / n) + 1.0) / (n * x);
} else if (n <= -4.6e-117) {
tmp = ((log(x) * x) + (n * x)) / (((n * x) * x) * n);
} else if (n <= -1e-227) {
tmp = 1.0 - 1.0;
} else if (n <= 3.5e-190) {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
} else if (n <= 0.03) {
tmp = ((x / n) - -1.0) - pow(x, (1.0 / n));
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (n <= -200.0) tmp = Float64(Float64(Float64(log(x) / n) + 1.0) / Float64(n * x)); elseif (n <= -4.6e-117) tmp = Float64(Float64(Float64(log(x) * x) + Float64(n * x)) / Float64(Float64(Float64(n * x) * x) * n)); elseif (n <= -1e-227) tmp = Float64(1.0 - 1.0); elseif (n <= 3.5e-190) tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); elseif (n <= 0.03) tmp = Float64(Float64(Float64(x / n) - -1.0) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[n, -200.0], N[(N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -4.6e-117], N[(N[(N[(N[Log[x], $MachinePrecision] * x), $MachinePrecision] + N[(n * x), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(n * x), $MachinePrecision] * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1e-227], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[n, 3.5e-190], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[n, 0.03], N[(N[(N[(x / n), $MachinePrecision] - -1.0), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -200:\\
\;\;\;\;\frac{\frac{\log x}{n} + 1}{n \cdot x}\\
\mathbf{elif}\;n \leq -4.6 \cdot 10^{-117}:\\
\;\;\;\;\frac{\log x \cdot x + n \cdot x}{\left(\left(n \cdot x\right) \cdot x\right) \cdot n}\\
\mathbf{elif}\;n \leq -1 \cdot 10^{-227}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\mathbf{elif}\;n \leq 0.03:\\
\;\;\;\;\left(\frac{x}{n} - -1\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -200Initial program 31.7%
Taylor expanded in x around inf
Applied rewrites53.6%
Taylor expanded in n around inf
Applied rewrites52.1%
if -200 < n < -4.59999999999999989e-117Initial program 100.0%
Taylor expanded in x around inf
Applied rewrites97.1%
Taylor expanded in n around -inf
Applied rewrites28.7%
Applied rewrites67.0%
if -4.59999999999999989e-117 < n < -9.99999999999999945e-228Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites16.3%
Taylor expanded in n around inf
Applied rewrites86.6%
if -9.99999999999999945e-228 < n < 3.4999999999999999e-190Initial program 62.2%
Taylor expanded in x around 0
Applied rewrites39.4%
Taylor expanded in n around inf
Applied rewrites39.4%
Taylor expanded in n around 0
Applied rewrites44.3%
Taylor expanded in x around 0
Applied rewrites78.5%
if 3.4999999999999999e-190 < n < 0.029999999999999999Initial program 72.7%
Taylor expanded in x around 0
Applied rewrites72.1%
if 0.029999999999999999 < n Initial program 36.7%
Taylor expanded in x around inf
Applied rewrites64.8%
Taylor expanded in n around -inf
Applied rewrites63.5%
Taylor expanded in n around inf
Applied rewrites63.4%
Final simplification66.7%
(FPCore (x n)
:precision binary64
(if (<= n -15.0)
(/ (+ (/ (log x) n) 1.0) (* n x))
(if (<= n -1e-227)
(- 1.0 1.0)
(if (<= n 3.5e-190)
(- (fma (/ n (* n n)) x 1.0) 1.0)
(if (<= n 0.03)
(- (- (/ x n) -1.0) (pow x (/ 1.0 n)))
(/ (/ 1.0 n) x))))))
double code(double x, double n) {
double tmp;
if (n <= -15.0) {
tmp = ((log(x) / n) + 1.0) / (n * x);
} else if (n <= -1e-227) {
tmp = 1.0 - 1.0;
} else if (n <= 3.5e-190) {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
} else if (n <= 0.03) {
tmp = ((x / n) - -1.0) - pow(x, (1.0 / n));
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (n <= -15.0) tmp = Float64(Float64(Float64(log(x) / n) + 1.0) / Float64(n * x)); elseif (n <= -1e-227) tmp = Float64(1.0 - 1.0); elseif (n <= 3.5e-190) tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); elseif (n <= 0.03) tmp = Float64(Float64(Float64(x / n) - -1.0) - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[n, -15.0], N[(N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1e-227], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[n, 3.5e-190], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[n, 0.03], N[(N[(N[(x / n), $MachinePrecision] - -1.0), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -15:\\
\;\;\;\;\frac{\frac{\log x}{n} + 1}{n \cdot x}\\
\mathbf{elif}\;n \leq -1 \cdot 10^{-227}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;n \leq 3.5 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\mathbf{elif}\;n \leq 0.03:\\
\;\;\;\;\left(\frac{x}{n} - -1\right) - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -15Initial program 32.8%
Taylor expanded in x around inf
Applied rewrites52.9%
Taylor expanded in n around inf
Applied rewrites51.3%
if -15 < n < -9.99999999999999945e-228Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -9.99999999999999945e-228 < n < 3.4999999999999999e-190Initial program 62.2%
Taylor expanded in x around 0
Applied rewrites39.4%
Taylor expanded in n around inf
Applied rewrites39.4%
Taylor expanded in n around 0
Applied rewrites44.3%
Taylor expanded in x around 0
Applied rewrites78.5%
if 3.4999999999999999e-190 < n < 0.029999999999999999Initial program 72.7%
Taylor expanded in x around 0
Applied rewrites72.1%
if 0.029999999999999999 < n Initial program 36.7%
Taylor expanded in x around inf
Applied rewrites64.8%
Taylor expanded in n around -inf
Applied rewrites63.5%
Taylor expanded in n around inf
Applied rewrites63.4%
(FPCore (x n)
:precision binary64
(if (<= (/ 1.0 n) -1e+233)
(- (fma (/ n (* n n)) x 1.0) 1.0)
(if (<= (/ 1.0 n) -4000.0)
(- 1.0 1.0)
(if (<= (/ 1.0 n) 1e-5)
(/ (/ 1.0 n) x)
(-
(fma
(fma
(-
(/
(fma
-0.3333333333333333
x
(/ (- (fma 0.16666666666666666 (/ x n) (* -0.5 x)) -0.5) (- n)))
(- n))
(/ 0.5 n))
x
(/ 1.0 n))
x
1.0)
1.0)))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
} else if ((1.0 / n) <= -4000.0) {
tmp = 1.0 - 1.0;
} else if ((1.0 / n) <= 1e-5) {
tmp = (1.0 / n) / x;
} else {
tmp = fma(fma(((fma(-0.3333333333333333, x, ((fma(0.16666666666666666, (x / n), (-0.5 * x)) - -0.5) / -n)) / -n) - (0.5 / n)), x, (1.0 / n)), x, 1.0) - 1.0;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(1.0 - 1.0); elseif (Float64(1.0 / n) <= 1e-5) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(fma(fma(Float64(Float64(fma(-0.3333333333333333, x, Float64(Float64(fma(0.16666666666666666, Float64(x / n), Float64(-0.5 * x)) - -0.5) / Float64(-n))) / Float64(-n)) - Float64(0.5 / n)), x, Float64(1.0 / n)), x, 1.0) - 1.0); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-5], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + N[(N[(N[(0.16666666666666666 * N[(x / n), $MachinePrecision] + N[(-0.5 * x), $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * x + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{\mathsf{fma}\left(-0.3333333333333333, x, \frac{\mathsf{fma}\left(0.16666666666666666, \frac{x}{n}, -0.5 \cdot x\right) - -0.5}{-n}\right)}{-n} - \frac{0.5}{n}, x, \frac{1}{n}\right), x, 1\right) - 1\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites0.5%
Taylor expanded in n around inf
Applied rewrites0.5%
Taylor expanded in n around 0
Applied rewrites9.2%
Taylor expanded in x around 0
Applied rewrites70.0%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -4e3 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5Initial program 35.2%
Taylor expanded in x around inf
Applied rewrites59.0%
Taylor expanded in n around -inf
Applied rewrites58.3%
Taylor expanded in n around inf
Applied rewrites57.7%
if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) Initial program 50.1%
Taylor expanded in x around 0
Applied rewrites48.1%
Taylor expanded in n around inf
Applied rewrites2.3%
Taylor expanded in x around 0
Applied rewrites13.8%
Taylor expanded in n around -inf
Applied rewrites42.7%
Final simplification57.7%
(FPCore (x n)
:precision binary64
(if (<= n -8.5)
(/ 1.0 (* n x))
(if (<= n -1e-227)
(- 1.0 1.0)
(if (<= n 0.5)
(-
(fma
(fma
(-
(/
(fma
(/ x n)
-0.5
(fma
(/ x (* n n))
0.16666666666666666
(fma 0.3333333333333333 x (/ 0.5 n))))
n)
(/ 0.5 n))
x
(/ 1.0 n))
x
1.0)
1.0)
(/ (/ 1.0 n) x)))))
double code(double x, double n) {
double tmp;
if (n <= -8.5) {
tmp = 1.0 / (n * x);
} else if (n <= -1e-227) {
tmp = 1.0 - 1.0;
} else if (n <= 0.5) {
tmp = fma(fma(((fma((x / n), -0.5, fma((x / (n * n)), 0.16666666666666666, fma(0.3333333333333333, x, (0.5 / n)))) / n) - (0.5 / n)), x, (1.0 / n)), x, 1.0) - 1.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (n <= -8.5) tmp = Float64(1.0 / Float64(n * x)); elseif (n <= -1e-227) tmp = Float64(1.0 - 1.0); elseif (n <= 0.5) tmp = Float64(fma(fma(Float64(Float64(fma(Float64(x / n), -0.5, fma(Float64(x / Float64(n * n)), 0.16666666666666666, fma(0.3333333333333333, x, Float64(0.5 / n)))) / n) - Float64(0.5 / n)), x, Float64(1.0 / n)), x, 1.0) - 1.0); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[n, -8.5], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -1e-227], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[n, 0.5], N[(N[(N[(N[(N[(N[(N[(x / n), $MachinePrecision] * -0.5 + N[(N[(x / N[(n * n), $MachinePrecision]), $MachinePrecision] * 0.16666666666666666 + N[(0.3333333333333333 * x + N[(0.5 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * x + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;n \leq -1 \cdot 10^{-227}:\\
\;\;\;\;1 - 1\\
\mathbf{elif}\;n \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{x}{n}, -0.5, \mathsf{fma}\left(\frac{x}{n \cdot n}, 0.16666666666666666, \mathsf{fma}\left(0.3333333333333333, x, \frac{0.5}{n}\right)\right)\right)}{n} - \frac{0.5}{n}, x, \frac{1}{n}\right), x, 1\right) - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -8.5Initial program 32.8%
Taylor expanded in x around inf
Applied rewrites52.9%
Taylor expanded in n around inf
Applied rewrites50.2%
if -8.5 < n < -9.99999999999999945e-228Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -9.99999999999999945e-228 < n < 0.5Initial program 65.8%
Taylor expanded in x around 0
Applied rewrites55.2%
Taylor expanded in n around inf
Applied rewrites11.5%
Taylor expanded in x around 0
Applied rewrites9.5%
Taylor expanded in n around inf
Applied rewrites51.3%
if 0.5 < n Initial program 37.3%
Taylor expanded in x around inf
Applied rewrites64.3%
Taylor expanded in n around -inf
Applied rewrites64.4%
Taylor expanded in n around inf
Applied rewrites64.2%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -1e+233) (- (fma (/ n (* n n)) x 1.0) 1.0) (if (<= (/ 1.0 n) -4000.0) (- 1.0 1.0) (/ (/ 1.0 n) x))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -1e+233) {
tmp = fma((n / (n * n)), x, 1.0) - 1.0;
} else if ((1.0 / n) <= -4000.0) {
tmp = 1.0 - 1.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+233) tmp = Float64(fma(Float64(n / Float64(n * n)), x, 1.0) - 1.0); elseif (Float64(1.0 / n) <= -4000.0) tmp = Float64(1.0 - 1.0); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+233], N[(N[(N[(n / N[(n * n), $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - 1.0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000.0], N[(1.0 - 1.0), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+233}:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{n \cdot n}, x, 1\right) - 1\\
\mathbf{elif}\;\frac{1}{n} \leq -4000:\\
\;\;\;\;1 - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -9.99999999999999974e232Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites0.5%
Taylor expanded in n around inf
Applied rewrites0.5%
Taylor expanded in n around 0
Applied rewrites9.2%
Taylor expanded in x around 0
Applied rewrites70.0%
if -9.99999999999999974e232 < (/.f64 #s(literal 1 binary64) n) < -4e3Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -4e3 < (/.f64 #s(literal 1 binary64) n) Initial program 39.3%
Taylor expanded in x around inf
Applied rewrites43.5%
Taylor expanded in n around -inf
Applied rewrites42.2%
Taylor expanded in n around inf
Applied rewrites50.9%
(FPCore (x n) :precision binary64 (if (<= n -8.5) (/ 1.0 (* n x)) (if (<= n -8.8e-230) (- 1.0 1.0) (/ (/ 1.0 n) x))))
double code(double x, double n) {
double tmp;
if (n <= -8.5) {
tmp = 1.0 / (n * x);
} else if (n <= -8.8e-230) {
tmp = 1.0 - 1.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-8.5d0)) then
tmp = 1.0d0 / (n * x)
else if (n <= (-8.8d-230)) then
tmp = 1.0d0 - 1.0d0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -8.5) {
tmp = 1.0 / (n * x);
} else if (n <= -8.8e-230) {
tmp = 1.0 - 1.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -8.5: tmp = 1.0 / (n * x) elif n <= -8.8e-230: tmp = 1.0 - 1.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (n <= -8.5) tmp = Float64(1.0 / Float64(n * x)); elseif (n <= -8.8e-230) tmp = Float64(1.0 - 1.0); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -8.5) tmp = 1.0 / (n * x); elseif (n <= -8.8e-230) tmp = 1.0 - 1.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -8.5], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, -8.8e-230], N[(1.0 - 1.0), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -8.5:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;n \leq -8.8 \cdot 10^{-230}:\\
\;\;\;\;1 - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if n < -8.5Initial program 32.8%
Taylor expanded in x around inf
Applied rewrites52.9%
Taylor expanded in n around inf
Applied rewrites50.2%
if -8.5 < n < -8.79999999999999922e-230Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
if -8.79999999999999922e-230 < n Initial program 51.8%
Taylor expanded in x around inf
Applied rewrites48.7%
Taylor expanded in n around -inf
Applied rewrites43.0%
Taylor expanded in n around inf
Applied rewrites51.8%
(FPCore (x n) :precision binary64 (if (or (<= n -8.5) (not (<= n -8.8e-230))) (/ 1.0 (* n x)) (- 1.0 1.0)))
double code(double x, double n) {
double tmp;
if ((n <= -8.5) || !(n <= -8.8e-230)) {
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 <= (-8.5d0)) .or. (.not. (n <= (-8.8d-230)))) 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 <= -8.5) || !(n <= -8.8e-230)) {
tmp = 1.0 / (n * x);
} else {
tmp = 1.0 - 1.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -8.5) or not (n <= -8.8e-230): tmp = 1.0 / (n * x) else: tmp = 1.0 - 1.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -8.5) || !(n <= -8.8e-230)) 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 <= -8.5) || ~((n <= -8.8e-230))) tmp = 1.0 / (n * x); else tmp = 1.0 - 1.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -8.5], N[Not[LessEqual[n, -8.8e-230]], $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 -8.5 \lor \neg \left(n \leq -8.8 \cdot 10^{-230}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;1 - 1\\
\end{array}
\end{array}
if n < -8.5 or -8.79999999999999922e-230 < n Initial program 46.2%
Taylor expanded in x around inf
Applied rewrites49.9%
Taylor expanded in n around inf
Applied rewrites51.0%
if -8.5 < n < -8.79999999999999922e-230Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites36.0%
Taylor expanded in n around inf
Applied rewrites66.6%
Final simplification54.2%
(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 57.3%
Taylor expanded in x around 0
Applied rewrites41.0%
Taylor expanded in n around inf
Applied rewrites34.1%
herbie shell --seed 2025026
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))