
(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 (if (<= x 1.0) (- (/ x n) (expm1 (/ (log x) n))) (/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x / n) - expm1((log(x) / n));
} else {
tmp = pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if (x <= 1.0) {
tmp = (x / n) - Math.expm1((Math.log(x) / n));
} else {
tmp = Math.pow(x, (1.0 / n)) / (x * n);
}
return tmp;
}
def code(x, n): tmp = 0 if x <= 1.0: tmp = (x / n) - math.expm1((math.log(x) / n)) else: tmp = math.pow(x, (1.0 / n)) / (x * n) return tmp
function code(x, n) tmp = 0.0 if (x <= 1.0) tmp = Float64(Float64(x / n) - expm1(Float64(log(x) / n))); else tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n)); end return tmp end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x / n), $MachinePrecision] - N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{x}{n} - \mathsf{expm1}\left(\frac{\log x}{n}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\
\end{array}
\end{array}
if x < 1Initial program 49.1%
Taylor expanded in x around 0 49.0%
*-rgt-identity49.0%
associate-/l*49.0%
exp-to-pow49.0%
Simplified49.0%
Taylor expanded in x around 0 49.0%
associate--l+49.0%
*-rgt-identity49.0%
associate-*r/49.0%
exp-to-pow49.0%
+-commutative49.0%
associate-+l-49.3%
exp-to-pow49.3%
associate-*r/49.3%
*-rgt-identity49.3%
expm1-define93.6%
Simplified93.6%
if 1 < x Initial program 67.4%
Taylor expanded in x around inf 96.0%
log-rec96.0%
mul-1-neg96.0%
associate-*r/96.0%
neg-mul-196.0%
mul-1-neg96.0%
remove-double-neg96.0%
*-rgt-identity96.0%
associate-/l*96.0%
exp-to-pow96.0%
*-commutative96.0%
Simplified96.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -40000.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) -2e-75)
t_1
(if (<= (/ 1.0 n) -5e-90)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= (/ 1.0 n) 2e-6) t_1 (- (+ (+ (/ x n) 2.0) -1.0) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = (((x / n) + 2.0) + -1.0) - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-40000.0d0)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= (-2d-75)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-90)) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if ((1.0d0 / n) <= 2d-6) then
tmp = t_1
else
tmp = (((x / n) + 2.0d0) + (-1.0d0)) - 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(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = (((x / n) + 2.0) + -1.0) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -40000.0: tmp = t_0 / (x * n) elif (1.0 / n) <= -2e-75: tmp = t_1 elif (1.0 / n) <= -5e-90: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif (1.0 / n) <= 2e-6: tmp = t_1 else: tmp = (((x / n) + 2.0) + -1.0) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -40000.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= -2e-75) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-90) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (Float64(1.0 / n) <= 2e-6) tmp = t_1; else tmp = Float64(Float64(Float64(Float64(x / n) + 2.0) + -1.0) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -40000.0) tmp = t_0 / (x * n); elseif ((1.0 / n) <= -2e-75) tmp = t_1; elseif ((1.0 / n) <= -5e-90) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif ((1.0 / n) <= 2e-6) tmp = t_1; else tmp = (((x / n) + 2.0) + -1.0) - 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[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(N[(N[(N[(x / n), $MachinePrecision] + 2.0), $MachinePrecision] + -1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\frac{x}{n} + 2\right) + -1\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4e4Initial program 100.0%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 31.2%
Taylor expanded in n around inf 81.3%
log1p-define81.3%
Simplified81.3%
log1p-undefine81.3%
diff-log81.4%
Applied egg-rr81.4%
+-commutative81.4%
Simplified81.4%
if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90Initial program 4.6%
Taylor expanded in n around inf 25.2%
log1p-define25.2%
Simplified25.2%
Taylor expanded in x around -inf 89.1%
Taylor expanded in n around 0 88.7%
Simplified89.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 67.2%
Taylor expanded in x around 0 66.7%
*-rgt-identity66.7%
associate-/l*66.7%
exp-to-pow66.7%
Simplified66.7%
expm1-log1p-u66.7%
expm1-undefine66.7%
Applied egg-rr66.7%
sub-neg66.7%
log1p-undefine66.7%
rem-exp-log66.7%
associate-+r+66.8%
metadata-eval66.8%
metadata-eval66.8%
Simplified66.8%
Final simplification86.0%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -40000.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) -2e-75)
t_1
(if (<= (/ 1.0 n) -5e-90)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= (/ 1.0 n) 2e-6) t_1 (- (+ 1.0 (/ x n)) t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = (1.0 + (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) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-40000.0d0)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= (-2d-75)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-90)) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if ((1.0d0 / n) <= 2d-6) then
tmp = t_1
else
tmp = (1.0d0 + (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(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = (1.0 + (x / n)) - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -40000.0: tmp = t_0 / (x * n) elif (1.0 / n) <= -2e-75: tmp = t_1 elif (1.0 / n) <= -5e-90: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif (1.0 / n) <= 2e-6: tmp = t_1 else: tmp = (1.0 + (x / n)) - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -40000.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= -2e-75) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-90) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (Float64(1.0 / n) <= 2e-6) tmp = t_1; else tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -40000.0) tmp = t_0 / (x * n); elseif ((1.0 / n) <= -2e-75) tmp = t_1; elseif ((1.0 / n) <= -5e-90) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif ((1.0 / n) <= 2e-6) tmp = t_1; else tmp = (1.0 + (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[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(N[(1.0 + 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 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4e4Initial program 100.0%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 31.2%
Taylor expanded in n around inf 81.3%
log1p-define81.3%
Simplified81.3%
log1p-undefine81.3%
diff-log81.4%
Applied egg-rr81.4%
+-commutative81.4%
Simplified81.4%
if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90Initial program 4.6%
Taylor expanded in n around inf 25.2%
log1p-define25.2%
Simplified25.2%
Taylor expanded in x around -inf 89.1%
Taylor expanded in n around 0 88.7%
Simplified89.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 67.2%
Taylor expanded in x around 0 66.7%
*-rgt-identity66.7%
associate-/l*66.7%
exp-to-pow66.7%
Simplified66.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -40000.0)
(/ t_0 (* x n))
(if (<= (/ 1.0 n) -2e-75)
t_1
(if (<= (/ 1.0 n) -5e-90)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= (/ 1.0 n) 2e-6) t_1 (- 1.0 t_0)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x ** (1.0d0 / n)
t_1 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-40000.0d0)) then
tmp = t_0 / (x * n)
else if ((1.0d0 / n) <= (-2d-75)) then
tmp = t_1
else if ((1.0d0 / n) <= (-5d-90)) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if ((1.0d0 / n) <= 2d-6) then
tmp = t_1
else
tmp = 1.0d0 - 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(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = t_0 / (x * n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_1;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_1;
} else {
tmp = 1.0 - t_0;
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) t_1 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -40000.0: tmp = t_0 / (x * n) elif (1.0 / n) <= -2e-75: tmp = t_1 elif (1.0 / n) <= -5e-90: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif (1.0 / n) <= 2e-6: tmp = t_1 else: tmp = 1.0 - t_0 return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -40000.0) tmp = Float64(t_0 / Float64(x * n)); elseif (Float64(1.0 / n) <= -2e-75) tmp = t_1; elseif (Float64(1.0 / n) <= -5e-90) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (Float64(1.0 / n) <= 2e-6) tmp = t_1; else tmp = Float64(1.0 - t_0); end return tmp end
function tmp_2 = code(x, n) t_0 = x ^ (1.0 / n); t_1 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -40000.0) tmp = t_0 / (x * n); elseif ((1.0 / n) <= -2e-75) tmp = t_1; elseif ((1.0 / n) <= -5e-90) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif ((1.0 / n) <= 2e-6) tmp = t_1; else tmp = 1.0 - 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[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;1 - t\_0\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4e4Initial program 100.0%
Taylor expanded in x around inf 100.0%
log-rec100.0%
mul-1-neg100.0%
associate-*r/100.0%
neg-mul-1100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-rgt-identity100.0%
associate-/l*100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 31.2%
Taylor expanded in n around inf 81.3%
log1p-define81.3%
Simplified81.3%
log1p-undefine81.3%
diff-log81.4%
Applied egg-rr81.4%
+-commutative81.4%
Simplified81.4%
if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90Initial program 4.6%
Taylor expanded in n around inf 25.2%
log1p-define25.2%
Simplified25.2%
Taylor expanded in x around -inf 89.1%
Taylor expanded in n around 0 88.7%
Simplified89.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 67.2%
Taylor expanded in x around 0 63.9%
*-rgt-identity63.9%
associate-/l*63.8%
exp-to-pow63.9%
Simplified63.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log (/ (+ x 1.0) x)) n)))
(if (<= (/ 1.0 n) -40000.0)
(* (pow x -3.0) (/ 0.3333333333333333 n))
(if (<= (/ 1.0 n) -2e-75)
t_0
(if (<= (/ 1.0 n) -5e-90)
(/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
(if (<= (/ 1.0 n) 2e-6) t_0 (- 1.0 (pow x (/ 1.0 n)))))))))
double code(double x, double n) {
double t_0 = log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = pow(x, -3.0) * (0.3333333333333333 / n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_0;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_0;
} else {
tmp = 1.0 - pow(x, (1.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 = log(((x + 1.0d0) / x)) / n
if ((1.0d0 / n) <= (-40000.0d0)) then
tmp = (x ** (-3.0d0)) * (0.3333333333333333d0 / n)
else if ((1.0d0 / n) <= (-2d-75)) then
tmp = t_0
else if ((1.0d0 / n) <= (-5d-90)) then
tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
else if ((1.0d0 / n) <= 2d-6) then
tmp = t_0
else
tmp = 1.0d0 - (x ** (1.0d0 / n))
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(((x + 1.0) / x)) / n;
double tmp;
if ((1.0 / n) <= -40000.0) {
tmp = Math.pow(x, -3.0) * (0.3333333333333333 / n);
} else if ((1.0 / n) <= -2e-75) {
tmp = t_0;
} else if ((1.0 / n) <= -5e-90) {
tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
} else if ((1.0 / n) <= 2e-6) {
tmp = t_0;
} else {
tmp = 1.0 - Math.pow(x, (1.0 / n));
}
return tmp;
}
def code(x, n): t_0 = math.log(((x + 1.0) / x)) / n tmp = 0 if (1.0 / n) <= -40000.0: tmp = math.pow(x, -3.0) * (0.3333333333333333 / n) elif (1.0 / n) <= -2e-75: tmp = t_0 elif (1.0 / n) <= -5e-90: tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n elif (1.0 / n) <= 2e-6: tmp = t_0 else: tmp = 1.0 - math.pow(x, (1.0 / n)) return tmp
function code(x, n) t_0 = Float64(log(Float64(Float64(x + 1.0) / x)) / n) tmp = 0.0 if (Float64(1.0 / n) <= -40000.0) tmp = Float64((x ^ -3.0) * Float64(0.3333333333333333 / n)); elseif (Float64(1.0 / n) <= -2e-75) tmp = t_0; elseif (Float64(1.0 / n) <= -5e-90) tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n); elseif (Float64(1.0 / n) <= 2e-6) tmp = t_0; else tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); end return tmp end
function tmp_2 = code(x, n) t_0 = log(((x + 1.0) / x)) / n; tmp = 0.0; if ((1.0 / n) <= -40000.0) tmp = (x ^ -3.0) * (0.3333333333333333 / n); elseif ((1.0 / n) <= -2e-75) tmp = t_0; elseif ((1.0 / n) <= -5e-90) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; elseif ((1.0 / n) <= 2e-6) tmp = t_0; else tmp = 1.0 - (x ^ (1.0 / n)); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(N[Power[x, -3.0], $MachinePrecision] * N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$0, N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\
\;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\end{array}
\end{array}
if (/.f64 #s(literal 1 binary64) n) < -4e4Initial program 100.0%
Taylor expanded in n around inf 42.4%
log1p-define42.4%
Simplified42.4%
Taylor expanded in x around -inf 55.5%
Taylor expanded in x around 0 79.1%
associate-/r*79.1%
Simplified79.1%
clear-num79.1%
associate-/r/79.1%
pow-flip79.1%
metadata-eval79.1%
Applied egg-rr79.1%
if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6Initial program 31.2%
Taylor expanded in n around inf 81.3%
log1p-define81.3%
Simplified81.3%
log1p-undefine81.3%
diff-log81.4%
Applied egg-rr81.4%
+-commutative81.4%
Simplified81.4%
if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90Initial program 4.6%
Taylor expanded in n around inf 25.2%
log1p-define25.2%
Simplified25.2%
Taylor expanded in x around -inf 89.1%
Taylor expanded in n around 0 88.7%
Simplified89.1%
if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) Initial program 67.2%
Taylor expanded in x around 0 63.9%
*-rgt-identity63.9%
associate-/l*63.8%
exp-to-pow63.9%
Simplified63.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log x) (- n))))
(if (<= x 4.7e-287)
t_0
(if (<= x 2e-224)
t_1
(if (<= x 2.7e-189)
t_0
(if (<= x 4.9e-36)
t_1
(if (<= x 3.1e+127)
(/ (+ (/ 1.0 x) (/ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) x)) n)
(* (pow x -3.0) (/ 0.3333333333333333 n)))))))))
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.7e-287) {
tmp = t_0;
} else if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 2.7e-189) {
tmp = t_0;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else if (x <= 3.1e+127) {
tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
} else {
tmp = pow(x, -3.0) * (0.3333333333333333 / 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x ** (1.0d0 / n))
t_1 = log(x) / -n
if (x <= 4.7d-287) then
tmp = t_0
else if (x <= 2d-224) then
tmp = t_1
else if (x <= 2.7d-189) then
tmp = t_0
else if (x <= 4.9d-36) then
tmp = t_1
else if (x <= 3.1d+127) then
tmp = ((1.0d0 / x) + ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) / x)) / n
else
tmp = (x ** (-3.0d0)) * (0.3333333333333333d0 / 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 t_1 = Math.log(x) / -n;
double tmp;
if (x <= 4.7e-287) {
tmp = t_0;
} else if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 2.7e-189) {
tmp = t_0;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else if (x <= 3.1e+127) {
tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
} else {
tmp = Math.pow(x, -3.0) * (0.3333333333333333 / n);
}
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.7e-287: tmp = t_0 elif x <= 2e-224: tmp = t_1 elif x <= 2.7e-189: tmp = t_0 elif x <= 4.9e-36: tmp = t_1 elif x <= 3.1e+127: tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n else: tmp = math.pow(x, -3.0) * (0.3333333333333333 / n) return tmp
function code(x, n) t_0 = Float64(1.0 - (x ^ Float64(1.0 / n))) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 4.7e-287) tmp = t_0; elseif (x <= 2e-224) tmp = t_1; elseif (x <= 2.7e-189) tmp = t_0; elseif (x <= 4.9e-36) tmp = t_1; elseif (x <= 3.1e+127) tmp = Float64(Float64(Float64(1.0 / x) + Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) / x)) / n); else tmp = Float64((x ^ -3.0) * Float64(0.3333333333333333 / n)); 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.7e-287) tmp = t_0; elseif (x <= 2e-224) tmp = t_1; elseif (x <= 2.7e-189) tmp = t_0; elseif (x <= 4.9e-36) tmp = t_1; elseif (x <= 3.1e+127) tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n; else tmp = (x ^ -3.0) * (0.3333333333333333 / 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]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 4.7e-287], t$95$0, If[LessEqual[x, 2e-224], t$95$1, If[LessEqual[x, 2.7e-189], t$95$0, If[LessEqual[x, 4.9e-36], t$95$1, If[LessEqual[x, 3.1e+127], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, -3.0], $MachinePrecision] * N[(0.3333333333333333 / n), $MachinePrecision]), $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.7 \cdot 10^{-287}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+127}:\\
\;\;\;\;\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\
\end{array}
\end{array}
if x < 4.6999999999999999e-287 or 2e-224 < x < 2.6999999999999999e-189Initial program 72.4%
Taylor expanded in x around 0 72.4%
*-rgt-identity72.4%
associate-/l*72.4%
exp-to-pow72.4%
Simplified72.4%
if 4.6999999999999999e-287 < x < 2e-224 or 2.6999999999999999e-189 < x < 4.8999999999999997e-36Initial program 41.6%
Taylor expanded in x around 0 41.6%
*-rgt-identity41.6%
associate-/l*41.6%
exp-to-pow41.6%
Simplified41.6%
Taylor expanded in n around inf 58.1%
neg-mul-158.1%
distribute-neg-frac58.1%
Simplified58.1%
if 4.8999999999999997e-36 < x < 3.1000000000000002e127Initial program 50.3%
Taylor expanded in n around inf 44.7%
log1p-define44.7%
Simplified44.7%
Taylor expanded in x around -inf 64.8%
div-sub64.8%
mul-1-neg64.8%
sub-neg64.8%
un-div-inv64.8%
metadata-eval64.8%
Applied egg-rr64.8%
if 3.1000000000000002e127 < x Initial program 89.1%
Taylor expanded in n around inf 89.1%
log1p-define89.1%
Simplified89.1%
Taylor expanded in x around -inf 67.2%
Taylor expanded in x around 0 89.1%
associate-/r*89.1%
Simplified89.1%
clear-num89.1%
associate-/r/89.1%
pow-flip89.1%
metadata-eval89.1%
Applied egg-rr89.1%
Final simplification67.3%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (t_1 (/ (log x) (- n))))
(if (<= x 2e-224)
t_1
(if (<= x 6.4e-189)
(/ (/ (+ 1.0 t_0) x) n)
(if (<= x 4.9e-36)
t_1
(if (<= x 1.9e+128)
(/ (+ (/ 1.0 x) (/ t_0 x)) n)
(* (pow x -3.0) (/ 0.3333333333333333 n))))))))
double code(double x, double n) {
double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
double t_1 = log(x) / -n;
double tmp;
if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 6.4e-189) {
tmp = ((1.0 + t_0) / x) / n;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else if (x <= 1.9e+128) {
tmp = ((1.0 / x) + (t_0 / x)) / n;
} else {
tmp = pow(x, -3.0) * (0.3333333333333333 / 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) :: t_1
real(8) :: tmp
t_0 = ((-0.5d0) + (0.3333333333333333d0 / x)) / x
t_1 = log(x) / -n
if (x <= 2d-224) then
tmp = t_1
else if (x <= 6.4d-189) then
tmp = ((1.0d0 + t_0) / x) / n
else if (x <= 4.9d-36) then
tmp = t_1
else if (x <= 1.9d+128) then
tmp = ((1.0d0 / x) + (t_0 / x)) / n
else
tmp = (x ** (-3.0d0)) * (0.3333333333333333d0 / n)
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
double t_1 = Math.log(x) / -n;
double tmp;
if (x <= 2e-224) {
tmp = t_1;
} else if (x <= 6.4e-189) {
tmp = ((1.0 + t_0) / x) / n;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else if (x <= 1.9e+128) {
tmp = ((1.0 / x) + (t_0 / x)) / n;
} else {
tmp = Math.pow(x, -3.0) * (0.3333333333333333 / n);
}
return tmp;
}
def code(x, n): t_0 = (-0.5 + (0.3333333333333333 / x)) / x t_1 = math.log(x) / -n tmp = 0 if x <= 2e-224: tmp = t_1 elif x <= 6.4e-189: tmp = ((1.0 + t_0) / x) / n elif x <= 4.9e-36: tmp = t_1 elif x <= 1.9e+128: tmp = ((1.0 / x) + (t_0 / x)) / n else: tmp = math.pow(x, -3.0) * (0.3333333333333333 / n) return tmp
function code(x, n) t_0 = Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 2e-224) tmp = t_1; elseif (x <= 6.4e-189) tmp = Float64(Float64(Float64(1.0 + t_0) / x) / n); elseif (x <= 4.9e-36) tmp = t_1; elseif (x <= 1.9e+128) tmp = Float64(Float64(Float64(1.0 / x) + Float64(t_0 / x)) / n); else tmp = Float64((x ^ -3.0) * Float64(0.3333333333333333 / n)); end return tmp end
function tmp_2 = code(x, n) t_0 = (-0.5 + (0.3333333333333333 / x)) / x; t_1 = log(x) / -n; tmp = 0.0; if (x <= 2e-224) tmp = t_1; elseif (x <= 6.4e-189) tmp = ((1.0 + t_0) / x) / n; elseif (x <= 4.9e-36) tmp = t_1; elseif (x <= 1.9e+128) tmp = ((1.0 / x) + (t_0 / x)) / n; else tmp = (x ^ -3.0) * (0.3333333333333333 / n); end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 2e-224], t$95$1, If[LessEqual[x, 6.4e-189], N[(N[(N[(1.0 + t$95$0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.9e-36], t$95$1, If[LessEqual[x, 1.9e+128], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, -3.0], $MachinePrecision] * N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-189}:\\
\;\;\;\;\frac{\frac{1 + t\_0}{x}}{n}\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{x} + \frac{t\_0}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\
\end{array}
\end{array}
if x < 2e-224 or 6.4000000000000001e-189 < x < 4.8999999999999997e-36Initial program 44.6%
Taylor expanded in x around 0 44.6%
*-rgt-identity44.6%
associate-/l*44.6%
exp-to-pow44.6%
Simplified44.6%
Taylor expanded in n around inf 56.0%
neg-mul-156.0%
distribute-neg-frac56.0%
Simplified56.0%
if 2e-224 < x < 6.4000000000000001e-189Initial program 74.8%
Taylor expanded in n around inf 31.4%
log1p-define31.4%
Simplified31.4%
Taylor expanded in x around -inf 67.4%
Taylor expanded in n around 0 67.4%
Simplified67.4%
if 4.8999999999999997e-36 < x < 1.89999999999999995e128Initial program 50.3%
Taylor expanded in n around inf 44.7%
log1p-define44.7%
Simplified44.7%
Taylor expanded in x around -inf 64.8%
div-sub64.8%
mul-1-neg64.8%
sub-neg64.8%
un-div-inv64.8%
metadata-eval64.8%
Applied egg-rr64.8%
if 1.89999999999999995e128 < x Initial program 89.1%
Taylor expanded in n around inf 89.1%
log1p-define89.1%
Simplified89.1%
Taylor expanded in x around -inf 67.2%
Taylor expanded in x around 0 89.1%
associate-/r*89.1%
Simplified89.1%
clear-num89.1%
associate-/r/89.1%
pow-flip89.1%
metadata-eval89.1%
Applied egg-rr89.1%
Final simplification65.1%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (t_1 (/ (log x) (- n))))
(if (<= x 1.6e-224)
t_1
(if (<= x 1.1e-188)
(/ (/ (+ 1.0 t_0) x) n)
(if (<= x 4.9e-36) t_1 (/ (+ (/ 1.0 x) (/ t_0 x)) n))))))
double code(double x, double n) {
double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
double t_1 = log(x) / -n;
double tmp;
if (x <= 1.6e-224) {
tmp = t_1;
} else if (x <= 1.1e-188) {
tmp = ((1.0 + t_0) / x) / n;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else {
tmp = ((1.0 / x) + (t_0 / x)) / n;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((-0.5d0) + (0.3333333333333333d0 / x)) / x
t_1 = log(x) / -n
if (x <= 1.6d-224) then
tmp = t_1
else if (x <= 1.1d-188) then
tmp = ((1.0d0 + t_0) / x) / n
else if (x <= 4.9d-36) then
tmp = t_1
else
tmp = ((1.0d0 / x) + (t_0 / x)) / n
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
double t_1 = Math.log(x) / -n;
double tmp;
if (x <= 1.6e-224) {
tmp = t_1;
} else if (x <= 1.1e-188) {
tmp = ((1.0 + t_0) / x) / n;
} else if (x <= 4.9e-36) {
tmp = t_1;
} else {
tmp = ((1.0 / x) + (t_0 / x)) / n;
}
return tmp;
}
def code(x, n): t_0 = (-0.5 + (0.3333333333333333 / x)) / x t_1 = math.log(x) / -n tmp = 0 if x <= 1.6e-224: tmp = t_1 elif x <= 1.1e-188: tmp = ((1.0 + t_0) / x) / n elif x <= 4.9e-36: tmp = t_1 else: tmp = ((1.0 / x) + (t_0 / x)) / n return tmp
function code(x, n) t_0 = Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) t_1 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.6e-224) tmp = t_1; elseif (x <= 1.1e-188) tmp = Float64(Float64(Float64(1.0 + t_0) / x) / n); elseif (x <= 4.9e-36) tmp = t_1; else tmp = Float64(Float64(Float64(1.0 / x) + Float64(t_0 / x)) / n); end return tmp end
function tmp_2 = code(x, n) t_0 = (-0.5 + (0.3333333333333333 / x)) / x; t_1 = log(x) / -n; tmp = 0.0; if (x <= 1.6e-224) tmp = t_1; elseif (x <= 1.1e-188) tmp = ((1.0 + t_0) / x) / n; elseif (x <= 4.9e-36) tmp = t_1; else tmp = ((1.0 / x) + (t_0 / x)) / n; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.6e-224], t$95$1, If[LessEqual[x, 1.1e-188], N[(N[(N[(1.0 + t$95$0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 4.9e-36], t$95$1, N[(N[(N[(1.0 / x), $MachinePrecision] + N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.6 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-188}:\\
\;\;\;\;\frac{\frac{1 + t\_0}{x}}{n}\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} + \frac{t\_0}{x}}{n}\\
\end{array}
\end{array}
if x < 1.5999999999999999e-224 or 1.1e-188 < x < 4.8999999999999997e-36Initial program 44.6%
Taylor expanded in x around 0 44.6%
*-rgt-identity44.6%
associate-/l*44.6%
exp-to-pow44.6%
Simplified44.6%
Taylor expanded in n around inf 56.0%
neg-mul-156.0%
distribute-neg-frac56.0%
Simplified56.0%
if 1.5999999999999999e-224 < x < 1.1e-188Initial program 74.8%
Taylor expanded in n around inf 31.4%
log1p-define31.4%
Simplified31.4%
Taylor expanded in x around -inf 67.4%
Taylor expanded in n around 0 67.4%
Simplified67.4%
if 4.8999999999999997e-36 < x Initial program 68.3%
Taylor expanded in n around inf 65.2%
log1p-define65.2%
Simplified65.2%
Taylor expanded in x around -inf 65.9%
div-sub65.9%
mul-1-neg65.9%
sub-neg65.9%
un-div-inv65.9%
metadata-eval65.9%
Applied egg-rr65.9%
Final simplification60.8%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* x n)) (/ -0.5 n)) x)) x))
double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) + ((-0.5d0) / n)) / x)) / x
end function
public static double code(double x, double n) {
return ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x;
}
def code(x, n): return ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x
function code(x, n) return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x) end
function tmp = code(x, n) tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) + (-0.5 / n)) / x)) / x; end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}
\end{array}
Initial program 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 47.8%
mul-1-neg47.8%
distribute-neg-frac247.8%
Simplified47.8%
Final simplification47.8%
(FPCore (x n) :precision binary64 (/ (+ (/ 1.0 x) (/ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) x)) n))
double code(double x, double n) {
return ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 / x) + ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) / x)) / n
end function
public static double code(double x, double n) {
return ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
}
def code(x, n): return ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n
function code(x, n) return Float64(Float64(Float64(1.0 / x) + Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) / x)) / n) end
function tmp = code(x, n) tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n; end
code[x_, n_] := N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 47.8%
div-sub47.8%
mul-1-neg47.8%
sub-neg47.8%
un-div-inv47.8%
metadata-eval47.8%
Applied egg-rr47.8%
Final simplification47.8%
(FPCore (x n) :precision binary64 (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n))
double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
end function
public static double code(double x, double n) {
return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
}
def code(x, n): return ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
function code(x, n) return Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n) end
function tmp = code(x, n) tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n; end
code[x_, n_] := N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Initial program 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around -inf 47.8%
Taylor expanded in n around 0 47.3%
Simplified47.8%
(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 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around inf 41.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(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 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around inf 26.9%
sub-neg26.9%
associate-*r/26.9%
metadata-eval26.9%
distribute-neg-frac26.9%
metadata-eval26.9%
*-commutative26.9%
Simplified26.9%
Taylor expanded in x around inf 41.7%
(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(1.0 / Float64(x * n)) end
function tmp = code(x, n) tmp = 1.0 / (x * n); end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{x \cdot n}
\end{array}
Initial program 56.4%
Taylor expanded in n around inf 58.5%
log1p-define58.5%
Simplified58.5%
Taylor expanded in x around inf 41.2%
*-commutative41.2%
Simplified41.2%
(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 56.4%
Taylor expanded in x around 0 37.0%
*-rgt-identity37.0%
associate-/l*37.0%
exp-to-pow37.0%
Simplified37.0%
Taylor expanded in x around inf 4.5%
herbie shell --seed 2024096
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))