
(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 13 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-18)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5000.0)
(- (/ (log (/ x (+ 1.0 x))) n))
(- (exp (/ x n)) t_0)))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(log((x / (1.0 + x))) / n);
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
if ((1.0d0 / n) <= (-2d-18)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = -(log((x / (1.0d0 + x))) / n)
else
tmp = exp((x / n)) - t_0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(Math.log((x / (1.0 + x))) / n);
} else {
tmp = Math.exp((x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -2e-18: tmp = t_0 / (n * x) elif (1.0 / n) <= 5000.0: tmp = -(math.log((x / (1.0 + x))) / n) else: tmp = math.exp((x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -2e-18) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(-Float64(log(Float64(x / Float64(1.0 + x))) / n)); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); tmp = 0.0; if ((1.0 / n) <= -2e-18) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5000.0) tmp = -(log((x / (1.0 + x))) / n); else tmp = exp((x / n)) - t_0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-18], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-18Initial program 96.3%
Taylor expanded in n around 0 96.3%
log1p-def96.3%
Simplified96.3%
Taylor expanded in x around inf 100.0%
log-rec100.0%
neg-mul-1100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
associate-*r/100.0%
associate-*l/100.0%
log-pow100.0%
rem-exp-log100.0%
*-commutative100.0%
Simplified100.0%
if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3Initial program 28.4%
Taylor expanded in n around inf 78.9%
log1p-def78.9%
Simplified78.9%
log1p-udef78.9%
diff-log79.1%
+-commutative79.1%
Applied egg-rr79.1%
clear-num79.1%
log-div79.1%
metadata-eval79.1%
Applied egg-rr79.1%
neg-sub079.1%
Simplified79.1%
if 5e3 < (/.f64 1 n) Initial program 54.0%
Taylor expanded in n around 0 54.0%
log1p-def97.4%
Simplified97.4%
Taylor expanded in x around 0 97.4%
Final simplification88.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-18)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5000.0)
(- (/ (log (/ x (+ 1.0 x))) n))
(if (<= (/ 1.0 n) 5e+195)
(- (+ 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= (-2d-18)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = -(log((x / (1.0d0 + x))) / n)
else if ((1.0d0 / n) <= 5d+195) 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(Math.log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= -2e-18: tmp = t_0 / (n * x) elif (1.0 / n) <= 5000.0: tmp = -(math.log((x / (1.0 + x))) / n) elif (1.0 / n) <= 5e+195: 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) <= -2e-18) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(-Float64(log(Float64(x / Float64(1.0 + x))) / n)); elseif (Float64(1.0 / n) <= 5e+195) 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) <= -2e-18) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5000.0) tmp = -(log((x / (1.0 + x))) / n); elseif ((1.0 / n) <= 5e+195) 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], -2e-18], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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 -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\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) < -2.0000000000000001e-18Initial program 96.3%
Taylor expanded in n around 0 96.3%
log1p-def96.3%
Simplified96.3%
Taylor expanded in x around inf 100.0%
log-rec100.0%
neg-mul-1100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
associate-*r/100.0%
associate-*l/100.0%
log-pow100.0%
rem-exp-log100.0%
*-commutative100.0%
Simplified100.0%
if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3Initial program 28.4%
Taylor expanded in n around inf 78.9%
log1p-def78.9%
Simplified78.9%
log1p-udef78.9%
diff-log79.1%
+-commutative79.1%
Applied egg-rr79.1%
clear-num79.1%
log-div79.1%
metadata-eval79.1%
Applied egg-rr79.1%
neg-sub079.1%
Simplified79.1%
if 5e3 < (/.f64 1 n) < 4.9999999999999998e195Initial program 79.6%
Taylor expanded in x around 0 79.8%
if 4.9999999999999998e195 < (/.f64 1 n) Initial program 10.0%
Taylor expanded in n around inf 20.9%
log1p-def20.9%
Simplified20.9%
Taylor expanded in x around inf 86.6%
*-commutative86.6%
Simplified86.6%
add-sqr-sqrt86.6%
sqrt-unprod93.1%
inv-pow93.1%
inv-pow93.1%
pow-prod-up93.1%
metadata-eval93.1%
Applied egg-rr93.1%
Final simplification86.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ 1.0 x) x)) n)))
(if (<= (/ 1.0 n) -1e+251)
t_1
(if (<= (/ 1.0 n) -4.0)
t_0
(if (<= (/ 1.0 n) 5000.0)
t_1
(if (<= (/ 1.0 n) 5e+195) t_0 (/ 1.0 (* n x))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double t_1 = log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e+251) {
tmp = t_1;
} else if ((1.0 / n) <= -4.0) {
tmp = t_0;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+195) {
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(((1.0d0 + x) / x)) / n
if ((1.0d0 / n) <= (-1d+251)) then
tmp = t_1
else if ((1.0d0 / n) <= (-4.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = t_1
else if ((1.0d0 / n) <= 5d+195) 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 t_1 = Math.log(((1.0 + x) / x)) / n;
double tmp;
if ((1.0 / n) <= -1e+251) {
tmp = t_1;
} else if ((1.0 / n) <= -4.0) {
tmp = t_0;
} else if ((1.0 / n) <= 5000.0) {
tmp = t_1;
} else if ((1.0 / n) <= 5e+195) {
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)) t_1 = math.log(((1.0 + x) / x)) / n tmp = 0 if (1.0 / n) <= -1e+251: tmp = t_1 elif (1.0 / n) <= -4.0: tmp = t_0 elif (1.0 / n) <= 5000.0: tmp = t_1 elif (1.0 / n) <= 5e+195: 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))) t_1 = Float64(log(Float64(Float64(1.0 + x) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -1e+251) tmp = t_1; elseif (Float64(1.0 / n) <= -4.0) tmp = t_0; elseif (Float64(1.0 / n) <= 5000.0) tmp = t_1; elseif (Float64(1.0 / n) <= 5e+195) 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)); t_1 = log(((1.0 + x) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -1e+251) tmp = t_1; elseif ((1.0 / n) <= -4.0) tmp = t_0; elseif ((1.0 / n) <= 5000.0) tmp = t_1; elseif ((1.0 / n) <= 5e+195) 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]}, Block[{t$95$1 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+251], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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)}\\
t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+251}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq -4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e251 or -4 < (/.f64 1 n) < 5e3Initial program 34.7%
Taylor expanded in n around inf 76.6%
log1p-def76.6%
Simplified76.6%
log1p-udef76.6%
diff-log76.8%
+-commutative76.8%
Applied egg-rr76.8%
if -1e251 < (/.f64 1 n) < -4 or 5e3 < (/.f64 1 n) < 4.9999999999999998e195Initial program 94.1%
Taylor expanded in x around 0 73.1%
if 4.9999999999999998e195 < (/.f64 1 n) Initial program 10.0%
Taylor expanded in n around inf 20.9%
log1p-def20.9%
Simplified20.9%
Taylor expanded in x around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification76.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= (/ 1.0 n) -1e+251)
(/ (log (/ (+ 1.0 x) x)) n)
(if (<= (/ 1.0 n) -4.0)
t_0
(if (<= (/ 1.0 n) 5000.0)
(- (/ (log (/ x (+ 1.0 x))) n))
(if (<= (/ 1.0 n) 5e+195) 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) <= -1e+251) {
tmp = log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -4.0) {
tmp = t_0;
} else if ((1.0 / n) <= 5000.0) {
tmp = -(log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= (-1d+251)) then
tmp = log(((1.0d0 + x) / x)) / n
else if ((1.0d0 / n) <= (-4.0d0)) then
tmp = t_0
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = -(log((x / (1.0d0 + x))) / n)
else if ((1.0d0 / n) <= 5d+195) 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) <= -1e+251) {
tmp = Math.log(((1.0 + x) / x)) / n;
} else if ((1.0 / n) <= -4.0) {
tmp = t_0;
} else if ((1.0 / n) <= 5000.0) {
tmp = -(Math.log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= -1e+251: tmp = math.log(((1.0 + x) / x)) / n elif (1.0 / n) <= -4.0: tmp = t_0 elif (1.0 / n) <= 5000.0: tmp = -(math.log((x / (1.0 + x))) / n) elif (1.0 / n) <= 5e+195: 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) <= -1e+251) tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n); elseif (Float64(1.0 / n) <= -4.0) tmp = t_0; elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(-Float64(log(Float64(x / Float64(1.0 + x))) / n)); elseif (Float64(1.0 / n) <= 5e+195) 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) <= -1e+251) tmp = log(((1.0 + x) / x)) / n; elseif ((1.0 / n) <= -4.0) tmp = t_0; elseif ((1.0 / n) <= 5000.0) tmp = -(log((x / (1.0 + x))) / n); elseif ((1.0 / n) <= 5e+195) 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], -1e+251], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -4.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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 -1 \cdot 10^{+251}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -4:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -1e251Initial program 100.0%
Taylor expanded in n around inf 69.5%
log1p-def69.5%
Simplified69.5%
log1p-udef69.5%
diff-log69.5%
+-commutative69.5%
Applied egg-rr69.5%
if -1e251 < (/.f64 1 n) < -4 or 5e3 < (/.f64 1 n) < 4.9999999999999998e195Initial program 94.1%
Taylor expanded in x around 0 73.1%
if -4 < (/.f64 1 n) < 5e3Initial program 27.9%
Taylor expanded in n around inf 77.3%
log1p-def77.3%
Simplified77.3%
log1p-udef77.3%
diff-log77.5%
+-commutative77.5%
Applied egg-rr77.5%
clear-num77.5%
log-div77.6%
metadata-eval77.6%
Applied egg-rr77.6%
neg-sub077.6%
Simplified77.6%
if 4.9999999999999998e195 < (/.f64 1 n) Initial program 10.0%
Taylor expanded in n around inf 20.9%
log1p-def20.9%
Simplified20.9%
Taylor expanded in x around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification76.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-18)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5000.0)
(- (/ (log (/ x (+ 1.0 x))) n))
(if (<= (/ 1.0 n) 5e+195) (- (+ 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= (-2d-18)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = -(log((x / (1.0d0 + x))) / n)
else if ((1.0d0 / n) <= 5d+195) 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(Math.log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= -2e-18: tmp = t_0 / (n * x) elif (1.0 / n) <= 5000.0: tmp = -(math.log((x / (1.0 + x))) / n) elif (1.0 / n) <= 5e+195: 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) <= -2e-18) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(-Float64(log(Float64(x / Float64(1.0 + x))) / n)); elseif (Float64(1.0 / n) <= 5e+195) 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) <= -2e-18) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5000.0) tmp = -(log((x / (1.0 + x))) / n); elseif ((1.0 / n) <= 5e+195) 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], -2e-18], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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 -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-18Initial program 96.3%
Taylor expanded in n around 0 96.3%
log1p-def96.3%
Simplified96.3%
Taylor expanded in x around inf 100.0%
log-rec100.0%
neg-mul-1100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
associate-*r/100.0%
associate-*l/100.0%
log-pow100.0%
rem-exp-log100.0%
*-commutative100.0%
Simplified100.0%
if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3Initial program 28.4%
Taylor expanded in n around inf 78.9%
log1p-def78.9%
Simplified78.9%
log1p-udef78.9%
diff-log79.1%
+-commutative79.1%
Applied egg-rr79.1%
clear-num79.1%
log-div79.1%
metadata-eval79.1%
Applied egg-rr79.1%
neg-sub079.1%
Simplified79.1%
if 5e3 < (/.f64 1 n) < 4.9999999999999998e195Initial program 79.6%
Taylor expanded in x around 0 79.8%
if 4.9999999999999998e195 < (/.f64 1 n) Initial program 10.0%
Taylor expanded in n around inf 20.9%
log1p-def20.9%
Simplified20.9%
Taylor expanded in x around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification85.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -2e-18)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 5000.0)
(- (/ (log (/ x (+ 1.0 x))) n))
(if (<= (/ 1.0 n) 5e+195) (- 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= (-2d-18)) then
tmp = t_0 / (n * x)
else if ((1.0d0 / n) <= 5000.0d0) then
tmp = -(log((x / (1.0d0 + x))) / n)
else if ((1.0d0 / n) <= 5d+195) 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) <= -2e-18) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 5000.0) {
tmp = -(Math.log((x / (1.0 + x))) / n);
} else if ((1.0 / n) <= 5e+195) {
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) <= -2e-18: tmp = t_0 / (n * x) elif (1.0 / n) <= 5000.0: tmp = -(math.log((x / (1.0 + x))) / n) elif (1.0 / n) <= 5e+195: 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) <= -2e-18) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 5000.0) tmp = Float64(-Float64(log(Float64(x / Float64(1.0 + x))) / n)); elseif (Float64(1.0 / n) <= 5e+195) 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) <= -2e-18) tmp = t_0 / (n * x); elseif ((1.0 / n) <= 5000.0) tmp = -(log((x / (1.0 + x))) / n); elseif ((1.0 / n) <= 5e+195) 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], -2e-18], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-N[(N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]), If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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 -2 \cdot 10^{-18}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;1 - t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\end{array}
\end{array}
if (/.f64 1 n) < -2.0000000000000001e-18Initial program 96.3%
Taylor expanded in n around 0 96.3%
log1p-def96.3%
Simplified96.3%
Taylor expanded in x around inf 100.0%
log-rec100.0%
neg-mul-1100.0%
associate-*r/100.0%
associate-*r*100.0%
metadata-eval100.0%
associate-*r/100.0%
associate-*l/100.0%
log-pow100.0%
rem-exp-log100.0%
*-commutative100.0%
Simplified100.0%
if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3Initial program 28.4%
Taylor expanded in n around inf 78.9%
log1p-def78.9%
Simplified78.9%
log1p-udef78.9%
diff-log79.1%
+-commutative79.1%
Applied egg-rr79.1%
clear-num79.1%
log-div79.1%
metadata-eval79.1%
Applied egg-rr79.1%
neg-sub079.1%
Simplified79.1%
if 5e3 < (/.f64 1 n) < 4.9999999999999998e195Initial program 79.6%
Taylor expanded in x around 0 79.6%
if 4.9999999999999998e195 < (/.f64 1 n) Initial program 10.0%
Taylor expanded in n around inf 20.9%
log1p-def20.9%
Simplified20.9%
Taylor expanded in x around inf 86.6%
*-commutative86.6%
Simplified86.6%
Final simplification85.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
(if (<= x 7.5e-227)
t_0
(if (<= x 2.6e-208)
(* (log x) (/ -1.0 n))
(if (<= x 5.5e-173)
t_0
(if (<= x 2.8e-38)
(/ (- (log x)) n)
(if (<= x 2.3e-25)
t_0
(if (<= x 1.0)
(/ (- x (log x)) n)
(if (<= x 2.6e+128) (/ (/ 1.0 n) x) (/ 0.0 n))))))))))
double code(double x, double n) {
double t_0 = 1.0 - pow(x, (1.0 / n));
double tmp;
if (x <= 7.5e-227) {
tmp = t_0;
} else if (x <= 2.6e-208) {
tmp = log(x) * (-1.0 / n);
} else if (x <= 5.5e-173) {
tmp = t_0;
} else if (x <= 2.8e-38) {
tmp = -log(x) / n;
} else if (x <= 2.3e-25) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 2.6e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / 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 = 1.0d0 - (x ** (1.0d0 / n))
if (x <= 7.5d-227) then
tmp = t_0
else if (x <= 2.6d-208) then
tmp = log(x) * ((-1.0d0) / n)
else if (x <= 5.5d-173) then
tmp = t_0
else if (x <= 2.8d-38) then
tmp = -log(x) / n
else if (x <= 2.3d-25) then
tmp = t_0
else if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 2.6d+128) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
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 (x <= 7.5e-227) {
tmp = t_0;
} else if (x <= 2.6e-208) {
tmp = Math.log(x) * (-1.0 / n);
} else if (x <= 5.5e-173) {
tmp = t_0;
} else if (x <= 2.8e-38) {
tmp = -Math.log(x) / n;
} else if (x <= 2.3e-25) {
tmp = t_0;
} else if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 2.6e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): t_0 = 1.0 - math.pow(x, (1.0 / n)) tmp = 0 if x <= 7.5e-227: tmp = t_0 elif x <= 2.6e-208: tmp = math.log(x) * (-1.0 / n) elif x <= 5.5e-173: tmp = t_0 elif x <= 2.8e-38: tmp = -math.log(x) / n elif x <= 2.3e-25: tmp = t_0 elif x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 2.6e+128: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) tmp = 0.0 if (x <= 7.5e-227) tmp = t_0; elseif (x <= 2.6e-208) tmp = Float64(log(x) * Float64(-1.0 / n)); elseif (x <= 5.5e-173) tmp = t_0; elseif (x <= 2.8e-38) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 2.3e-25) tmp = t_0; elseif (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 2.6e+128) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) t_0 = 1.0 - (x ^ (1.0 / n)); tmp = 0.0; if (x <= 7.5e-227) tmp = t_0; elseif (x <= 2.6e-208) tmp = log(x) * (-1.0 / n); elseif (x <= 5.5e-173) tmp = t_0; elseif (x <= 2.8e-38) tmp = -log(x) / n; elseif (x <= 2.3e-25) tmp = t_0; elseif (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 2.6e+128) tmp = (1.0 / n) / x; else tmp = 0.0 / n; 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[x, 7.5e-227], t$95$0, If[LessEqual[x, 2.6e-208], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-173], t$95$0, If[LessEqual[x, 2.8e-38], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.3e-25], t$95$0, If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.6e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 7.5 \cdot 10^{-227}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-208}:\\
\;\;\;\;\log x \cdot \frac{-1}{n}\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-173}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.8 \cdot 10^{-38}:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{-25}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 7.49999999999999988e-227 or 2.60000000000000017e-208 < x < 5.50000000000000022e-173 or 2.8e-38 < x < 2.2999999999999999e-25Initial program 60.2%
Taylor expanded in x around 0 60.2%
if 7.49999999999999988e-227 < x < 2.60000000000000017e-208Initial program 21.7%
Taylor expanded in x around 0 21.7%
Taylor expanded in n around inf 77.0%
neg-mul-177.0%
distribute-neg-frac77.0%
Simplified77.0%
frac-2neg77.0%
div-inv77.2%
remove-double-neg77.2%
metadata-eval77.2%
associate-*l/77.2%
metadata-eval77.2%
frac-2neg77.2%
associate-*l/77.2%
metadata-eval77.2%
Applied egg-rr77.2%
if 5.50000000000000022e-173 < x < 2.8e-38Initial program 28.8%
Taylor expanded in x around 0 28.8%
Taylor expanded in n around inf 61.6%
neg-mul-161.6%
distribute-neg-frac61.6%
Simplified61.6%
if 2.2999999999999999e-25 < x < 1Initial program 43.5%
Taylor expanded in x around 0 44.0%
Taylor expanded in n around inf 62.7%
if 1 < x < 2.6e128Initial program 32.1%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
associate-/r*95.2%
div-inv95.0%
div-inv95.0%
pow-to-exp95.0%
pow195.0%
pow-div94.6%
Applied egg-rr94.6%
Taylor expanded in n around inf 72.8%
associate-/r*74.8%
Simplified74.8%
if 2.6e128 < x Initial program 83.2%
Taylor expanded in n around inf 83.3%
log1p-def83.3%
Simplified83.3%
log1p-udef83.3%
diff-log83.3%
+-commutative83.3%
Applied egg-rr83.3%
Taylor expanded in x around inf 83.3%
Final simplification69.1%
(FPCore (x n) :precision binary64 (if (<= x 1.0) (/ (- x (log x)) n) (if (<= x 3.8e+128) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - log(x)) / n;
} else if (x <= 3.8e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 1.0d0) then
tmp = (x - log(x)) / n
else if (x <= 3.8d+128) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x - Math.log(x)) / n;
} else if (x <= 3.8e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x - math.log(x)) / n elif x <= 3.8e+128: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x - log(x)) / n); elseif (x <= 3.8e+128) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 1.0) tmp = (x - log(x)) / n; elseif (x <= 3.8e+128) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.8e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x - \log x}{n}\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 1Initial program 45.3%
Taylor expanded in x around 0 45.5%
Taylor expanded in n around inf 51.1%
if 1 < x < 3.7999999999999999e128Initial program 32.1%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
associate-/r*95.2%
div-inv95.0%
div-inv95.0%
pow-to-exp95.0%
pow195.0%
pow-div94.6%
Applied egg-rr94.6%
Taylor expanded in n around inf 72.8%
associate-/r*74.8%
Simplified74.8%
if 3.7999999999999999e128 < x Initial program 83.2%
Taylor expanded in n around inf 83.3%
log1p-def83.3%
Simplified83.3%
log1p-udef83.3%
diff-log83.3%
+-commutative83.3%
Applied egg-rr83.3%
Taylor expanded in x around inf 83.3%
Final simplification62.3%
(FPCore (x n) :precision binary64 (if (<= x 0.55) (/ (- (log x)) n) (if (<= x 3.1e+128) (/ (/ 1.0 n) x) (/ 0.0 n))))
double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -log(x) / n;
} else if (x <= 3.1e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 0.55d0) then
tmp = -log(x) / n
else if (x <= 3.1d+128) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 0.55) {
tmp = -Math.log(x) / n;
} else if (x <= 3.1e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 0.55: tmp = -math.log(x) / n elif x <= 3.1e+128: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 0.55) tmp = Float64(Float64(-log(x)) / n); elseif (x <= 3.1e+128) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 0.55) tmp = -log(x) / n; elseif (x <= 3.1e+128) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 0.55], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 3.1e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.55:\\
\;\;\;\;\frac{-\log x}{n}\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 0.55000000000000004Initial program 45.3%
Taylor expanded in x around 0 45.3%
Taylor expanded in n around inf 51.1%
neg-mul-151.1%
distribute-neg-frac51.1%
Simplified51.1%
if 0.55000000000000004 < x < 3.10000000000000004e128Initial program 32.1%
Taylor expanded in x around inf 93.5%
mul-1-neg93.5%
log-rec93.5%
mul-1-neg93.5%
distribute-neg-frac93.5%
mul-1-neg93.5%
remove-double-neg93.5%
*-commutative93.5%
Simplified93.5%
associate-/r*95.2%
div-inv95.0%
div-inv95.0%
pow-to-exp95.0%
pow195.0%
pow-div94.6%
Applied egg-rr94.6%
Taylor expanded in n around inf 72.8%
associate-/r*74.8%
Simplified74.8%
if 3.10000000000000004e128 < x Initial program 83.2%
Taylor expanded in n around inf 83.3%
log1p-def83.3%
Simplified83.3%
log1p-udef83.3%
diff-log83.3%
+-commutative83.3%
Applied egg-rr83.3%
Taylor expanded in x around inf 83.3%
Final simplification62.3%
(FPCore (x n) :precision binary64 (if (<= x 2.8e+128) (/ (/ 1.0 n) x) (/ 0.0 n)))
double code(double x, double n) {
double tmp;
if (x <= 2.8e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if (x <= 2.8d+128) then
tmp = (1.0d0 / n) / x
else
tmp = 0.0d0 / n
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if (x <= 2.8e+128) {
tmp = (1.0 / n) / x;
} else {
tmp = 0.0 / n;
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 2.8e+128: tmp = (1.0 / n) / x else: tmp = 0.0 / n return tmp
function code(x, n) tmp = 0.0 if (x <= 2.8e+128) tmp = Float64(Float64(1.0 / n) / x); else tmp = Float64(0.0 / n); end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if (x <= 2.8e+128) tmp = (1.0 / n) / x; else tmp = 0.0 / n; end tmp_2 = tmp; end
code[x_, n_] := If[LessEqual[x, 2.8e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\
\end{array}
\end{array}
if x < 2.79999999999999983e128Initial program 42.8%
Taylor expanded in x around inf 43.6%
mul-1-neg43.6%
log-rec43.6%
mul-1-neg43.6%
distribute-neg-frac43.6%
mul-1-neg43.6%
remove-double-neg43.6%
*-commutative43.6%
Simplified43.6%
associate-/r*44.2%
div-inv44.2%
div-inv44.2%
pow-to-exp44.2%
pow144.2%
pow-div44.1%
Applied egg-rr44.1%
Taylor expanded in n around inf 34.7%
associate-/r*35.0%
Simplified35.0%
if 2.79999999999999983e128 < x Initial program 83.2%
Taylor expanded in n around inf 83.3%
log1p-def83.3%
Simplified83.3%
log1p-udef83.3%
diff-log83.3%
+-commutative83.3%
Applied egg-rr83.3%
Taylor expanded in x around inf 83.3%
Final simplification46.7%
(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 52.6%
Taylor expanded in n around inf 57.0%
log1p-def57.0%
Simplified57.0%
Taylor expanded in x around inf 41.4%
*-commutative41.4%
Simplified41.4%
Final simplification41.4%
(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 52.6%
Taylor expanded in x around inf 57.3%
mul-1-neg57.3%
log-rec57.3%
mul-1-neg57.3%
distribute-neg-frac57.3%
mul-1-neg57.3%
remove-double-neg57.3%
*-commutative57.3%
Simplified57.3%
associate-/r*57.7%
div-inv57.7%
div-inv57.7%
pow-to-exp57.7%
pow157.7%
pow-div57.6%
Applied egg-rr57.6%
Taylor expanded in n around inf 41.4%
associate-/r*41.6%
Simplified41.6%
Final simplification41.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 52.6%
Taylor expanded in x around 0 36.9%
Taylor expanded in n around inf 32.8%
Taylor expanded in x around inf 4.5%
Final simplification4.5%
herbie shell --seed 2024010
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))