2
$\begingroup$

Why is Mathematica v12 spinning on this series:

FullSimplify[Sum[16^x/((16^x) + 4), {x, 1/2025, 2024/2025, 1/2025}]]

The answer works out to 1012. Is there another way to evaluate it? Thanks

$\endgroup$
7
  • 3
    $\begingroup$ it takes fraction of second on my PC. i.sstatic.net/kZluxdyb.png it is the simplification command which slows it. Not the Sum command. Sum[16^x/((16^x)+4),{x,1/2025,2024/2025,1/2025}]//N gives 1012. $\endgroup$
    – Nasser
    Commented Jun 30 at 2:01
  • $\begingroup$ Sum returns 2024 terms (it's just plugging it in), which is useless. It needs to evaluate it to the supposed result of 1012, which is why I added Simplify in $\endgroup$
    – Steve237
    Commented Jun 30 at 2:02
  • $\begingroup$ Strange! Why would we need to set //N for Numerical, If the answer is exact to begin with...Hmmm.... In other words if an answer works out to an integer, why would the result be 2024 terms if we not ask for //N $\endgroup$
    – Steve237
    Commented Jun 30 at 2:04
  • 2
    $\begingroup$ If you look at result of Sum it is huge. LeafCount is 34,915 and result of sum is complicated with numbers raised to different powers everywhere, and FullSimplification is known that it can slow things, because it tries many things. Even though everything is symbolic, it is still complicated result. Numerically it is always much much faster. i.sstatic.net/V0ufFrHt.png $\endgroup$
    – Nasser
    Commented Jun 30 at 2:08
  • 1
    $\begingroup$ After using N you can use Rationalize to get the exact result. $\endgroup$
    – Bob Hanlon
    Commented Jun 30 at 2:40

2 Answers 2

6
$\begingroup$

One problem is the combinatorial explosion of subexpressions to try to simplify in the straight sum. I love it when symmetry works:

Table[16^x/((16^x) + 4), {x, 1/2025, 2024/2025, 1/2025}] //
    # + Reverse[#] & //
   Simplify //
  Total //
 #/2 &

(*  1012  *)

Generalization:

Block[{n = 2024},
     Table[r^j/(r^((n + 1)/2) + r^j), {j, 1, n}]
     ] //
    # + Reverse[#] & //
   Simplify //
  Total //
 #/2 &

(*  1012  *)
$\endgroup$
3
  • $\begingroup$ Nice another clever solution! Thx $\endgroup$
    – Steve237
    Commented Jun 30 at 4:47
  • $\begingroup$ @MichaelE2 very Gauss like :) + 1 $\endgroup$
    – ubpdqn
    Commented Jun 30 at 7:16
  • 1
    $\begingroup$ @ubpdqn Exactly. See update. (Remove total to see just how like Gauss it is.) $\endgroup$
    – Michael E2
    Commented 2 days ago
4
$\begingroup$

Another fast symbolic solution:

F = Simplify[Sum[16^j/(4 + 16^j), {j, a, b, c}], 
Assumptions -> {a > 0, b > 0, c > 0}];
S = Simplify[F /. a -> 1/2025 /. b -> 2024/2025 /. c -> 1/2025]

(* -((2025 (QPolyGamma[0, (-2025 I \[Pi] - 2023 Log[4])/Log[16], 2^(
 4/2025)] - QPolyGamma[0, (-2025 I \[Pi] - 2023 Log[4] + 2024 Log[16])/
 Log[16], 2^(4/2025)]))/Log[16])*)
S // FunctionExpand (*Can't find simpler form*)

% // N // Chop
(* 1012. *)

Or:

Rationalize[Round[Sum[16^j/(4 + 16^j), {j, 1/2025, 2024/2025, c}] 
/. c -> 1/2025 // N // Chop, 0.1], 0] // AbsoluteTiming
(*{0.0649698, 1012}*)
$\endgroup$
6
  • 1
    $\begingroup$ I like these! s you're just evaluating the original Series and by adding restrictions, limiting the computations needed by the tool. $\endgroup$
    – Steve237
    Commented 2 days ago
  • 1
    $\begingroup$ (+1) I did a symbolic sum and got a QPolyGamma[] result similar to yours. I didn't like the somewhat small (or even not-so-small) imaginary round-off error after N[], which I didn't want to have to explain. It made it seem inferior to @Nasser's comment, although it's faster. So I moved on. Symbolic summation is still a good strategy to try. I was surprised that FullSimplify on it could not yield the integer 1012. $\endgroup$
    – Michael E2
    Commented 2 days ago
  • $\begingroup$ @MichaelE2. FullSimplify or FunctionExpand dosen't work here ,because in this case not exist function Identities for QPolyGamma[] to get simpler form,unless I'm wrong :P $\endgroup$ Commented 2 days ago
  • 1
    $\begingroup$ Interesting way to get sum: ClearAll[sum]; (sum[n_, wprec_ : 32] := Round[ NIntegrate[#, {K[1], -1/2, n - 1/2}, WorkingPrecision -> wprec, Method -> {"GaussKronrodRule", "Points" -> 5}], 10^(-wprec/2)]) &@ D[Sum[(16^(1/2024))^j/(4 + (16^(1/2024))^j), {j, K[1]}], K[1]]; sum[2024] $\endgroup$
    – Michael E2
    Commented yesterday
  • 1
    $\begingroup$ Reversing the order of the summation also works here:F1 = Simplify[Sum[16^j/(4 + 16^j), {j, a, b, c}] /. {a -> 1/2025, b -> 2024/2025, c -> 1/2025}]; F2 = Simplify[Sum[16^j/(4 + 16^j), {j, b, a, -c}] /. {a -> 1/2025, b -> 2024/2025, c -> 1/2025}]; (F1 + F2)/2 // FullSimplify $\endgroup$
    – Bob Hanlon
    Commented yesterday

Not the answer you're looking for? Browse other questions tagged or ask your own question.