
(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 15 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))) (t_1 (log (+ 1.0 x))) (t_2 (/ (log x) n)))
(if (<= (/ 1.0 n) -5e-42)
(/ (exp t_2) (* n x))
(if (<= (/ 1.0 n) 4e-105)
(-
(+ (* 0.5 (/ (pow t_1 2.0) (pow n 2.0))) (/ t_1 n))
(+ t_2 (* 0.5 (/ (pow (log x) 2.0) (pow n 2.0)))))
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 n))
(- (exp (/ x n)) t_0))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log((1.0 + x));
double t_2 = log(x) / n;
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = exp(t_2) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = ((0.5 * (pow(t_1, 2.0) / pow(n, 2.0))) + (t_1 / n)) - (t_2 + (0.5 * (pow(log(x), 2.0) / pow(n, 2.0))));
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log((1.0d0 + x))
t_2 = log(x) / n
if ((1.0d0 / n) <= (-5d-42)) then
tmp = exp(t_2) / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = ((0.5d0 * ((t_1 ** 2.0d0) / (n ** 2.0d0))) + (t_1 / n)) - (t_2 + (0.5d0 * ((log(x) ** 2.0d0) / (n ** 2.0d0))))
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / 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 t_1 = Math.log((1.0 + x));
double t_2 = Math.log(x) / n;
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = Math.exp(t_2) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = ((0.5 * (Math.pow(t_1, 2.0) / Math.pow(n, 2.0))) + (t_1 / n)) - (t_2 + (0.5 * (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0))));
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log((1.0 + x)) t_2 = math.log(x) / n tmp = 0 if (1.0 / n) <= -5e-42: tmp = math.exp(t_2) / (n * x) elif (1.0 / n) <= 4e-105: tmp = ((0.5 * (math.pow(t_1, 2.0) / math.pow(n, 2.0))) + (t_1 / n)) - (t_2 + (0.5 * (math.pow(math.log(x), 2.0) / math.pow(n, 2.0)))) elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / n) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = log(Float64(1.0 + x)) t_2 = Float64(log(x) / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(exp(t_2) / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(Float64(Float64(0.5 * Float64((t_1 ^ 2.0) / (n ^ 2.0))) + Float64(t_1 / n)) - Float64(t_2 + Float64(0.5 * Float64((log(x) ^ 2.0) / (n ^ 2.0))))); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / 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); t_1 = log((1.0 + x)); t_2 = log(x) / n; tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = exp(t_2) / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = ((0.5 * ((t_1 ^ 2.0) / (n ^ 2.0))) + (t_1 / n)) - (t_2 + (0.5 * ((log(x) ^ 2.0) / (n ^ 2.0)))); elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / 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]}, Block[{t$95$1 = N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-42], N[(N[Exp[t$95$2], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[(N[(0.5 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 / n), $MachinePrecision]), $MachinePrecision] - N[(t$95$2 + N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $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)}\\
t_1 := \log \left(1 + x\right)\\
t_2 := \frac{\log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{e^{t_2}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\left(0.5 \cdot \frac{{t_1}^{2}}{{n}^{2}} + \frac{t_1}{n}\right) - \left(t_2 + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) Initial program 56.6%
Taylor expanded in n around 0 56.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e+151)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.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) <= (-5d-42)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d+151) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.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 tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = t_0 / (n * x) elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e+151: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e+151) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e+151) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.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], -5e-42], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+151], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+151}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-*r/97.5%
exp-to-pow97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
log1p-def79.9%
Simplified79.9%
log1p-udef79.9%
diff-log79.9%
+-commutative79.9%
Applied egg-rr79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) < 1.00000000000000002e151Initial program 85.2%
Taylor expanded in x around 0 87.8%
if 1.00000000000000002e151 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.2%
log1p-def6.2%
Simplified6.2%
Taylor expanded in x around inf 43.5%
*-commutative43.5%
Simplified43.5%
add-sqr-sqrt43.5%
sqrt-unprod85.5%
inv-pow85.5%
inv-pow85.5%
pow-prod-up85.5%
metadata-eval85.5%
Applied egg-rr85.5%
Final simplification85.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e+151)
(- (+ 1.0 (/ x n)) t_0)
(sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = sqrt(pow((n * x), -2.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) <= (-5d-42)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d+151) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = sqrt(((n * x) ** (-2.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 tmp;
if ((1.0 / n) <= -5e-42) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+151) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = Math.sqrt(Math.pow((n * x), -2.0));
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e+151: tmp = (1.0 + (x / n)) - t_0 else: tmp = math.sqrt(math.pow((n * x), -2.0)) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e+151) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = sqrt((Float64(n * x) ^ -2.0)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e+151) tmp = (1.0 + (x / n)) - t_0; else tmp = sqrt(((n * x) ^ -2.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], -5e-42], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+151], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+151}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
log1p-def79.9%
Simplified79.9%
log1p-udef79.9%
diff-log79.9%
+-commutative79.9%
Applied egg-rr79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) < 1.00000000000000002e151Initial program 85.2%
Taylor expanded in x around 0 87.8%
if 1.00000000000000002e151 < (/.f64 1 n) Initial program 26.6%
Taylor expanded in n around inf 6.2%
log1p-def6.2%
Simplified6.2%
Taylor expanded in x around inf 43.5%
*-commutative43.5%
Simplified43.5%
add-sqr-sqrt43.5%
sqrt-unprod85.5%
inv-pow85.5%
inv-pow85.5%
pow-prod-up85.5%
metadata-eval85.5%
Applied egg-rr85.5%
Final simplification85.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ (exp (/ (log x) n)) (* n x))
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 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) <= -5e-42) {
tmp = exp((log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / 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) <= (-5d-42)) then
tmp = exp((log(x) / n)) / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / 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) <= -5e-42) {
tmp = Math.exp((Math.log(x) / n)) / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / 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) <= -5e-42: tmp = math.exp((math.log(x) / n)) / (n * x) elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / 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) <= -5e-42) tmp = Float64(exp(Float64(log(x) / n)) / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / 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) <= -5e-42) tmp = exp((log(x) / n)) / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / 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], -5e-42], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $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 -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
log1p-def79.9%
Simplified79.9%
log1p-udef79.9%
diff-log79.9%
+-commutative79.9%
Applied egg-rr79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) Initial program 56.6%
Taylor expanded in n around 0 56.6%
log1p-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Final simplification87.5%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e+198)
(- (+ 1.0 (/ x n)) t_0)
(/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+198) {
tmp = (1.0 + (x / n)) - t_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) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d+198) then
tmp = (1.0d0 + (x / n)) - t_0
else
tmp = 1.0d0 / (n * x)
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) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+198) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = t_0 / (n * x) elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e+198: tmp = (1.0 + (x / n)) - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e+198) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e+198) tmp = (1.0 + (x / n)) - t_0; else tmp = 1.0 / (n * x); 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], -5e-42], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+198], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+198}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-*r/97.5%
exp-to-pow97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
log1p-def79.9%
Simplified79.9%
log1p-udef79.9%
diff-log79.9%
+-commutative79.9%
Applied egg-rr79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) < 1.00000000000000002e198Initial program 73.5%
Taylor expanded in x around 0 69.1%
if 1.00000000000000002e198 < (/.f64 1 n) Initial program 10.6%
Taylor expanded in n around inf 7.3%
log1p-def7.3%
Simplified7.3%
Taylor expanded in x around inf 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification82.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log x)) n)))
(if (<= x 4.05e-290)
t_0
(if (<= x 3e-142)
t_1
(if (<= x 3.6e-126)
t_0
(if (<= x 8e-97)
t_1
(if (<= x 2.2e-84)
t_0
(if (<= x 0.05) (/ (- x (log x)) n) (/ (/ 1.0 n) x)))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = -log(x) / n;
double tmp;
if (x <= 4.05e-290) {
tmp = t_0;
} else if (x <= 3e-142) {
tmp = t_1;
} else if (x <= 3.6e-126) {
tmp = t_0;
} else if (x <= 8e-97) {
tmp = t_1;
} else if (x <= 2.2e-84) {
tmp = t_0;
} else if (x <= 0.05) {
tmp = (x - log(x)) / n;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = -log(x) / n
if (x <= 4.05d-290) then
tmp = t_0
else if (x <= 3d-142) then
tmp = t_1
else if (x <= 3.6d-126) then
tmp = t_0
else if (x <= 8d-97) then
tmp = t_1
else if (x <= 2.2d-84) then
tmp = t_0
else if (x <= 0.05d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double t_1 = -Math.log(x) / n;
double tmp;
if (x <= 4.05e-290) {
tmp = t_0;
} else if (x <= 3e-142) {
tmp = t_1;
} else if (x <= 3.6e-126) {
tmp = t_0;
} else if (x <= 8e-97) {
tmp = t_1;
} else if (x <= 2.2e-84) {
tmp = t_0;
} else if (x <= 0.05) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) t_1 = -math.log(x) / n tmp = 0 if x <= 4.05e-290: tmp = t_0 elif x <= 3e-142: tmp = t_1 elif x <= 3.6e-126: tmp = t_0 elif x <= 8e-97: tmp = t_1 elif x <= 2.2e-84: tmp = t_0 elif x <= 0.05: tmp = (x - math.log(x)) / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(Float64(-log(x)) / n) tmp = 0.0 if (x <= 4.05e-290) tmp = t_0; elseif (x <= 3e-142) tmp = t_1; elseif (x <= 3.6e-126) tmp = t_0; elseif (x <= 8e-97) tmp = t_1; elseif (x <= 2.2e-84) tmp = t_0; elseif (x <= 0.05) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); t_1 = -log(x) / n; tmp = 0.0; if (x <= 4.05e-290) tmp = t_0; elseif (x <= 3e-142) tmp = t_1; elseif (x <= 3.6e-126) tmp = t_0; elseif (x <= 8e-97) tmp = t_1; elseif (x <= 2.2e-84) tmp = t_0; elseif (x <= 0.05) tmp = (x - log(x)) / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.05e-290], t$95$0, If[LessEqual[x, 3e-142], t$95$1, If[LessEqual[x, 3.6e-126], t$95$0, If[LessEqual[x, 8e-97], t$95$1, If[LessEqual[x, 2.2e-84], t$95$0, If[LessEqual[x, 0.05], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 4.05 \cdot 10^{-290}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-142}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-126}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-97}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-84}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 0.05:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 4.05000000000000027e-290 or 3.0000000000000001e-142 < x < 3.5999999999999999e-126 or 8.00000000000000029e-97 < x < 2.1999999999999999e-84Initial program 70.1%
Taylor expanded in x around 0 70.1%
if 4.05000000000000027e-290 < x < 3.0000000000000001e-142 or 3.5999999999999999e-126 < x < 8.00000000000000029e-97Initial program 41.4%
Taylor expanded in x around 0 41.4%
Taylor expanded in n around inf 55.7%
neg-mul-155.7%
distribute-neg-frac55.7%
Simplified55.7%
if 2.1999999999999999e-84 < x < 0.050000000000000003Initial program 27.5%
Taylor expanded in n around inf 56.6%
log1p-def56.6%
Simplified56.6%
Taylor expanded in x around 0 55.7%
neg-mul-155.7%
unsub-neg55.7%
Simplified55.7%
if 0.050000000000000003 < x Initial program 59.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 71.3%
*-commutative71.3%
Simplified71.3%
clear-num71.3%
associate-/r/71.3%
*-commutative71.3%
associate-/r*72.9%
Applied egg-rr72.9%
Final simplification64.6%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -400000.0)
t_0
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(/ (/ 1.0 x) n)
(if (<= (/ 1.0 n) 1e+198) t_0 (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -400000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 1e+198) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
if ((1.0d0 / n) <= (-400000.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) / n
else if ((1.0d0 / n) <= 1d+198) then
tmp = t_0
else
tmp = 1.0d0 / (n * x)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = 1.0 - Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -400000.0) {
tmp = t_0;
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) / n;
} else if ((1.0 / n) <= 1e+198) {
tmp = t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -400000.0: tmp = t_0 elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) / n elif (1.0 / n) <= 1e+198: tmp = t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (Float64(1.0 / n) <= -400000.0) tmp = t_0; elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) / n); elseif (Float64(1.0 / n) <= 1e+198) tmp = t_0; else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if ((1.0 / n) <= -400000.0) tmp = t_0; elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) / n; elseif ((1.0 / n) <= 1e+198) tmp = t_0; else tmp = 1.0 / (n * x); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -400000.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+198], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -400000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+198}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -4e5 or 2e3 < (/.f64 1 n) < 1.00000000000000002e198Initial program 91.6%
Taylor expanded in x around 0 64.1%
if -4e5 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.4%
Taylor expanded in n around inf 75.7%
log1p-def75.7%
Simplified75.7%
log1p-udef75.7%
diff-log75.7%
+-commutative75.7%
Applied egg-rr75.7%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in n around inf 43.0%
log1p-def43.0%
Simplified43.0%
Taylor expanded in x around inf 66.1%
if 1.00000000000000002e198 < (/.f64 1 n) Initial program 10.6%
Taylor expanded in n around inf 7.3%
log1p-def7.3%
Simplified7.3%
Taylor expanded in x around inf 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification70.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ t_0 (* n x))))
(if (<= (/ 1.0 n) -5e-42)
t_1
(if (<= (/ 1.0 n) 2e-100)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
t_1
(if (<= (/ 1.0 n) 1e+198) (- 1.0 t_0) (/ 1.0 (* n x))))))))
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) <= -5e-42) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-100) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+198) {
tmp = 1.0 - t_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) :: 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) <= (-5d-42)) then
tmp = t_1
else if ((1.0d0 / n) <= 2d-100) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 1d+198) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
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) <= -5e-42) {
tmp = t_1;
} else if ((1.0 / n) <= 2e-100) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 1e+198) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
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) <= -5e-42: tmp = t_1 elif (1.0 / n) <= 2e-100: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = t_1 elif (1.0 / n) <= 1e+198: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) 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) <= -5e-42) tmp = t_1; elseif (Float64(1.0 / n) <= 2e-100) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 1e+198) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); 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) <= -5e-42) tmp = t_1; elseif ((1.0 / n) <= 2e-100) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = t_1; elseif ((1.0 / n) <= 1e+198) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); 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], -5e-42], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-100], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+198], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $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 -5 \cdot 10^{-42}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-100}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+198}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42 or 2e-100 < (/.f64 1 n) < 2e3Initial program 73.6%
Taylor expanded in x around inf 91.4%
mul-1-neg91.4%
log-rec91.4%
mul-1-neg91.4%
distribute-neg-frac91.4%
mul-1-neg91.4%
remove-double-neg91.4%
*-commutative91.4%
Simplified91.4%
Taylor expanded in x around 0 91.4%
*-rgt-identity91.4%
associate-*l/91.4%
associate-*r/91.4%
exp-to-pow91.4%
*-commutative91.4%
Simplified91.4%
if -5.00000000000000003e-42 < (/.f64 1 n) < 2e-100Initial program 30.8%
Taylor expanded in n around inf 79.5%
log1p-def79.5%
Simplified79.5%
log1p-udef79.5%
diff-log79.5%
+-commutative79.5%
Applied egg-rr79.5%
if 2e3 < (/.f64 1 n) < 1.00000000000000002e198Initial program 73.5%
Taylor expanded in x around 0 67.0%
if 1.00000000000000002e198 < (/.f64 1 n) Initial program 10.6%
Taylor expanded in n around inf 7.3%
log1p-def7.3%
Simplified7.3%
Taylor expanded in x around inf 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification81.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-42)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 4e-105)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) 2000.0)
(* (/ 1.0 x) (/ t_0 n))
(if (<= (/ 1.0 n) 1e+198) (- 1.0 t_0) (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+198) {
tmp = 1.0 - t_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) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-5d-42)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 4d-105) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= 2000.0d0) then
tmp = (1.0d0 / x) * (t_0 / n)
else if ((1.0d0 / n) <= 1d+198) then
tmp = 1.0d0 - t_0
else
tmp = 1.0d0 / (n * x)
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) <= -5e-42) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 4e-105) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= 2000.0) {
tmp = (1.0 / x) * (t_0 / n);
} else if ((1.0 / n) <= 1e+198) {
tmp = 1.0 - t_0;
} else {
tmp = 1.0 / (n * x);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-42: tmp = t_0 / (n * x) elif (1.0 / n) <= 4e-105: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= 2000.0: tmp = (1.0 / x) * (t_0 / n) elif (1.0 / n) <= 1e+198: tmp = 1.0 - t_0 else: tmp = 1.0 / (n * x) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-42) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 4e-105) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= 2000.0) tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n)); elseif (Float64(1.0 / n) <= 1e+198) tmp = Float64(1.0 - t_0); else tmp = Float64(1.0 / Float64(n * x)); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -5e-42) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 4e-105) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= 2000.0) tmp = (1.0 / x) * (t_0 / n); elseif ((1.0 / n) <= 1e+198) tmp = 1.0 - t_0; else tmp = 1.0 / (n * x); 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], -5e-42], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-105], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+198], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-42}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-105}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 10^{+198}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000003e-42Initial program 90.2%
Taylor expanded in x around inf 97.5%
mul-1-neg97.5%
log-rec97.5%
mul-1-neg97.5%
distribute-neg-frac97.5%
mul-1-neg97.5%
remove-double-neg97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in x around 0 97.5%
*-rgt-identity97.5%
associate-*l/97.5%
associate-*r/97.5%
exp-to-pow97.5%
*-commutative97.5%
Simplified97.5%
if -5.00000000000000003e-42 < (/.f64 1 n) < 3.99999999999999986e-105Initial program 30.7%
Taylor expanded in n around inf 79.9%
log1p-def79.9%
Simplified79.9%
log1p-udef79.9%
diff-log79.9%
+-commutative79.9%
Applied egg-rr79.9%
if 3.99999999999999986e-105 < (/.f64 1 n) < 2e3Initial program 13.8%
Taylor expanded in x around inf 67.6%
mul-1-neg67.6%
log-rec67.6%
mul-1-neg67.6%
distribute-neg-frac67.6%
mul-1-neg67.6%
remove-double-neg67.6%
*-commutative67.6%
Simplified67.6%
div-inv67.6%
pow-to-exp67.6%
*-un-lft-identity67.6%
times-frac71.1%
Applied egg-rr71.1%
if 2e3 < (/.f64 1 n) < 1.00000000000000002e198Initial program 73.5%
Taylor expanded in x around 0 67.0%
if 1.00000000000000002e198 < (/.f64 1 n) Initial program 10.6%
Taylor expanded in n around inf 7.3%
log1p-def7.3%
Simplified7.3%
Taylor expanded in x around inf 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification82.2%
(FPCore (x n) :precision binary64 (if (<= x 0.05) (/ (- x (log x)) n) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.05) {
tmp = (x - log(x)) / n;
} 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 (x <= 0.05d0) then
tmp = (x - log(x)) / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.05) {
tmp = (x - Math.log(x)) / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.05: tmp = (x - math.log(x)) / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.05) tmp = Float64(Float64(x - log(x)) / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.05) tmp = (x - log(x)) / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.05], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.05:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 0.050000000000000003Initial program 44.6%
Taylor expanded in n around inf 49.8%
log1p-def49.8%
Simplified49.8%
Taylor expanded in x around 0 49.6%
neg-mul-149.6%
unsub-neg49.6%
Simplified49.6%
if 0.050000000000000003 < x Initial program 59.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 71.3%
*-commutative71.3%
Simplified71.3%
clear-num71.3%
associate-/r/71.3%
*-commutative71.3%
associate-/r*72.9%
Applied egg-rr72.9%
Final simplification59.2%
(FPCore (x n) :precision binary64 (if (<= x 0.04) (/ (- (log x)) n) (/ (/ 1.0 n) x)))
double code(double x, double n) {
double tmp;
if (x <= 0.04) {
tmp = -log(x) / n;
} 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 (x <= 0.04d0) then
tmp = -log(x) / n
else
tmp = (1.0d0 / n) / x
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.04) {
tmp = -Math.log(x) / n;
} else {
tmp = (1.0 / n) / x;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.04: tmp = -math.log(x) / n else: tmp = (1.0 / n) / x return tmp
function code(x, n) tmp = 0.0 if (x <= 0.04) tmp = Float64(Float64(-log(x)) / n); else tmp = Float64(Float64(1.0 / n) / x); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.04) tmp = -log(x) / n; else tmp = (1.0 / n) / x; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.04], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.04:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\end{array}
\end{array}
if x < 0.0400000000000000008Initial program 44.6%
Taylor expanded in x around 0 44.0%
Taylor expanded in n around inf 48.8%
neg-mul-148.8%
distribute-neg-frac48.8%
Simplified48.8%
if 0.0400000000000000008 < x Initial program 59.5%
Taylor expanded in n around inf 57.7%
log1p-def57.7%
Simplified57.7%
Taylor expanded in x around inf 71.3%
*-commutative71.3%
Simplified71.3%
clear-num71.3%
associate-/r/71.3%
*-commutative71.3%
associate-/r*72.9%
Applied egg-rr72.9%
Final simplification58.8%
(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 50.8%
Taylor expanded in n around inf 53.1%
log1p-def53.1%
Simplified53.1%
Taylor expanded in x around inf 43.3%
*-commutative43.3%
Simplified43.3%
Final simplification43.3%
(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 50.8%
Taylor expanded in n around inf 53.1%
log1p-def53.1%
Simplified53.1%
Taylor expanded in x around inf 43.9%
Final simplification43.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(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 50.8%
Taylor expanded in n around inf 53.1%
log1p-def53.1%
Simplified53.1%
Taylor expanded in x around inf 43.3%
*-commutative43.3%
Simplified43.3%
clear-num43.3%
associate-/r/43.3%
*-commutative43.3%
associate-/r*44.0%
Applied egg-rr44.0%
Final simplification44.0%
(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 50.8%
Taylor expanded in x around 0 32.7%
Taylor expanded in x around inf 4.4%
Final simplification4.4%
herbie shell --seed 2024018
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))