
(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 12 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 (sqrt t_0)))
(if (<= (/ 1.0 n) -5e-11)
(* t_0 (/ 1.0 (* n x)))
(if (<= (/ 1.0 n) 2e-7)
(/ (log1p (/ 1.0 x)) n)
(fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double t_1 = sqrt(t_0);
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
}
return tmp;
}
function code(x, n) t_0 = x ^ Float64(1.0 / n) t_1 = sqrt(t_0) tmp = 0.0 if (Float64(1.0 / n) <= -5e-11) tmp = Float64(t_0 * Float64(1.0 / Float64(n * x))); elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(x) / n))); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \sqrt{t\_0}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t\_0 \cdot \frac{1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000018e-11Initial program 97.2%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
inv-pow100.0%
metadata-eval100.0%
pow-prod-up0.0%
exp-to-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
inv-pow100.0%
Applied egg-rr100.0%
if -5.00000000000000018e-11 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.3%
Taylor expanded in n around inf 76.3%
diff-log76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
expm1-undefine76.5%
add-exp-log76.5%
Applied egg-rr76.5%
*-lft-identity76.5%
associate-*l/75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
rgt-mult-inverse76.5%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in n around 0 76.5%
log1p-define98.7%
Simplified98.7%
if 1.9999999999999999e-7 < (/.f64 1 n) Initial program 42.8%
sub-neg42.8%
+-commutative42.8%
sqr-pow42.8%
distribute-rgt-neg-in42.8%
fma-define42.9%
sqrt-pow142.9%
sqrt-pow142.9%
pow-to-exp42.9%
un-div-inv42.9%
+-commutative42.9%
log1p-define94.6%
Applied egg-rr94.6%
Final simplification98.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-11)
(* t_0 (/ 1.0 (* n x)))
(if (<= (/ 1.0 n) 2e-7) (/ (log1p (/ 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) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = exp((x / n)) - t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = Math.log1p((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) <= -5e-11: tmp = t_0 * (1.0 / (n * x)) elif (1.0 / n) <= 2e-7: tmp = math.log1p((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) <= -5e-11) tmp = Float64(t_0 * Float64(1.0 / Float64(n * x))); elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(exp(Float64(x / n)) - t_0); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t\_0 \cdot \frac{1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000018e-11Initial program 97.2%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
inv-pow100.0%
metadata-eval100.0%
pow-prod-up0.0%
exp-to-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
inv-pow100.0%
Applied egg-rr100.0%
if -5.00000000000000018e-11 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.3%
Taylor expanded in n around inf 76.3%
diff-log76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
expm1-undefine76.5%
add-exp-log76.5%
Applied egg-rr76.5%
*-lft-identity76.5%
associate-*l/75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
rgt-mult-inverse76.5%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in n around 0 76.5%
log1p-define98.7%
Simplified98.7%
if 1.9999999999999999e-7 < (/.f64 1 n) Initial program 42.8%
Taylor expanded in n around 0 42.8%
log1p-define94.5%
Simplified94.5%
Taylor expanded in x around 0 94.5%
Final simplification98.4%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-11)
(* t_0 (/ 1.0 (* n x)))
(if (<= (/ 1.0 n) 2e-7)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+117)
(- (+ 1.0 (/ x n)) t_0)
(* 0.3333333333333333 (/ (pow x -3.0) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = (1.0 + (x / n)) - t_0;
} else {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-11: tmp = t_0 * (1.0 / (n * x)) elif (1.0 / n) <= 2e-7: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+117: tmp = (1.0 + (x / n)) - t_0 else: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-11) tmp = Float64(t_0 * Float64(1.0 / Float64(n * x))); elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+117) tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0); else tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+117], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $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^{-11}:\\
\;\;\;\;t\_0 \cdot \frac{1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+117}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000018e-11Initial program 97.2%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
inv-pow100.0%
metadata-eval100.0%
pow-prod-up0.0%
exp-to-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
inv-pow100.0%
Applied egg-rr100.0%
if -5.00000000000000018e-11 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.3%
Taylor expanded in n around inf 76.3%
diff-log76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
expm1-undefine76.5%
add-exp-log76.5%
Applied egg-rr76.5%
*-lft-identity76.5%
associate-*l/75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
rgt-mult-inverse76.5%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in n around 0 76.5%
log1p-define98.7%
Simplified98.7%
if 1.9999999999999999e-7 < (/.f64 1 n) < 4.99999999999999983e117Initial program 72.9%
Taylor expanded in x around 0 73.6%
if 4.99999999999999983e117 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 10.8%
Taylor expanded in x around inf 43.3%
sub-neg43.3%
+-commutative43.3%
associate-+l+43.3%
associate-*r/43.3%
metadata-eval43.3%
associate-*r/43.3%
metadata-eval43.3%
distribute-neg-frac43.3%
metadata-eval43.3%
Simplified43.3%
Taylor expanded in x around 0 81.9%
associate-/r*81.9%
Simplified81.9%
div-inv81.9%
div-inv81.9%
inv-pow81.9%
metadata-eval81.9%
pow-prod-up81.9%
metadata-eval81.9%
cube-div81.9%
pow381.9%
associate-*l*81.9%
pow-prod-up81.9%
metadata-eval81.9%
inv-pow81.9%
pow381.9%
inv-pow81.9%
pow-pow81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-*r/81.9%
*-commutative81.9%
*-lft-identity81.9%
Simplified81.9%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (* 0.3333333333333333 (/ (pow x -3.0) n))))
(if (<= (/ 1.0 n) -2e+22)
t_0
(if (<= (/ 1.0 n) 2e-7)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+117) (- 1.0 (pow x (/ 1.0 n))) t_0)))))
double code(double x, double n) {
double t_0 = 0.3333333333333333 * (pow(x, -3.0) / n);
double tmp;
if ((1.0 / n) <= -2e+22) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
double tmp;
if ((1.0 / n) <= -2e+22) {
tmp = t_0;
} else if ((1.0 / n) <= 2e-7) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - Math.pow(x, (1.0 / n));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = 0.3333333333333333 * (math.pow(x, -3.0) / n) tmp = 0 if (1.0 / n) <= -2e+22: tmp = t_0 elif (1.0 / n) <= 2e-7: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+117: tmp = 1.0 - math.pow(x, (1.0 / n)) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)) tmp = 0.0 if (Float64(1.0 / n) <= -2e+22) tmp = t_0; elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+117) tmp = Float64(1.0 - (x ^ Float64(1.0 / n))); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+22], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+117], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+117}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 1 n) < -2e22 or 4.99999999999999983e117 < (/.f64 1 n) Initial program 80.0%
Taylor expanded in n around inf 43.7%
Taylor expanded in x around inf 25.0%
sub-neg25.0%
+-commutative25.0%
associate-+l+25.0%
associate-*r/25.0%
metadata-eval25.0%
associate-*r/25.0%
metadata-eval25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 71.4%
associate-/r*71.4%
Simplified71.4%
div-inv71.4%
div-inv71.4%
inv-pow71.4%
metadata-eval71.4%
pow-prod-up19.8%
metadata-eval19.8%
cube-div19.8%
pow319.8%
associate-*l*19.8%
pow-prod-up71.4%
metadata-eval71.4%
inv-pow71.4%
pow371.4%
inv-pow71.4%
pow-pow71.4%
metadata-eval71.4%
Applied egg-rr71.4%
*-commutative71.4%
associate-*r/71.4%
*-commutative71.4%
*-lft-identity71.4%
Simplified71.4%
if -2e22 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.1%
Taylor expanded in n around inf 75.3%
diff-log75.5%
Applied egg-rr75.5%
log1p-expm1-u75.5%
expm1-undefine75.5%
add-exp-log75.5%
Applied egg-rr75.5%
*-lft-identity75.5%
associate-*l/74.2%
distribute-rgt-in74.2%
*-lft-identity74.2%
rgt-mult-inverse75.5%
associate--l+97.9%
metadata-eval97.9%
Simplified97.9%
Taylor expanded in n around 0 75.5%
log1p-define97.9%
Simplified97.9%
if 1.9999999999999999e-7 < (/.f64 1 n) < 4.99999999999999983e117Initial program 72.9%
Taylor expanded in x around 0 72.9%
Final simplification87.2%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-11)
(/ t_0 (* n x))
(if (<= (/ 1.0 n) 2e-7)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+117)
(- 1.0 t_0)
(* 0.3333333333333333 (/ (pow x -3.0) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 / (n * x);
} else if ((1.0 / n) <= 2e-7) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-11: tmp = t_0 / (n * x) elif (1.0 / n) <= 2e-7: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+117: tmp = 1.0 - t_0 else: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-11) tmp = Float64(t_0 / Float64(n * x)); elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+117) tmp = Float64(1.0 - t_0); else tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+117], N[(1.0 - t$95$0), $MachinePrecision], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $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^{-11}:\\
\;\;\;\;\frac{t\_0}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+117}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000018e-11Initial program 97.2%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-rgt-identity100.0%
associate-*r/100.0%
exp-to-pow100.0%
*-commutative100.0%
Simplified100.0%
if -5.00000000000000018e-11 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.3%
Taylor expanded in n around inf 76.3%
diff-log76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
expm1-undefine76.5%
add-exp-log76.5%
Applied egg-rr76.5%
*-lft-identity76.5%
associate-*l/75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
rgt-mult-inverse76.5%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in n around 0 76.5%
log1p-define98.7%
Simplified98.7%
if 1.9999999999999999e-7 < (/.f64 1 n) < 4.99999999999999983e117Initial program 72.9%
Taylor expanded in x around 0 72.9%
if 4.99999999999999983e117 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 10.8%
Taylor expanded in x around inf 43.3%
sub-neg43.3%
+-commutative43.3%
associate-+l+43.3%
associate-*r/43.3%
metadata-eval43.3%
associate-*r/43.3%
metadata-eval43.3%
distribute-neg-frac43.3%
metadata-eval43.3%
Simplified43.3%
Taylor expanded in x around 0 81.9%
associate-/r*81.9%
Simplified81.9%
div-inv81.9%
div-inv81.9%
inv-pow81.9%
metadata-eval81.9%
pow-prod-up81.9%
metadata-eval81.9%
cube-div81.9%
pow381.9%
associate-*l*81.9%
pow-prod-up81.9%
metadata-eval81.9%
inv-pow81.9%
pow381.9%
inv-pow81.9%
pow-pow81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-*r/81.9%
*-commutative81.9%
*-lft-identity81.9%
Simplified81.9%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (pow x (/ 1.0 n))))
(if (<= (/ 1.0 n) -5e-11)
(* t_0 (/ 1.0 (* n x)))
(if (<= (/ 1.0 n) 2e-7)
(/ (log1p (/ 1.0 x)) n)
(if (<= (/ 1.0 n) 5e+117)
(- 1.0 t_0)
(* 0.3333333333333333 (/ (pow x -3.0) n)))))))
double code(double x, double n) {
double t_0 = pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.pow(x, (1.0 / n));
double tmp;
if ((1.0 / n) <= -5e-11) {
tmp = t_0 * (1.0 / (n * x));
} else if ((1.0 / n) <= 2e-7) {
tmp = Math.log1p((1.0 / x)) / n;
} else if ((1.0 / n) <= 5e+117) {
tmp = 1.0 - t_0;
} else {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
}
return tmp;
}
def code(x, n): t_0 = math.pow(x, (1.0 / n)) tmp = 0 if (1.0 / n) <= -5e-11: tmp = t_0 * (1.0 / (n * x)) elif (1.0 / n) <= 2e-7: tmp = math.log1p((1.0 / x)) / n elif (1.0 / n) <= 5e+117: tmp = 1.0 - t_0 else: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) return tmp
function code(x, n) t_0 = x ^ Float64(1.0 / n) tmp = 0.0 if (Float64(1.0 / n) <= -5e-11) tmp = Float64(t_0 * Float64(1.0 / Float64(n * x))); elseif (Float64(1.0 / n) <= 2e-7) tmp = Float64(log1p(Float64(1.0 / x)) / n); elseif (Float64(1.0 / n) <= 5e+117) tmp = Float64(1.0 - t_0); else tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); end return tmp end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-11], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-7], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+117], N[(1.0 - t$95$0), $MachinePrecision], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $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^{-11}:\\
\;\;\;\;t\_0 \cdot \frac{1}{n \cdot x}\\
\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+117}:\\
\;\;\;\;1 - t\_0\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\end{array}
\end{array}
if (/.f64 1 n) < -5.00000000000000018e-11Initial program 97.2%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
log-rec100.0%
mul-1-neg100.0%
distribute-neg-frac100.0%
mul-1-neg100.0%
remove-double-neg100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
inv-pow100.0%
metadata-eval100.0%
pow-prod-up0.0%
exp-to-pow0.0%
pow-prod-up100.0%
metadata-eval100.0%
inv-pow100.0%
Applied egg-rr100.0%
if -5.00000000000000018e-11 < (/.f64 1 n) < 1.9999999999999999e-7Initial program 23.3%
Taylor expanded in n around inf 76.3%
diff-log76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
expm1-undefine76.5%
add-exp-log76.5%
Applied egg-rr76.5%
*-lft-identity76.5%
associate-*l/75.1%
distribute-rgt-in75.1%
*-lft-identity75.1%
rgt-mult-inverse76.5%
associate--l+98.7%
metadata-eval98.7%
Simplified98.7%
Taylor expanded in n around 0 76.5%
log1p-define98.7%
Simplified98.7%
if 1.9999999999999999e-7 < (/.f64 1 n) < 4.99999999999999983e117Initial program 72.9%
Taylor expanded in x around 0 72.9%
if 4.99999999999999983e117 < (/.f64 1 n) Initial program 17.1%
Taylor expanded in n around inf 10.8%
Taylor expanded in x around inf 43.3%
sub-neg43.3%
+-commutative43.3%
associate-+l+43.3%
associate-*r/43.3%
metadata-eval43.3%
associate-*r/43.3%
metadata-eval43.3%
distribute-neg-frac43.3%
metadata-eval43.3%
Simplified43.3%
Taylor expanded in x around 0 81.9%
associate-/r*81.9%
Simplified81.9%
div-inv81.9%
div-inv81.9%
inv-pow81.9%
metadata-eval81.9%
pow-prod-up81.9%
metadata-eval81.9%
cube-div81.9%
pow381.9%
associate-*l*81.9%
pow-prod-up81.9%
metadata-eval81.9%
inv-pow81.9%
pow381.9%
inv-pow81.9%
pow-pow81.9%
metadata-eval81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-*r/81.9%
*-commutative81.9%
*-lft-identity81.9%
Simplified81.9%
Final simplification95.9%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log1p (/ 1.0 x)) n)))
(if (<= n -6.4)
t_0
(if (<= n -3.5e-296) 0.0 (if (<= n 1.6e-122) (/ 1.0 (* n x)) t_0)))))
double code(double x, double n) {
double t_0 = log1p((1.0 / x)) / n;
double tmp;
if (n <= -6.4) {
tmp = t_0;
} else if (n <= -3.5e-296) {
tmp = 0.0;
} else if (n <= 1.6e-122) {
tmp = 1.0 / (n * x);
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double x, double n) {
double t_0 = Math.log1p((1.0 / x)) / n;
double tmp;
if (n <= -6.4) {
tmp = t_0;
} else if (n <= -3.5e-296) {
tmp = 0.0;
} else if (n <= 1.6e-122) {
tmp = 1.0 / (n * x);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, n): t_0 = math.log1p((1.0 / x)) / n tmp = 0 if n <= -6.4: tmp = t_0 elif n <= -3.5e-296: tmp = 0.0 elif n <= 1.6e-122: tmp = 1.0 / (n * x) else: tmp = t_0 return tmp
function code(x, n) t_0 = Float64(log1p(Float64(1.0 / x)) / n) tmp = 0.0 if (n <= -6.4) tmp = t_0; elseif (n <= -3.5e-296) tmp = 0.0; elseif (n <= 1.6e-122) tmp = Float64(1.0 / Float64(n * x)); else tmp = t_0; end return tmp end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -6.4], t$95$0, If[LessEqual[n, -3.5e-296], 0.0, If[LessEqual[n, 1.6e-122], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{if}\;n \leq -6.4:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -3.5 \cdot 10^{-296}:\\
\;\;\;\;0\\
\mathbf{elif}\;n \leq 1.6 \cdot 10^{-122}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -6.4000000000000004 or 1.6000000000000001e-122 < n Initial program 28.4%
Taylor expanded in n around inf 68.2%
diff-log68.4%
Applied egg-rr68.4%
log1p-expm1-u68.4%
expm1-undefine68.4%
add-exp-log68.4%
Applied egg-rr68.4%
*-lft-identity68.4%
associate-*l/67.2%
distribute-rgt-in67.2%
*-lft-identity67.2%
rgt-mult-inverse68.4%
associate--l+88.4%
metadata-eval88.4%
Simplified88.4%
Taylor expanded in n around 0 68.4%
log1p-define88.4%
Simplified88.4%
if -6.4000000000000004 < n < -3.4999999999999999e-296Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sqr-pow100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
sqrt-pow1100.0%
sqrt-pow1100.0%
pow-to-exp100.0%
un-div-inv100.0%
+-commutative100.0%
log1p-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 57.1%
distribute-rgt1-in57.1%
metadata-eval57.1%
mul0-lft57.8%
Simplified57.8%
if -3.4999999999999999e-296 < n < 1.6000000000000001e-122Initial program 27.4%
Taylor expanded in n around inf 10.9%
Taylor expanded in x around inf 64.8%
*-commutative64.8%
Simplified64.8%
Final simplification78.7%
(FPCore (x n)
:precision binary64
(let* ((t_0 (/ (log x) (- n))))
(if (<= x 1.45e-266)
t_0
(if (<= x 4.3e-245)
(/ 1.0 (* n x))
(if (<= x 0.16) t_0 (if (<= x 9.2e+183) (/ (/ 1.0 x) n) 0.0))))))
double code(double x, double n) {
double t_0 = log(x) / -n;
double tmp;
if (x <= 1.45e-266) {
tmp = t_0;
} else if (x <= 4.3e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 0.16) {
tmp = t_0;
} else if (x <= 9.2e+183) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: t_0
real(8) :: tmp
t_0 = log(x) / -n
if (x <= 1.45d-266) then
tmp = t_0
else if (x <= 4.3d-245) then
tmp = 1.0d0 / (n * x)
else if (x <= 0.16d0) then
tmp = t_0
else if (x <= 9.2d+183) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double t_0 = Math.log(x) / -n;
double tmp;
if (x <= 1.45e-266) {
tmp = t_0;
} else if (x <= 4.3e-245) {
tmp = 1.0 / (n * x);
} else if (x <= 0.16) {
tmp = t_0;
} else if (x <= 9.2e+183) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): t_0 = math.log(x) / -n tmp = 0 if x <= 1.45e-266: tmp = t_0 elif x <= 4.3e-245: tmp = 1.0 / (n * x) elif x <= 0.16: tmp = t_0 elif x <= 9.2e+183: tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) t_0 = Float64(log(x) / Float64(-n)) tmp = 0.0 if (x <= 1.45e-266) tmp = t_0; elseif (x <= 4.3e-245) tmp = Float64(1.0 / Float64(n * x)); elseif (x <= 0.16) tmp = t_0; elseif (x <= 9.2e+183) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) t_0 = log(x) / -n; tmp = 0.0; if (x <= 1.45e-266) tmp = t_0; elseif (x <= 4.3e-245) tmp = 1.0 / (n * x); elseif (x <= 0.16) tmp = t_0; elseif (x <= 9.2e+183) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 1.45e-266], t$95$0, If[LessEqual[x, 4.3e-245], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.16], t$95$0, If[LessEqual[x, 9.2e+183], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.45 \cdot 10^{-266}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.3 \cdot 10^{-245}:\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{elif}\;x \leq 0.16:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.2 \cdot 10^{+183}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.44999999999999998e-266 or 4.30000000000000003e-245 < x < 0.160000000000000003Initial program 32.8%
Taylor expanded in n around inf 60.1%
Taylor expanded in x around 0 59.1%
neg-mul-159.1%
Simplified59.1%
if 1.44999999999999998e-266 < x < 4.30000000000000003e-245Initial program 80.6%
Taylor expanded in n around inf 6.7%
Taylor expanded in x around inf 100.0%
*-commutative100.0%
Simplified100.0%
if 0.160000000000000003 < x < 9.1999999999999992e183Initial program 49.3%
Taylor expanded in n around inf 50.2%
Taylor expanded in x around inf 64.4%
if 9.1999999999999992e183 < x Initial program 83.2%
sub-neg83.2%
+-commutative83.2%
sqr-pow83.2%
distribute-rgt-neg-in83.2%
fma-define82.9%
sqrt-pow182.9%
sqrt-pow182.9%
pow-to-exp82.9%
un-div-inv82.9%
+-commutative82.9%
log1p-define82.9%
Applied egg-rr82.9%
Taylor expanded in x around inf 83.2%
distribute-rgt1-in83.2%
metadata-eval83.2%
mul0-lft83.2%
Simplified83.2%
Final simplification65.0%
(FPCore (x n) :precision binary64 (if (or (<= n -3.1) (not (<= n 2.6e-118))) (/ (log1p (/ 1.0 x)) n) (* 0.3333333333333333 (/ (pow x -3.0) n))))
double code(double x, double n) {
double tmp;
if ((n <= -3.1) || !(n <= 2.6e-118)) {
tmp = log1p((1.0 / x)) / n;
} else {
tmp = 0.3333333333333333 * (pow(x, -3.0) / n);
}
return tmp;
}
public static double code(double x, double n) {
double tmp;
if ((n <= -3.1) || !(n <= 2.6e-118)) {
tmp = Math.log1p((1.0 / x)) / n;
} else {
tmp = 0.3333333333333333 * (Math.pow(x, -3.0) / n);
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -3.1) or not (n <= 2.6e-118): tmp = math.log1p((1.0 / x)) / n else: tmp = 0.3333333333333333 * (math.pow(x, -3.0) / n) return tmp
function code(x, n) tmp = 0.0 if ((n <= -3.1) || !(n <= 2.6e-118)) tmp = Float64(log1p(Float64(1.0 / x)) / n); else tmp = Float64(0.3333333333333333 * Float64((x ^ -3.0) / n)); end return tmp end
code[x_, n_] := If[Or[LessEqual[n, -3.1], N[Not[LessEqual[n, 2.6e-118]], $MachinePrecision]], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(0.3333333333333333 * N[(N[Power[x, -3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.1 \lor \neg \left(n \leq 2.6 \cdot 10^{-118}\right):\\
\;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{{x}^{-3}}{n}\\
\end{array}
\end{array}
if n < -3.10000000000000009 or 2.6e-118 < n Initial program 28.4%
Taylor expanded in n around inf 68.2%
diff-log68.4%
Applied egg-rr68.4%
log1p-expm1-u68.4%
expm1-undefine68.4%
add-exp-log68.4%
Applied egg-rr68.4%
*-lft-identity68.4%
associate-*l/67.2%
distribute-rgt-in67.2%
*-lft-identity67.2%
rgt-mult-inverse68.4%
associate--l+88.4%
metadata-eval88.4%
Simplified88.4%
Taylor expanded in n around 0 68.4%
log1p-define88.4%
Simplified88.4%
if -3.10000000000000009 < n < 2.6e-118Initial program 80.0%
Taylor expanded in n around inf 43.7%
Taylor expanded in x around inf 25.0%
sub-neg25.0%
+-commutative25.0%
associate-+l+25.0%
associate-*r/25.0%
metadata-eval25.0%
associate-*r/25.0%
metadata-eval25.0%
distribute-neg-frac25.0%
metadata-eval25.0%
Simplified25.0%
Taylor expanded in x around 0 71.4%
associate-/r*71.4%
Simplified71.4%
div-inv71.4%
div-inv71.4%
inv-pow71.4%
metadata-eval71.4%
pow-prod-up19.8%
metadata-eval19.8%
cube-div19.8%
pow319.8%
associate-*l*19.8%
pow-prod-up71.4%
metadata-eval71.4%
inv-pow71.4%
pow371.4%
inv-pow71.4%
pow-pow71.4%
metadata-eval71.4%
Applied egg-rr71.4%
*-commutative71.4%
associate-*r/71.4%
*-commutative71.4%
*-lft-identity71.4%
Simplified71.4%
Final simplification82.6%
(FPCore (x n) :precision binary64 (if (or (<= n -12.5) (not (<= n -3.2e-295))) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -12.5) || !(n <= -3.2e-295)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-12.5d0)) .or. (.not. (n <= (-3.2d-295)))) then
tmp = 1.0d0 / (n * x)
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -12.5) || !(n <= -3.2e-295)) {
tmp = 1.0 / (n * x);
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -12.5) or not (n <= -3.2e-295): tmp = 1.0 / (n * x) else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -12.5) || !(n <= -3.2e-295)) tmp = Float64(1.0 / Float64(n * x)); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -12.5) || ~((n <= -3.2e-295))) tmp = 1.0 / (n * x); else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -12.5], N[Not[LessEqual[n, -3.2e-295]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -12.5 \lor \neg \left(n \leq -3.2 \cdot 10^{-295}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -12.5 or -3.2e-295 < n Initial program 28.3%
Taylor expanded in n around inf 61.1%
Taylor expanded in x around inf 44.2%
*-commutative44.2%
Simplified44.2%
if -12.5 < n < -3.2e-295Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sqr-pow100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
sqrt-pow1100.0%
sqrt-pow1100.0%
pow-to-exp100.0%
un-div-inv100.0%
+-commutative100.0%
log1p-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 57.1%
distribute-rgt1-in57.1%
metadata-eval57.1%
mul0-lft57.8%
Simplified57.8%
Final simplification47.6%
(FPCore (x n) :precision binary64 (if (or (<= n -1.9) (not (<= n -3.3e-295))) (/ (/ 1.0 x) n) 0.0))
double code(double x, double n) {
double tmp;
if ((n <= -1.9) || !(n <= -3.3e-295)) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
real(8) :: tmp
if ((n <= (-1.9d0)) .or. (.not. (n <= (-3.3d-295)))) then
tmp = (1.0d0 / x) / n
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double x, double n) {
double tmp;
if ((n <= -1.9) || !(n <= -3.3e-295)) {
tmp = (1.0 / x) / n;
} else {
tmp = 0.0;
}
return tmp;
}
def code(x, n): tmp = 0 if (n <= -1.9) or not (n <= -3.3e-295): tmp = (1.0 / x) / n else: tmp = 0.0 return tmp
function code(x, n) tmp = 0.0 if ((n <= -1.9) || !(n <= -3.3e-295)) tmp = Float64(Float64(1.0 / x) / n); else tmp = 0.0; end return tmp end
function tmp_2 = code(x, n) tmp = 0.0; if ((n <= -1.9) || ~((n <= -3.3e-295))) tmp = (1.0 / x) / n; else tmp = 0.0; end tmp_2 = tmp; end
code[x_, n_] := If[Or[LessEqual[n, -1.9], N[Not[LessEqual[n, -3.3e-295]], $MachinePrecision]], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.9 \lor \neg \left(n \leq -3.3 \cdot 10^{-295}\right):\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if n < -1.8999999999999999 or -3.2999999999999998e-295 < n Initial program 28.3%
Taylor expanded in n around inf 61.1%
Taylor expanded in x around inf 44.3%
if -1.8999999999999999 < n < -3.2999999999999998e-295Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
sqr-pow100.0%
distribute-rgt-neg-in100.0%
fma-define100.0%
sqrt-pow1100.0%
sqrt-pow1100.0%
pow-to-exp100.0%
un-div-inv100.0%
+-commutative100.0%
log1p-define100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 57.1%
distribute-rgt1-in57.1%
metadata-eval57.1%
mul0-lft57.8%
Simplified57.8%
Final simplification47.6%
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
return 0.0;
}
real(8) function code(x, n)
real(8), intent (in) :: x
real(8), intent (in) :: n
code = 0.0d0
end function
public static double code(double x, double n) {
return 0.0;
}
def code(x, n): return 0.0
function code(x, n) return 0.0 end
function tmp = code(x, n) tmp = 0.0; end
code[x_, n_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 45.9%
sub-neg45.9%
+-commutative45.9%
sqr-pow45.9%
distribute-rgt-neg-in45.9%
fma-define45.8%
sqrt-pow145.8%
sqrt-pow145.8%
pow-to-exp45.8%
un-div-inv45.8%
+-commutative45.8%
log1p-define53.7%
Applied egg-rr53.7%
Taylor expanded in x around inf 27.7%
distribute-rgt1-in27.7%
metadata-eval27.7%
mul0-lft27.9%
Simplified27.9%
Final simplification27.9%
herbie shell --seed 2024048
(FPCore (x n)
:name "2nthrt (problem 3.4.6)"
:precision binary64
(- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))