
(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 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ (pow n -1.0) 4.0))))
(if (or (<= n -3600000.0) (not (<= n 5600000.0)))
(/ (log1p (pow x -1.0)) n)
(fma (* (- (sqrt (pow x (pow n -1.0)))) t_0) t_0 (exp (/ (log1p x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (pow(n, -1.0) / 4.0));
double tmp;
if ((n <= -3600000.0) || !(n <= 5600000.0)) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma((-sqrt(pow(x, pow(n, -1.0))) * t_0), t_0, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64((n ^ -1.0) / 4.0) tmp = 0.0 if ((n <= -3600000.0) || !(n <= 5600000.0)) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = fma(Float64(Float64(-sqrt((x ^ (n ^ -1.0)))) * t_0), t_0, exp(Float64(log1p(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(N[Power[n, -1.0], $MachinePrecision] / 4.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[n, -3600000.0], N[Not[LessEqual[n, 5600000.0]], $MachinePrecision]], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[((-N[Sqrt[N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]) * t$95$0), $MachinePrecision] * t$95$0 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{{n}^{-1}}{4}\right)}\\
\mathbf{if}\;n \leq -3600000 \lor \neg \left(n \leq 5600000\right):\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-\sqrt{{x}^{\left({n}^{-1}\right)}}\right) \cdot t\_0, t\_0, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if n < -3.6e6 or 5.6e6 < n Initial program 29.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.8
Applied rewrites75.8%
Applied rewrites76.0%
Taylor expanded in n around 0
Applied rewrites99.3%
if -3.6e6 < n < 5.6e6Initial program 84.8%
lift--.f64N/A
lift-pow.f64N/A
sqr-powN/A
fp-cancel-sub-sign-invN/A
distribute-lft-neg-inN/A
sqr-powN/A
lift-pow.f64N/A
+-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
distribute-lft-neg-inN/A
sqr-powN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.8%
Final simplification97.8%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -20.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(-
(fma (fma (/ (+ -0.5 (/ 0.5 n)) n) x (pow n -1.0)) x 1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(fma(((-0.5 + (0.5 / n)) / n), x, pow(n, -1.0)), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(fma(Float64(Float64(-0.5 + Float64(0.5 / n)) / n), x, (n ^ -1.0)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] * x + N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\frac{-0.5 + \frac{0.5}{n}}{n}, x, {n}^{-1}\right), x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites72.3%
if -20 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.0
Applied rewrites75.0%
Applied rewrites75.2%
Taylor expanded in n around 0
Applied rewrites98.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
Taylor expanded in x around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites71.0%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (pow n -1.0))))
(if (<= (pow n -1.0) -1e-5)
(- (pow (+ x 1.0) (pow n -1.0)) t_0)
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
t_0)))))
double code(double x, double n) {
double t_0 = pow(x, pow(n, -1.0));
double tmp;
if (pow(n, -1.0) <= -1e-5) {
tmp = pow((x + 1.0), pow(n, -1.0)) - t_0;
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - t_0;
}
return tmp;
}
function code(x, n) t_0 = x ^ (n ^ -1.0) tmp = 0.0 if ((n ^ -1.0) <= -1e-5) tmp = Float64((Float64(x + 1.0) ^ (n ^ -1.0)) - t_0); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-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]}, If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1e-5], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 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)}\\
\mathbf{if}\;{n}^{-1} \leq -1 \cdot 10^{-5}:\\
\;\;\;\;{\left(x + 1\right)}^{\left({n}^{-1}\right)} - t\_0\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.00000000000000008e-5Initial program 99.1%
if -1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 29.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.8
Applied rewrites75.8%
Applied rewrites76.0%
Taylor expanded in n around 0
Applied rewrites99.3%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
Taylor expanded in x around 0
Applied rewrites33.1%
Taylor expanded in n around -inf
Applied rewrites76.2%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -1.6e-5)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -1.6e-5) {
tmp = exp((log(x) / n)) / (n * x);
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -1.6e-5) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -1.6e-5], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -1.6 \cdot 10^{-5}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -1.59999999999999993e-5Initial program 99.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-*.f6499.2
Applied rewrites99.2%
if -1.59999999999999993e-5 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 30.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.2
Applied rewrites75.2%
Applied rewrites75.4%
Taylor expanded in n around 0
Applied rewrites98.4%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
Taylor expanded in x around 0
Applied rewrites33.1%
Taylor expanded in n around -inf
Applied rewrites76.2%
Final simplification95.4%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -20.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(/
(fma (/ (* x x) n) 0.16666666666666666 (* (fma -0.5 x 0.5) x))
(- n)))
1.0)
(- n))
x
1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, (fma(((x * x) / n), 0.16666666666666666, (fma(-0.5, x, 0.5) * x)) / -n)) - 1.0) / -n), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(fma(Float64(Float64(x * x) / n), 0.16666666666666666, Float64(fma(-0.5, x, 0.5) * x)) / Float64(-n))) - 1.0) / Float64(-n)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision] * 0.16666666666666666 + N[(N[(-0.5 * x + 0.5), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / (-n)), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{\mathsf{fma}\left(\frac{x \cdot x}{n}, 0.16666666666666666, \mathsf{fma}\left(-0.5, x, 0.5\right) \cdot x\right)}{-n}\right) - 1}{-n}, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites72.3%
if -20 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.0
Applied rewrites75.0%
Applied rewrites75.2%
Taylor expanded in n around 0
Applied rewrites98.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
Taylor expanded in x around 0
Applied rewrites33.1%
Taylor expanded in n around -inf
Applied rewrites76.2%
Final simplification87.9%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -20.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(-
(fma
(/
(-
(fma
(fma -0.3333333333333333 x 0.5)
x
(* (/ -0.16666666666666666 n) (/ (* x x) n)))
1.0)
(- n))
x
1.0)
(pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = fma(((fma(fma(-0.3333333333333333, x, 0.5), x, ((-0.16666666666666666 / n) * ((x * x) / n))) - 1.0) / -n), x, 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(fma(Float64(Float64(fma(fma(-0.3333333333333333, x, 0.5), x, Float64(Float64(-0.16666666666666666 / n) * Float64(Float64(x * x) / n))) - 1.0) / Float64(-n)), x, 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(N[(N[(N[(-0.3333333333333333 * x + 0.5), $MachinePrecision] * x + N[(N[(-0.16666666666666666 / n), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] / (-n)), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.3333333333333333, x, 0.5\right), x, \frac{-0.16666666666666666}{n} \cdot \frac{x \cdot x}{n}\right) - 1}{-n}, x, 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites72.3%
if -20 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.0
Applied rewrites75.0%
Applied rewrites75.2%
Taylor expanded in n around 0
Applied rewrites98.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
Taylor expanded in x around 0
Applied rewrites33.1%
Taylor expanded in n around -inf
Applied rewrites76.2%
Taylor expanded in n around 0
Applied rewrites73.7%
Final simplification87.6%
(FPCore (x n)
:precision binary64
(if (<= (pow n -1.0) -20.0)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= (pow n -1.0) 5e-12)
(/ (log1p (pow x -1.0)) n)
(- (+ (/ x n) 1.0) (pow x (pow n -1.0))))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (pow(n, -1.0) <= 5e-12) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = ((x / n) + 1.0) - pow(x, pow(n, -1.0));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (Math.pow(n, -1.0) <= -20.0) {
tmp = 0.3333333333333333 / (Math.pow(x, 3.0) * n);
} else if (Math.pow(n, -1.0) <= 5e-12) {
tmp = Math.log1p(Math.pow(x, -1.0)) / n;
} else {
tmp = ((x / n) + 1.0) - Math.pow(x, Math.pow(n, -1.0));
}
return tmp;
}
def code(x, n): tmp = 0 if math.pow(n, -1.0) <= -20.0: tmp = 0.3333333333333333 / (math.pow(x, 3.0) * n) elif math.pow(n, -1.0) <= 5e-12: tmp = math.log1p(math.pow(x, -1.0)) / n else: tmp = ((x / n) + 1.0) - math.pow(x, math.pow(n, -1.0)) return tmp
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif ((n ^ -1.0) <= 5e-12) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(Float64(Float64(x / n) + 1.0) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Power[n, -1.0], $MachinePrecision], 5e-12], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(x / n), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;{n}^{-1} \leq 5 \cdot 10^{-12}:\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites72.3%
if -20 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.0
Applied rewrites75.0%
Applied rewrites75.2%
Taylor expanded in n around 0
Applied rewrites98.0%
if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) Initial program 56.9%
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-/.f6453.1
Applied rewrites53.1%
Final simplification84.6%
(FPCore (x n) :precision binary64 (if (or (<= n -240000000.0) (not (<= n 7000000.0))) (/ (log1p (pow x -1.0)) n) (- (exp (/ (log1p x) n)) (pow x (pow n -1.0)))))
double code(double x, double n) {
double tmp;
if ((n <= -240000000.0) || !(n <= 7000000.0)) {
tmp = log1p(pow(x, -1.0)) / n;
} else {
tmp = exp((log1p(x) / n)) - pow(x, pow(n, -1.0));
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((n <= -240000000.0) || !(n <= 7000000.0)) {
tmp = Math.log1p(Math.pow(x, -1.0)) / n;
} else {
tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, Math.pow(n, -1.0));
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -240000000.0) or not (n <= 7000000.0): tmp = math.log1p(math.pow(x, -1.0)) / n else: tmp = math.exp((math.log1p(x) / n)) - math.pow(x, math.pow(n, -1.0)) return tmp
function code(x, n) tmp = 0.0 if ((n <= -240000000.0) || !(n <= 7000000.0)) tmp = Float64(log1p((x ^ -1.0)) / n); else tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ (n ^ -1.0))); end return tmp end
code[x_, n_] := If[Or[LessEqual[n, -240000000.0], N[Not[LessEqual[n, 7000000.0]], $MachinePrecision]], N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -240000000 \lor \neg \left(n \leq 7000000\right):\\
\;\;\;\;\frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left({n}^{-1}\right)}\\
\end{array}
\end{array}
if n < -2.4e8 or 7e6 < n Initial program 29.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.8
Applied rewrites75.8%
Applied rewrites76.0%
Taylor expanded in n around 0
Applied rewrites99.3%
if -2.4e8 < n < 7e6Initial program 84.8%
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.f6495.7
Applied rewrites95.7%
Final simplification97.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log1p (pow x -1.0)) n)))
(if (<= n -10.0)
t_0
(if (<= n 7e-156)
(/ 0.3333333333333333 (* (pow x 3.0) n))
(if (<= n 1800000.0) (- 1.0 (pow x (pow n -1.0))) t_0)))))
double code(double x, double n) {
double t_0 = log1p(pow(x, -1.0)) / n;
double tmp;
if (n <= -10.0) {
tmp = t_0;
} else if (n <= 7e-156) {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
} else if (n <= 1800000.0) {
tmp = 1.0 - pow(x, pow(n, -1.0));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p(Math.pow(x, -1.0)) / n;
double tmp;
if (n <= -10.0) {
tmp = t_0;
} else if (n <= 7e-156) {
tmp = 0.3333333333333333 / (Math.pow(x, 3.0) * n);
} else if (n <= 1800000.0) {
tmp = 1.0 - Math.pow(x, Math.pow(n, -1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log1p(math.pow(x, -1.0)) / n tmp = 0 if n <= -10.0: tmp = t_0 elif n <= 7e-156: tmp = 0.3333333333333333 / (math.pow(x, 3.0) * n) elif n <= 1800000.0: tmp = 1.0 - math.pow(x, math.pow(n, -1.0)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log1p((x ^ -1.0)) / n) tmp = 0.0 if (n <= -10.0) tmp = t_0; elseif (n <= 7e-156) tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); elseif (n <= 1800000.0) tmp = Float64(1.0 - (x ^ (n ^ -1.0))); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -10.0], t$95$0, If[LessEqual[n, 7e-156], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1800000.0], N[(1.0 - N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left({x}^{-1}\right)}{n}\\
\mathbf{if}\;n \leq -10:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 7 \cdot 10^{-156}:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\mathbf{elif}\;n \leq 1800000:\\
\;\;\;\;1 - {x}^{\left({n}^{-1}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -10 or 1.8e6 < n Initial program 30.5%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6475.0
Applied rewrites75.0%
Applied rewrites75.2%
Taylor expanded in n around 0
Applied rewrites98.0%
if -10 < n < 6.9999999999999999e-156Initial program 89.2%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6448.0
Applied rewrites48.0%
Taylor expanded in x around inf
Applied rewrites19.2%
Taylor expanded in x around 0
Applied rewrites69.4%
if 6.9999999999999999e-156 < n < 1.8e6Initial program 68.7%
Taylor expanded in x around 0
Applied rewrites68.6%
Final simplification86.1%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -20.0) (/ (/ (/ (fma -0.5 x 0.3333333333333333) n) (* x x)) x) (/ (pow n -1.0) x)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = ((fma(-0.5, x, 0.3333333333333333) / n) / (x * x)) / x;
} else {
tmp = pow(n, -1.0) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(Float64(Float64(fma(-0.5, x, 0.3333333333333333) / n) / Float64(x * x)) / x); else tmp = Float64((n ^ -1.0) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(N[(N[(N[(-0.5 * x + 0.3333333333333333), $MachinePrecision] / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(-0.5, x, 0.3333333333333333\right)}{n}}{x \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{n}^{-1}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites44.8%
if -20 < (/.f64 #s(literal 1 binary64) n) Initial program 35.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6461.8
Applied rewrites61.8%
Taylor expanded in x around inf
Applied rewrites45.3%
Final simplification45.2%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -20.0) (/ (/ (/ (fma -0.5 x 0.3333333333333333) n) (* x x)) x) (/ (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) n) x)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = ((fma(-0.5, x, 0.3333333333333333) / n) / (x * x)) / x;
} else {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(Float64(Float64(fma(-0.5, x, 0.3333333333333333) / n) / Float64(x * x)) / x); else tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / n) / x); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(N[(N[(N[(-0.5 * x + 0.3333333333333333), $MachinePrecision] / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(-0.5, x, 0.3333333333333333\right)}{n}}{x \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites44.8%
if -20 < (/.f64 #s(literal 1 binary64) n) Initial program 35.7%
Taylor expanded in x around inf
Applied rewrites44.4%
Taylor expanded in n around inf
Applied rewrites46.6%
Final simplification46.1%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -20.0) (/ (/ (/ (fma -0.5 x 0.3333333333333333) n) (* x x)) x) (/ (/ (- (/ (- (/ 0.3333333333333333 x) 0.5) x) -1.0) x) n)))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = ((fma(-0.5, x, 0.3333333333333333) / n) / (x * x)) / x;
} else {
tmp = (((((0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n;
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(Float64(Float64(fma(-0.5, x, 0.3333333333333333) / n) / Float64(x * x)) / x); else tmp = Float64(Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x) - -1.0) / x) / n); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(N[(N[(N[(-0.5 * x + 0.3333333333333333), $MachinePrecision] / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision] - -1.0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(-0.5, x, 0.3333333333333333\right)}{n}}{x \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{x} - -1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites44.8%
if -20 < (/.f64 #s(literal 1 binary64) n) Initial program 35.7%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6461.8
Applied rewrites61.8%
Taylor expanded in x around -inf
Applied rewrites46.5%
Final simplification46.1%
(FPCore (x n) :precision binary64 (if (<= (pow n -1.0) -20.0) (/ (/ (/ (fma -0.5 x 0.3333333333333333) n) (* x x)) x) (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) (* n x))))
double code(double x, double n) {
double tmp;
if (pow(n, -1.0) <= -20.0) {
tmp = ((fma(-0.5, x, 0.3333333333333333) / n) / (x * x)) / x;
} else {
tmp = (((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / (n * x);
}
return tmp;
}
function code(x, n) tmp = 0.0 if ((n ^ -1.0) <= -20.0) tmp = Float64(Float64(Float64(fma(-0.5, x, 0.3333333333333333) / n) / Float64(x * x)) / x); else tmp = Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / Float64(n * x)); end return tmp end
code[x_, n_] := If[LessEqual[N[Power[n, -1.0], $MachinePrecision], -20.0], N[(N[(N[(N[(-0.5 * x + 0.3333333333333333), $MachinePrecision] / n), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;{n}^{-1} \leq -20:\\
\;\;\;\;\frac{\frac{\frac{\mathsf{fma}\left(-0.5, x, 0.3333333333333333\right)}{n}}{x \cdot x}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -20Initial program 100.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.8
Applied rewrites55.8%
Taylor expanded in x around inf
Applied rewrites17.2%
Taylor expanded in x around 0
Applied rewrites44.8%
if -20 < (/.f64 #s(literal 1 binary64) n) Initial program 35.7%
Taylor expanded in x around inf
Applied rewrites44.4%
Taylor expanded in n around inf
Applied rewrites46.1%
Final simplification45.8%
(FPCore (x n)
:precision binary64
(if (<= x 2.35e-5)
(/ (- x (log x)) n)
(if (<= x 3.1e+204)
(/
(/
(-
(+ (/ 0.3333333333333333 (* x x)) 1.0)
(+ (/ 0.5 (* (* x x) n)) (/ 0.5 x)))
n)
x)
(/ 0.3333333333333333 (* (pow x 3.0) n)))))
double code(double x, double n) {
double tmp;
if (x <= 2.35e-5) {
tmp = (x - log(x)) / n;
} else if (x <= 3.1e+204) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / ((x * x) * n)) + (0.5 / x))) / n) / x;
} else {
tmp = 0.3333333333333333 / (pow(x, 3.0) * n);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.35d-5) then
tmp = (x - log(x)) / n
else if (x <= 3.1d+204) then
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - ((0.5d0 / ((x * x) * n)) + (0.5d0 / x))) / n) / x
else
tmp = 0.3333333333333333d0 / ((x ** 3.0d0) * n)
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.35e-5) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.1e+204) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / ((x * x) * n)) + (0.5 / x))) / n) / x;
} else {
tmp = 0.3333333333333333 / (Math.pow(x, 3.0) * n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.35e-5: tmp = (x - math.log(x)) / n elif x <= 3.1e+204: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / ((x * x) * n)) + (0.5 / x))) / n) / x else: tmp = 0.3333333333333333 / (math.pow(x, 3.0) * n) return tmp
function code(x, n) tmp = 0.0 if (x <= 2.35e-5) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.1e+204) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(Float64(0.5 / Float64(Float64(x * x) * n)) + Float64(0.5 / x))) / n) / x); else tmp = Float64(0.3333333333333333 / Float64((x ^ 3.0) * n)); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.35e-5) tmp = (x - log(x)) / n; elseif (x <= 3.1e+204) tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / ((x * x) * n)) + (0.5 / x))) / n) / x; else tmp = 0.3333333333333333 / ((x ^ 3.0) * n); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.35e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.1e+204], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(0.5 / N[(N[(x * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision] + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], N[(0.3333333333333333 / N[(N[Power[x, 3.0], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.35 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+204}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \left(\frac{0.5}{\left(x \cdot x\right) \cdot n} + \frac{0.5}{x}\right)}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{{x}^{3} \cdot n}\\
\end{array}
\end{array}
if x < 2.34999999999999986e-5Initial program 41.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.9
Applied rewrites55.9%
Taylor expanded in x around 0
Applied rewrites55.8%
if 2.34999999999999986e-5 < x < 3.1000000000000002e204Initial program 51.3%
Taylor expanded in x around inf
Applied rewrites80.6%
Taylor expanded in n around inf
Applied rewrites83.2%
Taylor expanded in n around inf
Applied rewrites64.2%
Taylor expanded in n around inf
Applied rewrites63.3%
if 3.1000000000000002e204 < x Initial program 89.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Taylor expanded in x around inf
Applied rewrites62.6%
Taylor expanded in x around 0
Applied rewrites89.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* (* x x) n)))
(if (<= x 2.35e-5)
(/ (- x (log x)) n)
(if (<= x 1.1e+205)
(/
(/
(- (+ (/ 0.3333333333333333 (* x x)) 1.0) (+ (/ 0.5 t_0) (/ 0.5 x)))
n)
x)
(/ (- (/ 0.3333333333333333 t_0) (/ (/ 0.5 n) x)) x)))))
double code(double x, double n) {
double t_0 = (x * x) * n;
double tmp;
if (x <= 2.35e-5) {
tmp = (x - log(x)) / n;
} else if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x;
} else {
tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x * x) * n
if (x <= 2.35d-5) then
tmp = (x - log(x)) / n
else if (x <= 1.1d+205) then
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - ((0.5d0 / t_0) + (0.5d0 / x))) / n) / x
else
tmp = ((0.3333333333333333d0 / t_0) - ((0.5d0 / n) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x * x) * n;
double tmp;
if (x <= 2.35e-5) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x;
} else {
tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = (x * x) * n tmp = 0 if x <= 2.35e-5: tmp = (x - math.log(x)) / n elif x <= 1.1e+205: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x else: tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x return tmp
function code(x, n) t_0 = Float64(Float64(x * x) * n) tmp = 0.0 if (x <= 2.35e-5) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 1.1e+205) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(Float64(0.5 / t_0) + Float64(0.5 / x))) / n) / x); else tmp = Float64(Float64(Float64(0.3333333333333333 / t_0) - Float64(Float64(0.5 / n) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = (x * x) * n; tmp = 0.0; if (x <= 2.35e-5) tmp = (x - log(x)) / n; elseif (x <= 1.1e+205) tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x; else tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[x, 2.35e-5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.1e+205], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(0.5 / t$95$0), $MachinePrecision] + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.3333333333333333 / t$95$0), $MachinePrecision] - N[(N[(0.5 / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot n\\
\mathbf{if}\;x \leq 2.35 \cdot 10^{-5}:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+205}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \left(\frac{0.5}{t\_0} + \frac{0.5}{x}\right)}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{t\_0} - \frac{\frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 2.34999999999999986e-5Initial program 41.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.9
Applied rewrites55.9%
Taylor expanded in x around 0
Applied rewrites55.8%
if 2.34999999999999986e-5 < x < 1.0999999999999999e205Initial program 51.3%
Taylor expanded in x around inf
Applied rewrites80.6%
Taylor expanded in n around inf
Applied rewrites83.2%
Taylor expanded in n around inf
Applied rewrites64.2%
Taylor expanded in n around inf
Applied rewrites63.3%
if 1.0999999999999999e205 < x Initial program 89.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Taylor expanded in x around inf
Applied rewrites62.6%
Taylor expanded in x around 0
Applied rewrites81.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* (* x x) n)))
(if (<= x 1.8e-5)
(/ (- (log x)) n)
(if (<= x 1.1e+205)
(/
(/
(- (+ (/ 0.3333333333333333 (* x x)) 1.0) (+ (/ 0.5 t_0) (/ 0.5 x)))
n)
x)
(/ (- (/ 0.3333333333333333 t_0) (/ (/ 0.5 n) x)) x)))))
double code(double x, double n) {
double t_0 = (x * x) * n;
double tmp;
if (x <= 1.8e-5) {
tmp = -log(x) / n;
} else if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x;
} else {
tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = (x * x) * n
if (x <= 1.8d-5) then
tmp = -log(x) / n
else if (x <= 1.1d+205) then
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - ((0.5d0 / t_0) + (0.5d0 / x))) / n) / x
else
tmp = ((0.3333333333333333d0 / t_0) - ((0.5d0 / n) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (x * x) * n;
double tmp;
if (x <= 1.8e-5) {
tmp = -Math.log(x) / n;
} else if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x;
} else {
tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x;
}
return tmp;
}
def code(x, n): t_0 = (x * x) * n tmp = 0 if x <= 1.8e-5: tmp = -math.log(x) / n elif x <= 1.1e+205: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x else: tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x return tmp
function code(x, n) t_0 = Float64(Float64(x * x) * n) tmp = 0.0 if (x <= 1.8e-5) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 1.1e+205) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(Float64(0.5 / t_0) + Float64(0.5 / x))) / n) / x); else tmp = Float64(Float64(Float64(0.3333333333333333 / t_0) - Float64(Float64(0.5 / n) / x)) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = (x * x) * n; tmp = 0.0; if (x <= 1.8e-5) tmp = -log(x) / n; elseif (x <= 1.1e+205) tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - ((0.5 / t_0) + (0.5 / x))) / n) / x; else tmp = ((0.3333333333333333 / t_0) - ((0.5 / n) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * n), $MachinePrecision]}, If[LessEqual[x, 1.8e-5], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.1e+205], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(N[(0.5 / t$95$0), $MachinePrecision] + N[(0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.3333333333333333 / t$95$0), $MachinePrecision] - N[(N[(0.5 / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot n\\
\mathbf{if}\;x \leq 1.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{+205}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \left(\frac{0.5}{t\_0} + \frac{0.5}{x}\right)}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{t\_0} - \frac{\frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 1.80000000000000005e-5Initial program 41.3%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6455.9
Applied rewrites55.9%
Taylor expanded in x around 0
Applied rewrites55.5%
if 1.80000000000000005e-5 < x < 1.0999999999999999e205Initial program 51.3%
Taylor expanded in x around inf
Applied rewrites80.6%
Taylor expanded in n around inf
Applied rewrites83.2%
Taylor expanded in n around inf
Applied rewrites64.2%
Taylor expanded in n around inf
Applied rewrites63.3%
if 1.0999999999999999e205 < x Initial program 89.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Taylor expanded in x around inf
Applied rewrites62.6%
Taylor expanded in x around 0
Applied rewrites81.6%
(FPCore (x n) :precision binary64 (/ (pow n -1.0) x))
double code(double x, double n) {
return pow(n, -1.0) / x;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (n ** (-1.0d0)) / x
end function
public static double code(double x, double n) {
return Math.pow(n, -1.0) / x;
}
def code(x, n): return math.pow(n, -1.0) / x
function code(x, n) return Float64((n ^ -1.0) / x) end
function tmp = code(x, n) tmp = (n ^ -1.0) / x; end
code[x_, n_] := N[(N[Power[n, -1.0], $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{{n}^{-1}}{x}
\end{array}
Initial program 53.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6460.2
Applied rewrites60.2%
Taylor expanded in x around inf
Applied rewrites39.1%
Final simplification39.1%
(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.0%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6460.2
Applied rewrites60.2%
Taylor expanded in x around inf
Applied rewrites39.1%
Applied rewrites38.8%
Final simplification38.8%
(FPCore (x n) :precision binary64 (if (<= x 1.1e+205) (/ (/ (- (+ (/ 0.3333333333333333 (* x x)) 1.0) (/ 0.5 x)) n) x) (/ (- (/ 0.3333333333333333 (* (* x x) n)) (/ (/ 0.5 n) x)) x)))
double code(double x, double n) {
double tmp;
if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
} else {
tmp = ((0.3333333333333333 / ((x * x) * n)) - ((0.5 / n) / x)) / x;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, n)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.1d+205) then
tmp = ((((0.3333333333333333d0 / (x * x)) + 1.0d0) - (0.5d0 / x)) / n) / x
else
tmp = ((0.3333333333333333d0 / ((x * x) * n)) - ((0.5d0 / n) / x)) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.1e+205) {
tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x;
} else {
tmp = ((0.3333333333333333 / ((x * x) * n)) - ((0.5 / n) / x)) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.1e+205: tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x else: tmp = ((0.3333333333333333 / ((x * x) * n)) - ((0.5 / n) / x)) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 1.1e+205) tmp = Float64(Float64(Float64(Float64(Float64(0.3333333333333333 / Float64(x * x)) + 1.0) - Float64(0.5 / x)) / n) / x); else tmp = Float64(Float64(Float64(0.3333333333333333 / Float64(Float64(x * x) * n)) - Float64(Float64(0.5 / n) / x)) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.1e+205) tmp = ((((0.3333333333333333 / (x * x)) + 1.0) - (0.5 / x)) / n) / x; else tmp = ((0.3333333333333333 / ((x * x) * n)) - ((0.5 / n) / x)) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.1e+205], N[(N[(N[(N[(N[(0.3333333333333333 / N[(x * x), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(0.3333333333333333 / N[(N[(x * x), $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision] - N[(N[(0.5 / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{+205}:\\
\;\;\;\;\frac{\frac{\left(\frac{0.3333333333333333}{x \cdot x} + 1\right) - \frac{0.5}{x}}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{\left(x \cdot x\right) \cdot n} - \frac{\frac{0.5}{n}}{x}}{x}\\
\end{array}
\end{array}
if x < 1.0999999999999999e205Initial program 45.0%
Taylor expanded in x around inf
Applied rewrites38.2%
Taylor expanded in n around inf
Applied rewrites39.6%
if 1.0999999999999999e205 < x Initial program 89.8%
Taylor expanded in n around inf
lower-/.f64N/A
lower--.f64N/A
lower-log1p.f64N/A
lower-log.f6489.8
Applied rewrites89.8%
Taylor expanded in x around inf
Applied rewrites62.6%
Taylor expanded in x around 0
Applied rewrites81.6%
herbie shell --seed 2024347
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))