
(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 23 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) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
(/ (exp (/ (log x) n)) (* n x))
(- (expm1 (log1p (exp (/ (log1p x) n)))) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = exp((log(x) / n)) / (n * x);
} else {
tmp = expm1(log1p(exp((log1p(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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else {
tmp = Math.expm1(Math.log1p(Math.exp((Math.log1p(x) / n)))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = math.exp((math.log(x) / n)) / (n * x) else: tmp = math.expm1(math.log1p(math.exp((math.log1p(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) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); else tmp = Float64(expm1(log1p(exp(Float64(log1p(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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[N[Log[1 + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 95.1%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
div-inv99.9%
exp-to-pow100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 5.7%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-commutative98.0%
Simplified98.0%
if 2 < (/.f64 1 n) Initial program 52.6%
expm1-log1p-u52.6%
expm1-undefine52.6%
pow-to-exp52.6%
un-div-inv52.6%
+-commutative52.6%
log1p-define99.9%
Applied egg-rr99.9%
expm1-define100.0%
Simplified100.0%
Final simplification91.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
(/ (exp (/ (log x) n)) (* n x))
(- (exp (/ (log1p x) n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = exp((log(x) / n)) / (n * x);
} else {
tmp = exp((log1p(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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else {
tmp = Math.exp((Math.log1p(x) / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = math.exp((math.log(x) / n)) / (n * x) else: tmp = math.exp((math.log1p(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) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); else tmp = Float64(exp(Float64(log1p(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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / 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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 95.1%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
div-inv99.9%
exp-to-pow100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 5.7%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-commutative98.0%
Simplified98.0%
if 2 < (/.f64 1 n) Initial program 52.6%
Taylor expanded in n around 0 52.6%
log1p-define99.9%
*-rgt-identity99.9%
associate-*l/99.9%
associate-/l*99.9%
exp-to-pow99.9%
Simplified99.9%
Final simplification91.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-16)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
(/ (exp (/ (log x) n)) (* n x))
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (* (/ 1.0 n) (/ 1.0 n))) (* 0.5 (/ -1.0 n)))))))
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = exp((log(x) / n)) / (n * x);
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / 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) <= (-2d-16)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = exp((log(x) / n)) / (n * x)
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + (x * ((0.5d0 * ((1.0d0 / n) * (1.0d0 / n))) + (0.5d0 * ((-1.0d0) / 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) <= -2e-16) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = math.exp((math.log(x) / n)) / (n * x) else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(Float64(1.0 / n) * Float64(1.0 / n))) + Float64(0.5 * Float64(-1.0 / 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) <= -2e-16) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = exp((log(x) / n)) / (n * x); else tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / 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], -2e-16], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \left(\frac{1}{n} \cdot \frac{1}{n}\right) + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16Initial program 95.1%
Taylor expanded in x around inf 99.9%
mul-1-neg99.9%
log-rec99.9%
mul-1-neg99.9%
distribute-neg-frac99.9%
mul-1-neg99.9%
remove-double-neg99.9%
*-commutative99.9%
Simplified99.9%
*-un-lft-identity99.9%
div-inv99.9%
exp-to-pow100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 5.7%
Taylor expanded in x around inf 98.0%
mul-1-neg98.0%
log-rec98.0%
mul-1-neg98.0%
distribute-neg-frac98.0%
mul-1-neg98.0%
remove-double-neg98.0%
*-commutative98.0%
Simplified98.0%
if 2 < (/.f64 1 n) Initial program 52.6%
Taylor expanded in x around 0 75.1%
inv-pow75.1%
unpow275.1%
unpow-prod-down75.1%
inv-pow75.1%
inv-pow75.1%
Applied egg-rr75.1%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(-
(+
1.0
(*
x
(+
(/ 1.0 n)
(* x (+ (* 0.5 (* (/ 1.0 n) (/ 1.0 n))) (* 0.5 (/ -1.0 n)))))))
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + (x * ((0.5d0 * ((1.0d0 / n) * (1.0d0 / n))) + (0.5d0 * ((-1.0d0) / 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 t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / n))))))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / n))))))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(0.5 * Float64(Float64(1.0 / n) * Float64(1.0 / n))) + Float64(0.5 * Float64(-1.0 / n))))))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; else tmp = (1.0 + (x * ((1.0 / n) + (x * ((0.5 * ((1.0 / n) * (1.0 / n))) + (0.5 * (-1.0 / n))))))) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(0.5 * N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \left(\frac{1}{n} \cdot \frac{1}{n}\right) + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
div-inv99.7%
exp-to-pow99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) Initial program 52.6%
Taylor expanded in x around 0 75.1%
inv-pow75.1%
unpow275.1%
unpow-prod-down75.1%
inv-pow75.1%
inv-pow75.1%
Applied egg-rr75.1%
Final simplification88.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(-
(+ 1.0 (* x (+ (/ 1.0 n) (/ (+ (* x -0.5) (* 0.5 (/ x n))) n))))
t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / 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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else
tmp = (1.0d0 + (x * ((1.0d0 / n) + (((x * (-0.5d0)) + (0.5d0 * (x / 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 t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else {
tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 else: tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / n))) / n)))) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(Float64(Float64(x * -0.5) + Float64(0.5 * Float64(x / n))) / n)))) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; else tmp = (1.0 + (x * ((1.0 / n) + (((x * -0.5) + (0.5 * (x / 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]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(x * -0.5), $MachinePrecision] + N[(0.5 * N[(x / n), $MachinePrecision]), $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)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot -0.5 + 0.5 \cdot \frac{x}{n}}{n}\right)\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
div-inv99.7%
exp-to-pow99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) Initial program 52.6%
Taylor expanded in x around 0 75.1%
Taylor expanded in n around inf 73.0%
Final simplification88.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(if (<= (/ 1.0 n) 1e+219)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* x (/ n (+ 1.0 (/ 0.25 (pow x 3.0))))))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * (n / (1.0 + (0.25 / pow(x, 3.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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+219) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (x * (n / (1.0d0 + (0.25d0 / (x ** 3.0d0)))))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (x * (n / (1.0 + (0.25 / Math.pow(x, 3.0)))));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 elif (1.0 / n) <= 1e+219: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (x * (n / (1.0 + (0.25 / math.pow(x, 3.0))))) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(x * Float64(n / Float64(1.0 + Float64(0.25 / (x ^ 3.0)))))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; elseif ((1.0 / n) <= 1e+219) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (x * (n / (1.0 + (0.25 / (x ^ 3.0))))); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(x * N[(n / N[(1.0 + N[(0.25 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{n}{1 + \frac{0.25}{{x}^{3}}}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
div-inv99.7%
exp-to-pow99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) < 9.99999999999999965e218Initial program 65.1%
Taylor expanded in x around 0 64.6%
if 9.99999999999999965e218 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in n around inf 8.0%
log1p-define8.0%
Simplified8.0%
Taylor expanded in x around -inf 0.0%
Applied egg-rr88.6%
unpow-188.6%
associate-/r/88.6%
+-commutative88.6%
+-commutative88.6%
Simplified88.6%
Taylor expanded in x around 0 88.6%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(if (<= (/ 1.0 n) 1e+219)
(- (+ 1.0 (/ x n)) t_0)
(/ 0.25 (* n (pow x 4.0)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.25 / (n * pow(x, 4.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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+219) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 0.25d0 / (n * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.25 / (n * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 elif (1.0 / n) <= 1e+219: tmp = (1.0 + (x / n)) - t_0 else: tmp = 0.25 / (n * math.pow(x, 4.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(0.25 / Float64(n * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; elseif ((1.0 / n) <= 1e+219) tmp = (1.0 + (x / n)) - t_0; else tmp = 0.25 / (n * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
div-inv99.7%
exp-to-pow99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) < 9.99999999999999965e218Initial program 65.1%
Taylor expanded in x around 0 64.6%
if 9.99999999999999965e218 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in n around inf 8.0%
log1p-define8.0%
Simplified8.0%
Taylor expanded in x around -inf 0.0%
Applied egg-rr88.6%
unpow-188.6%
associate-/r/88.6%
+-commutative88.6%
+-commutative88.6%
Simplified88.6%
Taylor expanded in x around 0 88.6%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (/ t_0 n) x)))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(if (<= (/ 1.0 n) 1e+219) (- 1.0 t_0) (/ 0.25 (* n (pow x 4.0)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 0.25 / (n * pow(x, 4.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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = (t_0 / n) / x
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+219) then
tmp = 1.0d0 - t_0
else
tmp = 0.25d0 / (n * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = (t_0 / n) / x;
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 0.25 / (n * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = (t_0 / n) / x tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 elif (1.0 / n) <= 1e+219: tmp = 1.0 - t_0 else: tmp = 0.25 / (n * math.pow(x, 4.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(Float64(t_0 / n) / x) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(1.0 - t_0); else tmp = Float64(0.25 / Float64(n * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = (t_0 / n) / x; tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; elseif ((1.0 / n) <= 1e+219) tmp = 1.0 - t_0; else tmp = 0.25 / (n * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(1.0 - t$95$0), $MachinePrecision], N[(0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\frac{t\_0}{n}}{x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
associate-/r*99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-rgt-identity99.7%
associate-/l*99.7%
exp-to-pow99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) < 9.99999999999999965e218Initial program 65.1%
Taylor expanded in x around 0 61.0%
*-rgt-identity61.0%
associate-*l/61.0%
associate-/l*61.0%
exp-to-pow61.0%
Simplified61.0%
if 9.99999999999999965e218 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in n around inf 8.0%
log1p-define8.0%
Simplified8.0%
Taylor expanded in x around -inf 0.0%
Applied egg-rr88.6%
unpow-188.6%
associate-/r/88.6%
+-commutative88.6%
+-commutative88.6%
Simplified88.6%
Taylor expanded in x around 0 88.6%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -2e-16)
t_1
(if (<= (/ 1.0 n) 2e-41)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= (/ 1.0 n) 2.0)
t_1
(if (<= (/ 1.0 n) 1e+219) (- 1.0 t_0) (/ 0.25 (* n (pow x 4.0)))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 0.25 / (n * pow(x, 4.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) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = t_0 / (n * x)
if ((1.0d0 / n) <= (-2d-16)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-41) then
tmp = log((x / (1.0d0 + x))) / -n
else if ((1.0d0 / n) <= 2.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+219) then
tmp = 1.0d0 - t_0
else
tmp = 0.25d0 / (n * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double t_1 = t_0 / (n * x);
double tmp;
if ((1.0 / n) <= -2e-16) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-41) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if ((1.0 / n) <= 2.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+219) {
tmp = 1.0 - t_0;
} else {
tmp = 0.25 / (n * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = t_0 / (n * x) tmp = 0 if (1.0 / n) <= -2e-16: tmp = t_1 elif (1.0 / n) <= 2e-41: tmp = math.log((x / (1.0 + x))) / -n elif (1.0 / n) <= 2.0: tmp = t_1 elif (1.0 / n) <= 1e+219: tmp = 1.0 - t_0 else: tmp = 0.25 / (n * math.pow(x, 4.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(t_0 / Float64(n * x)) tmp = 0.0 if (Float64(1.0 / n) <= -2e-16) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-41) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (Float64(1.0 / n) <= 2.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+219) tmp = Float64(1.0 - t_0); else tmp = Float64(0.25 / Float64(n * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = t_0 / (n * x); tmp = 0.0; if ((1.0 / n) <= -2e-16) tmp = t_1; elseif ((1.0 / n) <= 2e-41) tmp = log((x / (1.0 + x))) / -n; elseif ((1.0 / n) <= 2.0) tmp = t_1; elseif ((1.0 / n) <= 1e+219) tmp = 1.0 - t_0; else tmp = 0.25 / (n * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-16], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-41], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+219], N[(1.0 - t$95$0), $MachinePrecision], N[(0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{t\_0}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-41}:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+219}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e-16 or 2.00000000000000001e-41 < (/.f64 1 n) < 2Initial program 87.7%
Taylor expanded in x around inf 99.7%
mul-1-neg99.7%
log-rec99.7%
mul-1-neg99.7%
distribute-neg-frac99.7%
mul-1-neg99.7%
remove-double-neg99.7%
*-commutative99.7%
Simplified99.7%
*-un-lft-identity99.7%
div-inv99.7%
exp-to-pow99.8%
Applied egg-rr99.8%
*-lft-identity99.8%
Simplified99.8%
if -2e-16 < (/.f64 1 n) < 2.00000000000000001e-41Initial program 25.9%
Taylor expanded in n around inf 85.0%
log1p-define85.0%
Simplified85.0%
log1p-undefine85.0%
diff-log85.0%
Applied egg-rr85.0%
+-commutative85.0%
Simplified85.0%
clear-num85.0%
log-div85.0%
metadata-eval85.0%
+-commutative85.0%
Applied egg-rr85.0%
neg-sub085.0%
Simplified85.0%
if 2 < (/.f64 1 n) < 9.99999999999999965e218Initial program 65.1%
Taylor expanded in x around 0 61.0%
*-rgt-identity61.0%
associate-*l/61.0%
associate-/l*61.0%
exp-to-pow61.0%
Simplified61.0%
if 9.99999999999999965e218 < (/.f64 1 n) Initial program 15.2%
Taylor expanded in n around inf 8.0%
log1p-define8.0%
Simplified8.0%
Taylor expanded in x around -inf 0.0%
Applied egg-rr88.6%
unpow-188.6%
associate-/r/88.6%
+-commutative88.6%
+-commutative88.6%
Simplified88.6%
Taylor expanded in x around 0 88.6%
Final simplification87.8%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= n -4e+15)
t_0
(if (<= n 1.06e-219)
(/ 0.25 (* n (pow x 4.0)))
(if (<= n 0.75)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= n 4.2e+49) (/ 1.0 (* x (+ n (* 0.5 (/ n x))))) t_0))))))
double code(double x, double n) {
double t_0 = log(((1.0 + x) / x)) / n;
double tmp;
if (n <= -4e+15) {
tmp = t_0;
} else if (n <= 1.06e-219) {
tmp = 0.25 / (n * pow(x, 4.0));
} else if (n <= 0.75) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (n <= 4.2e+49) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} 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 = log(((1.0d0 + x) / x)) / n
if (n <= (-4d+15)) then
tmp = t_0
else if (n <= 1.06d-219) then
tmp = 0.25d0 / (n * (x ** 4.0d0))
else if (n <= 0.75d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (n <= 4.2d+49) then
tmp = 1.0d0 / (x * (n + (0.5d0 * (n / x))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if (n <= -4e+15) {
tmp = t_0;
} else if (n <= 1.06e-219) {
tmp = 0.25 / (n * Math.pow(x, 4.0));
} else if (n <= 0.75) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (n <= 4.2e+49) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log(((1.0 + x) / x)) / n tmp = 0 if n <= -4e+15: tmp = t_0 elif n <= 1.06e-219: tmp = 0.25 / (n * math.pow(x, 4.0)) elif n <= 0.75: tmp = 1.0 - math.pow(x, (1.0 / n)) elif n <= 4.2e+49: tmp = 1.0 / (x * (n + (0.5 * (n / x)))) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (n <= -4e+15) tmp = t_0; elseif (n <= 1.06e-219) tmp = Float64(0.25 / Float64(n * (x ^ 4.0))); elseif (n <= 0.75) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (n <= 4.2e+49) tmp = Float64(1.0 / Float64(x * Float64(n + Float64(0.5 * Float64(n / x))))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(((1.0 + x) / x)) / n; tmp = 0.0; if (n <= -4e+15) tmp = t_0; elseif (n <= 1.06e-219) tmp = 0.25 / (n * (x ^ 4.0)); elseif (n <= 0.75) tmp = 1.0 - (x ^ (1.0 / n)); elseif (n <= 4.2e+49) tmp = 1.0 / (x * (n + (0.5 * (n / x)))); else tmp = t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -4e+15], t$95$0, If[LessEqual[n, 1.06e-219], N[(0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.75], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.2e+49], N[(1.0 / N[(x * N[(n + N[(0.5 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;n \leq -4 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\
\mathbf{elif}\;n \leq 0.75:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 4.2 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -4e15 or 4.20000000000000022e49 < n Initial program 26.2%
Taylor expanded in n around inf 85.5%
log1p-define85.5%
Simplified85.5%
log1p-undefine85.5%
diff-log85.5%
Applied egg-rr85.5%
+-commutative85.5%
Simplified85.5%
if -4e15 < n < 1.06e-219Initial program 87.7%
Taylor expanded in n around inf 48.3%
log1p-define48.3%
Simplified48.3%
Taylor expanded in x around -inf 4.0%
Applied egg-rr44.2%
unpow-144.2%
associate-/r/44.2%
+-commutative44.2%
+-commutative44.2%
Simplified44.2%
Taylor expanded in x around 0 69.0%
if 1.06e-219 < n < 0.75Initial program 65.1%
Taylor expanded in x around 0 61.0%
*-rgt-identity61.0%
associate-*l/61.0%
associate-/l*61.0%
exp-to-pow61.0%
Simplified61.0%
if 0.75 < n < 4.20000000000000022e49Initial program 5.3%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around -inf 72.6%
Applied egg-rr72.5%
unpow-172.5%
associate-/r/72.6%
+-commutative72.6%
+-commutative72.6%
Simplified72.6%
Taylor expanded in x around inf 73.9%
Final simplification77.3%
(FPCore (x n)
:precision binary64
(if (<= n -3900000000.0)
(/ (log (/ x (+ 1.0 x))) (- n))
(if (<= n 1.06e-219)
(/ 0.25 (* n (pow x 4.0)))
(if (<= n 0.75)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= n 2.6e+53)
(/ 1.0 (* x (+ n (* 0.5 (/ n x)))))
(/ (log (/ (+ 1.0 x) x)) n))))))
double code(double x, double n) {
double tmp;
if (n <= -3900000000.0) {
tmp = log((x / (1.0 + x))) / -n;
} else if (n <= 1.06e-219) {
tmp = 0.25 / (n * pow(x, 4.0));
} else if (n <= 0.75) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (n <= 2.6e+53) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else {
tmp = log(((1.0 + x) / x)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (n <= (-3900000000.0d0)) then
tmp = log((x / (1.0d0 + x))) / -n
else if (n <= 1.06d-219) then
tmp = 0.25d0 / (n * (x ** 4.0d0))
else if (n <= 0.75d0) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (n <= 2.6d+53) then
tmp = 1.0d0 / (x * (n + (0.5d0 * (n / x))))
else
tmp = log(((1.0d0 + x) / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (n <= -3900000000.0) {
tmp = Math.log((x / (1.0 + x))) / -n;
} else if (n <= 1.06e-219) {
tmp = 0.25 / (n * Math.pow(x, 4.0));
} else if (n <= 0.75) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (n <= 2.6e+53) {
tmp = 1.0 / (x * (n + (0.5 * (n / x))));
} else {
tmp = Math.log(((1.0 + x) / x)) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if n <= -3900000000.0: tmp = math.log((x / (1.0 + x))) / -n elif n <= 1.06e-219: tmp = 0.25 / (n * math.pow(x, 4.0)) elif n <= 0.75: tmp = 1.0 - math.pow(x, (1.0 / n)) elif n <= 2.6e+53: tmp = 1.0 / (x * (n + (0.5 * (n / x)))) else: tmp = math.log(((1.0 + x) / x)) / n return tmp
function code(x, n) tmp = 0.0 if (n <= -3900000000.0) tmp = Float64(log(Float64(x / Float64(1.0 + x))) / Float64(-n)); elseif (n <= 1.06e-219) tmp = Float64(0.25 / Float64(n * (x ^ 4.0))); elseif (n <= 0.75) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (n <= 2.6e+53) tmp = Float64(1.0 / Float64(x * Float64(n + Float64(0.5 * Float64(n / x))))); else tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (n <= -3900000000.0) tmp = log((x / (1.0 + x))) / -n; elseif (n <= 1.06e-219) tmp = 0.25 / (n * (x ^ 4.0)); elseif (n <= 0.75) tmp = 1.0 - (x ^ (1.0 / n)); elseif (n <= 2.6e+53) tmp = 1.0 / (x * (n + (0.5 * (n / x)))); else tmp = log(((1.0 + x) / x)) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[n, -3900000000.0], N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[n, 1.06e-219], N[(0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.75], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.6e+53], N[(1.0 / N[(x * N[(n + N[(0.5 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3900000000:\\
\;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\
\mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\
\mathbf{elif}\;n \leq 0.75:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;n \leq 2.6 \cdot 10^{+53}:\\
\;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\end{array}
\end{array}
if n < -3.9e9Initial program 23.4%
Taylor expanded in n around inf 78.3%
log1p-define78.3%
Simplified78.3%
log1p-undefine78.3%
diff-log78.4%
Applied egg-rr78.4%
+-commutative78.4%
Simplified78.4%
clear-num78.4%
log-div78.4%
metadata-eval78.4%
+-commutative78.4%
Applied egg-rr78.4%
neg-sub078.4%
Simplified78.4%
if -3.9e9 < n < 1.06e-219Initial program 89.6%
Taylor expanded in n around inf 49.4%
log1p-define49.4%
Simplified49.4%
Taylor expanded in x around -inf 2.3%
Applied egg-rr43.5%
unpow-143.5%
associate-/r/43.5%
+-commutative43.5%
+-commutative43.5%
Simplified43.5%
Taylor expanded in x around 0 70.5%
if 1.06e-219 < n < 0.75Initial program 65.1%
Taylor expanded in x around 0 61.0%
*-rgt-identity61.0%
associate-*l/61.0%
associate-/l*61.0%
exp-to-pow61.0%
Simplified61.0%
if 0.75 < n < 2.59999999999999998e53Initial program 5.3%
Taylor expanded in n around inf 16.0%
log1p-define16.0%
Simplified16.0%
Taylor expanded in x around -inf 72.6%
Applied egg-rr72.5%
unpow-172.5%
associate-/r/72.6%
+-commutative72.6%
+-commutative72.6%
Simplified72.6%
Taylor expanded in x around inf 73.9%
if 2.59999999999999998e53 < n Initial program 28.3%
Taylor expanded in n around inf 90.2%
log1p-define90.2%
Simplified90.2%
log1p-undefine90.2%
diff-log90.2%
Applied egg-rr90.2%
+-commutative90.2%
Simplified90.2%
Final simplification77.3%
(FPCore (x n)
:precision binary64
(if (<= x 6e-164)
(/ (log x) (- n))
(if (<= x 6.9e-133)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.88)
(/ (- x (log x)) n)
(if (<= x 4e+172)
(/
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n)
(/ -0.25 (* n (pow x 4.0))))))))
double code(double x, double n) {
double tmp;
if (x <= 6e-164) {
tmp = log(x) / -n;
} else if (x <= 6.9e-133) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else if (x <= 4e+172) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = -0.25 / (n * pow(x, 4.0));
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 6d-164) then
tmp = log(x) / -n
else if (x <= 6.9d-133) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else if (x <= 4d+172) then
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
else
tmp = (-0.25d0) / (n * (x ** 4.0d0))
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6e-164) {
tmp = Math.log(x) / -n;
} else if (x <= 6.9e-133) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 4e+172) {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
} else {
tmp = -0.25 / (n * Math.pow(x, 4.0));
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6e-164: tmp = math.log(x) / -n elif x <= 6.9e-133: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.88: tmp = (x - math.log(x)) / n elif x <= 4e+172: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n else: tmp = -0.25 / (n * math.pow(x, 4.0)) return tmp
function code(x, n) tmp = 0.0 if (x <= 6e-164) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 6.9e-133) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 4e+172) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); else tmp = Float64(-0.25 / Float64(n * (x ^ 4.0))); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6e-164) tmp = log(x) / -n; elseif (x <= 6.9e-133) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.88) tmp = (x - log(x)) / n; elseif (x <= 4e+172) tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; else tmp = -0.25 / (n * (x ^ 4.0)); end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6e-164], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 6.9e-133], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4e+172], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(-0.25 / N[(n * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6 \cdot 10^{-164}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 6.9 \cdot 10^{-133}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+172}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{n \cdot {x}^{4}}\\
\end{array}
\end{array}
if x < 6.0000000000000002e-164Initial program 38.3%
Taylor expanded in n around inf 62.9%
log1p-define62.9%
Simplified62.9%
Taylor expanded in x around 0 62.9%
neg-mul-162.9%
Simplified62.9%
if 6.0000000000000002e-164 < x < 6.9000000000000001e-133Initial program 61.6%
Taylor expanded in x around 0 61.6%
*-rgt-identity61.6%
associate-*l/61.6%
associate-/l*61.6%
exp-to-pow61.6%
Simplified61.6%
if 6.9000000000000001e-133 < x < 0.880000000000000004Initial program 30.2%
Taylor expanded in n around inf 60.2%
log1p-define60.2%
Simplified60.2%
Taylor expanded in x around 0 59.2%
if 0.880000000000000004 < x < 4.0000000000000003e172Initial program 56.3%
Taylor expanded in n around inf 59.0%
log1p-define59.0%
Simplified59.0%
Taylor expanded in x around -inf 59.5%
if 4.0000000000000003e172 < x Initial program 86.9%
Taylor expanded in n around inf 86.9%
log1p-define86.9%
Simplified86.9%
Taylor expanded in x around -inf 58.8%
Taylor expanded in x around 0 86.9%
Final simplification64.8%
(FPCore (x n)
:precision binary64
(if (<= x 1e-142)
(/ (log x) (- n))
(if (<= x 4.2e-132)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= x 0.9)
(/ (- x (log x)) n)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 1e-142) {
tmp = log(x) / -n;
} else if (x <= 4.2e-132) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if (x <= 0.9) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 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) :: tmp
if (x <= 1d-142) then
tmp = log(x) / -n
else if (x <= 4.2d-132) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if (x <= 0.9d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1e-142) {
tmp = Math.log(x) / -n;
} else if (x <= 4.2e-132) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if (x <= 0.9) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1e-142: tmp = math.log(x) / -n elif x <= 4.2e-132: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif x <= 0.9: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1e-142) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 4.2e-132) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (x <= 0.9) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1e-142) tmp = log(x) / -n; elseif (x <= 4.2e-132) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif (x <= 0.9) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1e-142], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 4.2e-132], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-142}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 4.2 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;x \leq 0.9:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 1e-142Initial program 39.8%
Taylor expanded in n around inf 60.0%
log1p-define60.0%
Simplified60.0%
Taylor expanded in x around 0 60.0%
neg-mul-160.0%
Simplified60.0%
if 1e-142 < x < 4.2000000000000002e-132Initial program 67.7%
Taylor expanded in n around inf 7.1%
log1p-define7.1%
Simplified7.1%
Taylor expanded in x around inf 83.9%
associate--l+83.9%
unpow283.9%
associate-/r*83.9%
metadata-eval83.9%
associate-*r/83.9%
associate-*r/83.9%
metadata-eval83.9%
div-sub83.9%
sub-neg83.9%
metadata-eval83.9%
+-commutative83.9%
associate-*r/83.9%
metadata-eval83.9%
Simplified83.9%
if 4.2000000000000002e-132 < x < 0.900000000000000022Initial program 30.6%
Taylor expanded in n around inf 60.9%
log1p-define60.9%
Simplified60.9%
Taylor expanded in x around 0 59.9%
if 0.900000000000000022 < x Initial program 68.1%
Taylor expanded in n around inf 69.8%
log1p-define69.8%
Simplified69.8%
Taylor expanded in x around -inf 59.2%
Final simplification60.2%
(FPCore (x n)
:precision binary64
(if (<= x 6.6e-164)
(/ (log x) (- n))
(if (<= x 9.5e-133)
(- 1.0 (pow x (/ 1.0 n)))
(if (<= x 0.88)
(/ (- x (log x)) n)
(/
(/
(+ 1.0 (/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n)))))
double code(double x, double n) {
double tmp;
if (x <= 6.6e-164) {
tmp = log(x) / -n;
} else if (x <= 9.5e-133) {
tmp = 1.0 - pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 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) :: tmp
if (x <= 6.6d-164) then
tmp = log(x) / -n
else if (x <= 9.5d-133) then
tmp = 1.0d0 - (x ** (1.0d0 / n))
else if (x <= 0.88d0) then
tmp = (x - log(x)) / n
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 6.6e-164) {
tmp = Math.log(x) / -n;
} else if (x <= 9.5e-133) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else if (x <= 0.88) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 6.6e-164: tmp = math.log(x) / -n elif x <= 9.5e-133: tmp = 1.0 - math.pow(x, (1.0 / n)) elif x <= 0.88: tmp = (x - math.log(x)) / n else: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) tmp = 0.0 if (x <= 6.6e-164) tmp = Float64(log(x) / Float64(-n)); elseif (x <= 9.5e-133) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); elseif (x <= 0.88) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 6.6e-164) tmp = log(x) / -n; elseif (x <= 9.5e-133) tmp = 1.0 - (x ^ (1.0 / n)); elseif (x <= 0.88) tmp = (x - log(x)) / n; else tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 6.6e-164], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 9.5e-133], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.6 \cdot 10^{-164}:\\
\;\;\;\;\frac{\log x}{-n}\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-133}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{elif}\;x \leq 0.88:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 6.6e-164Initial program 38.3%
Taylor expanded in n around inf 62.9%
log1p-define62.9%
Simplified62.9%
Taylor expanded in x around 0 62.9%
neg-mul-162.9%
Simplified62.9%
if 6.6e-164 < x < 9.4999999999999992e-133Initial program 61.6%
Taylor expanded in x around 0 61.6%
*-rgt-identity61.6%
associate-*l/61.6%
associate-/l*61.6%
exp-to-pow61.6%
Simplified61.6%
if 9.4999999999999992e-133 < x < 0.880000000000000004Initial program 30.2%
Taylor expanded in n around inf 60.2%
log1p-define60.2%
Simplified60.2%
Taylor expanded in x around 0 59.2%
if 0.880000000000000004 < x Initial program 68.1%
Taylor expanded in n around inf 69.8%
log1p-define69.8%
Simplified69.8%
Taylor expanded in x around -inf 59.2%
Final simplification60.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 9.6e-143)
t_0
(if (<= x 2.3e-132)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= x 0.7)
t_0
(/
(/
(+
1.0
(/ (- (/ (- 0.3333333333333333 (* 0.25 (/ 1.0 x))) x) 0.5) x))
x)
n))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 9.6e-143) {
tmp = t_0;
} else if (x <= 2.3e-132) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 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 = log(x) / -n
if (x <= 9.6d-143) then
tmp = t_0
else if (x <= 2.3d-132) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if (x <= 0.7d0) then
tmp = t_0
else
tmp = ((1.0d0 + ((((0.3333333333333333d0 - (0.25d0 * (1.0d0 / x))) / x) - 0.5d0) / x)) / x) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 9.6e-143) {
tmp = t_0;
} else if (x <= 2.3e-132) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if (x <= 0.7) {
tmp = t_0;
} else {
tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 9.6e-143: tmp = t_0 elif x <= 2.3e-132: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif x <= 0.7: tmp = t_0 else: tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 9.6e-143) tmp = t_0; elseif (x <= 2.3e-132) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (x <= 0.7) tmp = t_0; else tmp = Float64(Float64(Float64(1.0 + Float64(Float64(Float64(Float64(0.3333333333333333 - Float64(0.25 * Float64(1.0 / x))) / x) - 0.5) / x)) / x) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 9.6e-143) tmp = t_0; elseif (x <= 2.3e-132) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif (x <= 0.7) tmp = t_0; else tmp = ((1.0 + ((((0.3333333333333333 - (0.25 * (1.0 / x))) / x) - 0.5) / x)) / x) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 9.6e-143], t$95$0, If[LessEqual[x, 2.3e-132], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 0.7], t$95$0, N[(N[(N[(1.0 + N[(N[(N[(N[(0.3333333333333333 - N[(0.25 * N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 9.6 \cdot 10^{-143}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-132}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;x \leq 0.7:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\
\end{array}
\end{array}
if x < 9.5999999999999995e-143 or 2.30000000000000003e-132 < x < 0.69999999999999996Initial program 35.5%
Taylor expanded in n around inf 60.4%
log1p-define60.4%
Simplified60.4%
Taylor expanded in x around 0 59.4%
neg-mul-159.4%
Simplified59.4%
if 9.5999999999999995e-143 < x < 2.30000000000000003e-132Initial program 67.7%
Taylor expanded in n around inf 7.1%
log1p-define7.1%
Simplified7.1%
Taylor expanded in x around inf 83.9%
associate--l+83.9%
unpow283.9%
associate-/r*83.9%
metadata-eval83.9%
associate-*r/83.9%
associate-*r/83.9%
metadata-eval83.9%
div-sub83.9%
sub-neg83.9%
metadata-eval83.9%
+-commutative83.9%
associate-*r/83.9%
metadata-eval83.9%
Simplified83.9%
if 0.69999999999999996 < x Initial program 68.1%
Taylor expanded in n around inf 69.8%
log1p-define69.8%
Simplified69.8%
Taylor expanded in x around -inf 59.2%
Final simplification59.9%
(FPCore (x n) :precision binary64 (* (/ 1.0 n) (/ (+ 1.0 (/ (+ -0.5 (/ (+ (/ 0.25 x) -0.3333333333333333) x)) x)) x)))
double code(double x, double n) {
return (1.0 / n) * ((1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) * ((1.0d0 + (((-0.5d0) + (((0.25d0 / x) + (-0.3333333333333333d0)) / x)) / x)) / x)
end function
public static double code(double x, double n) {
return (1.0 / n) * ((1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / x);
}
def code(x, n): return (1.0 / n) * ((1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / x)
function code(x, n) return Float64(Float64(1.0 / n) * Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / x)) / x)) / x)) end
function tmp = code(x, n) tmp = (1.0 / n) * ((1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / x); end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] * N[(N[(1.0 + N[(N[(-0.5 + N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n} \cdot \frac{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}}{x}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around -inf 25.0%
Applied egg-rr40.2%
Final simplification40.2%
(FPCore (x n) :precision binary64 (* (/ (/ 1.0 x) n) (+ 1.0 (/ (+ -0.5 (/ (+ (/ 0.25 x) -0.3333333333333333) x)) x))))
double code(double x, double n) {
return ((1.0 / x) / n) * (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x));
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / x) / n) * (1.0d0 + (((-0.5d0) + (((0.25d0 / x) + (-0.3333333333333333d0)) / x)) / x))
end function
public static double code(double x, double n) {
return ((1.0 / x) / n) * (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x));
}
def code(x, n): return ((1.0 / x) / n) * (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x))
function code(x, n) return Float64(Float64(Float64(1.0 / x) / n) * Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / x)) / x))) end
function tmp = code(x, n) tmp = ((1.0 / x) / n) * (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)); end
code[x_, n_] := N[(N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision] * N[(1.0 + N[(N[(-0.5 + N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n} \cdot \left(1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}\right)
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around -inf 25.0%
Applied egg-rr39.8%
unpow-139.8%
associate-/r/39.8%
+-commutative39.8%
+-commutative39.8%
Simplified39.8%
associate-*l/39.8%
*-commutative39.8%
associate-/r/39.8%
associate-/r*40.2%
Applied egg-rr40.2%
Final simplification40.2%
(FPCore (x n) :precision binary64 (/ (+ 1.0 (/ (+ -0.5 (/ (+ (/ 0.25 x) -0.3333333333333333) x)) x)) (* n x)))
double code(double x, double n) {
return (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 + (((-0.5d0) + (((0.25d0 / x) + (-0.3333333333333333d0)) / x)) / x)) / (n * x)
end function
public static double code(double x, double n) {
return (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / (n * x);
}
def code(x, n): return (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / (n * x)
function code(x, n) return Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / x)) / x)) / Float64(n * x)) end
function tmp = code(x, n) tmp = (1.0 + ((-0.5 + (((0.25 / x) + -0.3333333333333333) / x)) / x)) / (n * x); end
code[x_, n_] := N[(N[(1.0 + N[(N[(-0.5 + N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}}{n \cdot x}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around -inf 25.0%
Applied egg-rr40.2%
*-lft-identity40.2%
associate-/l/39.8%
+-commutative39.8%
+-commutative39.8%
*-commutative39.8%
Simplified39.8%
Final simplification39.8%
(FPCore (x n) :precision binary64 (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around inf 38.9%
associate--l+38.9%
unpow238.9%
associate-/r*38.9%
metadata-eval38.9%
associate-*r/38.9%
associate-*r/38.9%
metadata-eval38.9%
div-sub38.9%
sub-neg38.9%
metadata-eval38.9%
+-commutative38.9%
associate-*r/38.9%
metadata-eval38.9%
Simplified38.9%
Final simplification38.9%
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
return 1.0 / (n * x);
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
return 1.0 / (n * x);
}
def code(x, n): return 1.0 / (n * x)
function code(x, n) return Float64(1.0 / Float64(n * x)) end
function tmp = code(x, n) tmp = 1.0 / (n * x); end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{n \cdot x}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around inf 34.2%
*-commutative34.2%
Simplified34.2%
Final simplification34.2%
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
return (1.0 / n) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
return (1.0 / n) / x;
}
def code(x, n): return (1.0 / n) / x
function code(x, n) return Float64(Float64(1.0 / n) / x) end
function tmp = code(x, n) tmp = (1.0 / n) / x; end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n}}{x}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
div-inv63.0%
Applied egg-rr63.0%
Taylor expanded in x around inf 34.2%
associate-/r*34.6%
Simplified34.6%
Final simplification34.6%
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
return (1.0 / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
return (1.0 / x) / n;
}
def code(x, n): return (1.0 / x) / n
function code(x, n) return Float64(Float64(1.0 / x) / n) end
function tmp = code(x, n) tmp = (1.0 / x) / n; end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x}}{n}
\end{array}
Initial program 49.7%
Taylor expanded in n around inf 63.1%
log1p-define63.1%
Simplified63.1%
Taylor expanded in x around inf 34.6%
Final simplification34.6%
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
return x / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = x / n
end function
public static double code(double x, double n) {
return x / n;
}
def code(x, n): return x / n
function code(x, n) return Float64(x / n) end
function tmp = code(x, n) tmp = x / n; end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{n}
\end{array}
Initial program 49.7%
Taylor expanded in x around 0 27.8%
Taylor expanded in x around inf 4.6%
Final simplification4.6%
herbie shell --seed 2024076
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))