
(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));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n): return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n) return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n))) end
function tmp = code(x, n) tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n)); end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x n) :precision binary64 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
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 (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/
(+
(/ (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))) n)
(- (log1p x) (log x)))
n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) / n) + (log1p(x) - log(x))) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) / n) + (Math.log1p(x) - Math.log(x))) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = (((0.5 * (math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0))) / n) + (math.log1p(x) - math.log(x))) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) / n) + Float64(log1p(x) - log(x))) / n); else tmp = Float64(exp(Float64(x / n)) - 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], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $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 -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n} + \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 64.6%
pow-to-expN/A
exp-lowering-exp.f64N/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
log1p-defineN/A
log1p-lowering-log1p.f6496.7%
Applied egg-rr96.7%
Taylor expanded in x around 0
/-lowering-/.f6496.7%
Simplified96.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $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 -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 64.6%
pow-to-expN/A
exp-lowering-exp.f64N/A
un-div-invN/A
/-lowering-/.f64N/A
+-commutativeN/A
log1p-defineN/A
log1p-lowering-log1p.f6496.7%
Applied egg-rr96.7%
Taylor expanded in x around 0
/-lowering-/.f6496.7%
Simplified96.7%
Final simplification87.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 1e+120)
(- (+ 1.0 (/ x n)) t_0)
(/ (/ (+ (/ (* 0.5 (- 1.0 (log x))) n) -0.5) (* x x)) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+120) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((((0.5 * (1.0 - log(x))) / n) + -0.5) / (x * x)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 1d+120) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = ((((0.5d0 * (1.0d0 - log(x))) / n) + (-0.5d0)) / (x * x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 1e+120) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = ((((0.5 * (1.0 - Math.log(x))) / n) + -0.5) / (x * x)) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 1e+120: tmp = (1.0 + (x / n)) - t_0 else: tmp = ((((0.5 * (1.0 - math.log(x))) / n) + -0.5) / (x * x)) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 1e+120) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(Float64(Float64(Float64(0.5 * Float64(1.0 - log(x))) / n) + -0.5) / Float64(x * x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 1e+120) tmp = (1.0 + (x / n)) - t_0; else tmp = ((((0.5 * (1.0 - log(x))) / n) + -0.5) / (x * x)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+120], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(0.5 * N[(1.0 - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + -0.5), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+120}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{0.5 \cdot \left(1 - \log x\right)}{n} + -0.5}{x \cdot x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e119Initial program 79.8%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
+-lowering-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
/-lowering-/.f6481.2%
Simplified81.2%
if 9.9999999999999998e119 < (/.f64 #s(literal 1 binary64) n) Initial program 39.1%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified0.2%
Taylor expanded in x around inf
/-lowering-/.f64N/A
Simplified59.8%
Taylor expanded in x around 0
fmsub-defineN/A
sub-negN/A
distribute-frac-negN/A
log-recN/A
fmsub-defineN/A
/-lowering-/.f64N/A
Simplified68.2%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(- (+ 1.0 (* x (+ (/ 1.0 n) (/ (* x (/ 0.5 n)) n)))) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + ((x * (0.5 / n)) / n)))) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + ((x * (0.5d0 / n)) / n)))) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else {
tmp = (1.0 + (x * ((1.0 / n) + ((x * (0.5 / n)) / n)))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n else: tmp = (1.0 + (x * ((1.0 / n) + ((x * (0.5 / n)) / n)))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(Float64(x * Float64(0.5 / n)) / n)))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; else tmp = (1.0 + (x * ((1.0 / n) + ((x * (0.5 / n)) / n)))) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(N[(x * N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot \frac{0.5}{n}}{n}\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) Initial program 64.6%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
+-commutativeN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
sub-negN/A
+-lowering-+.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f64N/A
unpow2N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f6473.4%
Simplified73.4%
Taylor expanded in n around 0
associate-*r/N/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f64N/A
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
associate-*r/N/A
*-lowering-*.f64N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f6482.5%
Simplified82.5%
Final simplification85.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+233) (- (+ 1.0 (/ x n)) t_0) (/ (/ 1.0 x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+233) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+233: tmp = (1.0 + (x / n)) - t_0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+233) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+233) tmp = (1.0 + (x / n)) - t_0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+233], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+233}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999995e233Initial program 80.0%
Taylor expanded in x around 0
*-rgt-identityN/A
associate-*r/N/A
+-lowering-+.f64N/A
associate-*r/N/A
*-rgt-identityN/A
/-lowering-/.f6473.5%
Simplified73.5%
if 1.99999999999999995e233 < (/.f64 #s(literal 1 binary64) n) Initial program 9.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f640.0%
Simplified0.0%
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f641.8%
Applied egg-rr1.8%
Taylor expanded in n around inf
/-lowering-/.f6486.2%
Simplified86.2%
Final simplification84.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+233) (- 1.0 t_0) (/ (/ 1.0 x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+233) then
tmp = 1.0d0 - t_0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+233: tmp = 1.0 - t_0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+233) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+233) tmp = 1.0 - t_0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+233], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
div-invN/A
times-fracN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999995e233Initial program 80.0%
Taylor expanded in x around 0
Simplified72.3%
if 1.99999999999999995e233 < (/.f64 #s(literal 1 binary64) n) Initial program 9.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f640.0%
Simplified0.0%
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f641.8%
Applied egg-rr1.8%
Taylor expanded in n around inf
/-lowering-/.f6486.2%
Simplified86.2%
Final simplification84.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -0.002)
(/ (/ t_0 n) x)
(if (<= (/ 1.0 n) 1e-15)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2e+233) (- 1.0 t_0) (/ (/ 1.0 x) n))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-0.002d0)) then
tmp = (t_0 / n) / x
else if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+233) then
tmp = 1.0d0 - t_0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -0.002) {
tmp = (t_0 / n) / x;
} else if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - t_0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -0.002: tmp = (t_0 / n) / x elif (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+233: tmp = 1.0 - t_0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -0.002) tmp = Float64(Float64(t_0 / n) / x); elseif (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+233) tmp = Float64(1.0 - t_0); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -0.002) tmp = (t_0 / n) / x; elseif ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+233) tmp = 1.0 - t_0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.002], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+233], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -0.002:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+233}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -2e-3Initial program 98.9%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6498.9%
Simplified98.9%
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6498.9%
Applied egg-rr98.9%
if -2e-3 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 27.5%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified77.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr60.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6477.3%
Simplified77.3%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999995e233Initial program 80.0%
Taylor expanded in x around 0
Simplified72.3%
if 1.99999999999999995e233 < (/.f64 #s(literal 1 binary64) n) Initial program 9.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f640.0%
Simplified0.0%
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f641.8%
Applied egg-rr1.8%
Taylor expanded in n around inf
/-lowering-/.f6486.2%
Simplified86.2%
Final simplification84.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) 1e-15) (/ (log (/ (+ 1.0 x) x)) n) (if (<= (/ 1.0 n) 2e+233) (- 1.0 (pow x (/ 1.0 n))) (/ (/ 1.0 x) n))))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 1e-15) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= 1d-15) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2d+233) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= 1e-15) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2e+233) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= 1e-15: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2e+233: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= 1e-15) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2e+233) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= 1e-15) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2e+233) tmp = 1.0 - (x ^ (1.0 / n)); else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-15], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+233], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 10^{-15}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+233}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-15Initial program 56.2%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified78.4%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr56.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6470.7%
Simplified70.7%
if 1.0000000000000001e-15 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999995e233Initial program 80.0%
Taylor expanded in x around 0
Simplified72.3%
if 1.99999999999999995e233 < (/.f64 #s(literal 1 binary64) n) Initial program 9.4%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f640.0%
Simplified0.0%
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f641.8%
Applied egg-rr1.8%
Taylor expanded in n around inf
/-lowering-/.f6486.2%
Simplified86.2%
Final simplification71.3%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 44.0%
Taylor expanded in n around inf
/-lowering-/.f64N/A
Simplified65.8%
clear-numN/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
Applied egg-rr65.8%
Taylor expanded in n around inf
/-lowering-/.f64N/A
log-lowering-log.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6455.0%
Simplified55.0%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f64N/A
log-lowering-log.f6454.8%
Simplified54.8%
if 1 < x Initial program 72.5%
Taylor expanded in x around 0
Simplified28.5%
Taylor expanded in n around inf
Simplified72.5%
metadata-eval72.5%
Applied egg-rr72.5%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (- 0.0 (/ (log x) n)) 0.0))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = 0.0 - (log(x) / n);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 0.0d0 - (log(x) / n)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = 0.0 - (Math.log(x) / n);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = 0.0 - (math.log(x) / n) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(0.0 - Float64(log(x) / n)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = 0.0 - (log(x) / n); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(0.0 - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;0 - \frac{\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1Initial program 44.0%
Taylor expanded in x around 0
Simplified42.6%
Taylor expanded in n around inf
mul-1-negN/A
neg-sub0N/A
remove-double-negN/A
distribute-frac-negN/A
log-recN/A
mul-1-negN/A
--lowering--.f64N/A
mul-1-negN/A
log-recN/A
distribute-frac-negN/A
remove-double-negN/A
/-lowering-/.f64N/A
log-lowering-log.f6454.1%
Simplified54.1%
if 1 < x Initial program 72.5%
Taylor expanded in x around 0
Simplified28.5%
Taylor expanded in n around inf
Simplified72.5%
metadata-eval72.5%
Applied egg-rr72.5%
(FPCore (x n) :precision binary64 (let* ((t_0 (/ 1.0 (* n x)))) (if (<= n -7.0) t_0 (if (<= n -1.4e-299) 0.0 t_0))))
double code(double x, double n) {
double t_0 = 1.0 / (n * x);
double tmp;
if (n <= -7.0) {
tmp = t_0;
} else if (n <= -1.4e-299) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 / (n * x)
if (n <= (-7.0d0)) then
tmp = t_0
else if (n <= (-1.4d-299)) then
tmp = 0.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 / (n * x);
double tmp;
if (n <= -7.0) {
tmp = t_0;
} else if (n <= -1.4e-299) {
tmp = 0.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = 1.0 / (n * x) tmp = 0 if n <= -7.0: tmp = t_0 elif n <= -1.4e-299: tmp = 0.0 else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(1.0 / Float64(n * x)) tmp = 0.0 if (n <= -7.0) tmp = t_0; elseif (n <= -1.4e-299) tmp = 0.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 / (n * x); tmp = 0.0; if (n <= -7.0) tmp = t_0; elseif (n <= -1.4e-299) tmp = 0.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -7.0], t$95$0, If[LessEqual[n, -1.4e-299], 0.0, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
\mathbf{if}\;n \leq -7:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -1.4 \cdot 10^{-299}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -7 or -1.4000000000000001e-299 < n Initial program 35.2%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6440.1%
Simplified40.1%
Taylor expanded in n around inf
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6442.9%
Simplified42.9%
if -7 < n < -1.4000000000000001e-299Initial program 100.0%
Taylor expanded in x around 0
Simplified39.9%
Taylor expanded in n around inf
Simplified62.7%
metadata-eval62.7%
Applied egg-rr62.7%
Final simplification49.6%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -0.2) 0.0 (/ (/ 1.0 x) n)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -0.2) {
tmp = 0.0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-0.2d0)) then
tmp = 0.0d0
else
tmp = (1.0d0 / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -0.2) {
tmp = 0.0;
} else {
tmp = (1.0 / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -0.2: tmp = 0.0 else: tmp = (1.0 / x) / n return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -0.2) tmp = 0.0; else tmp = Float64(Float64(1.0 / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -0.2) tmp = 0.0; else tmp = (1.0 / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.2], 0.0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -0.2:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.20000000000000001Initial program 100.0%
Taylor expanded in x around 0
Simplified40.6%
Taylor expanded in n around inf
Simplified62.0%
metadata-eval62.0%
Applied egg-rr62.0%
if -0.20000000000000001 < (/.f64 #s(literal 1 binary64) n) Initial program 34.8%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.8%
Simplified39.8%
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6441.2%
Applied egg-rr41.2%
Taylor expanded in n around inf
/-lowering-/.f6443.8%
Simplified43.8%
(FPCore (x n) :precision binary64 (if (<= (/ 1.0 n) -0.2) 0.0 (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -0.2) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((1.0d0 / n) <= (-0.2d0)) then
tmp = 0.0d0
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((1.0 / n) <= -0.2) {
tmp = 0.0;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if (1.0 / n) <= -0.2: tmp = 0.0 else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (Float64(1.0 / n) <= -0.2) tmp = 0.0; else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((1.0 / n) <= -0.2) tmp = 0.0; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.2], 0.0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -0.2:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -0.20000000000000001Initial program 100.0%
Taylor expanded in x around 0
Simplified40.6%
Taylor expanded in n around inf
Simplified62.0%
metadata-eval62.0%
Applied egg-rr62.0%
if -0.20000000000000001 < (/.f64 #s(literal 1 binary64) n) Initial program 34.8%
Taylor expanded in x around inf
/-lowering-/.f64N/A
mul-1-negN/A
log-recN/A
mul-1-negN/A
exp-negN/A
/-lowering-/.f64N/A
*-commutativeN/A
associate-/l*N/A
exp-to-powN/A
pow-lowering-pow.f64N/A
/-lowering-/.f64N/A
*-commutativeN/A
*-lowering-*.f6439.8%
Simplified39.8%
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f64N/A
pow-flipN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f64N/A
pow-lowering-pow.f64N/A
/-lowering-/.f6441.1%
Applied egg-rr41.1%
Taylor expanded in n around inf
Simplified43.7%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 57.2%
Taylor expanded in x around 0
Simplified36.0%
Taylor expanded in n around inf
Simplified35.7%
metadata-eval35.7%
Applied egg-rr35.7%
herbie shell --seed 2024288
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))