TruncateSum[sexpr,n]
truncates each Sum in sexpr to have at most n terms.
TruncateSum[sexpr,{m,n,…}]
truncates each multiple Sum in sexpr using the iterative specification {m,n,…}.
TruncateSum
TruncateSum[sexpr,n]
truncates each Sum in sexpr to have at most n terms.
TruncateSum[sexpr,{m,n,…}]
truncates each multiple Sum in sexpr using the iterative specification {m,n,…}.
Details and Options
- TruncateSum is typically used to truncate symbolic solutions involving infinite sums to finite sums, making it easy to numerically evaluate such approximations.
- The sum expression sexpr can have any combination of unevaluated and Inactive sums.
- TruncateSum will truncate large positive or negative summation limits according to the following:
-



, if 



, if 


- The following options can be given:
-
ActivateResult True whether to Activate the result WorkingPrecision Automatic the precision used in internal computations
Examples
open all close allBasic Examples (2)
Truncate an infinite sum to its first 12 terms:
TruncateSum[Sum[f[i], {i, 1, ∞}], 12]expr = Inactive[Sum][1 / x^i, {i, 1, ∞}]TruncateSum[expr, 5]Avoid activating the inactive sum:
TruncateSum[Inactive[Sum][x^(-i), {i, 1, Infinity}], 5, ActivateResult -> False]Activate[%]Scope (13)
Basic Uses (3)
Truncate an infinite sum to its first 10 terms:
expr = Sum[Sin[x^i], {i, 1, Infinity}]TruncateSum[expr, 10]Truncate an infinite sum to a sum with a symbolic upper limit:
expr = Inactive[Sum][Exp[-Sin[x]], {x, 1, Infinity}]TruncateSum[expr, m]For unevaluated sums, TruncateSum directly evaluates the truncated sum:
expr = Sum[Cos[i], {i, 3, Infinity}]TruncateSum[expr, 7]Finite Sums (3)
TruncateSum[Inactive[Sum][Tanh[x]^i, {i, 1, 1000}], 5]Truncate a sum with symbolic upper limit:
expr = Sum[Sin[x^i], {i, 1, n}]TruncateSum[expr, 10]Truncate a sum with symmetric upper and lower limits:
expr = Inactive[Sum][(-x)^n, {n, -100, 100}];TruncateSum[expr, 10, ActivateResult -> False]Infinite Sums (4)
expr = Sum[1 / n, {n, 1, Infinity}]TruncateSum[expr, 14]Truncate a sum with doubly infinite limits:
TruncateSum[Inactive[Sum][Sin[x^i], {i, -Infinity, Infinity}], 10, ActivateResult -> False]Activate[%]Truncate a sum with –∞ as its lower limit:
TruncateSum[Inactive[Sum][Cos[n + x], {n, -Infinity, 0}], 5]Truncate a polynomial with infinite sum coefficients:
pol = x^2 Inactive[Sum][Sin[i], {i, 1, Infinity}] + x Inactive[Sum][Cos[j], {j, 1, Infinity}] + Inactive[Sum][E^(-k), {k, 1, Infinity}];N[TruncateSum[pol, 4]]Multiple Sums (2)
Truncate a doubly infinite sum:
expr = Inactive[Sum][Sin[i*j], {i, 1, Infinity}, {j, 1, Infinity}];TruncateSum[expr, 5]Specify the maximum number of total terms for each sum:
TruncateSum[expr, {3, 4}]TruncateSum[expr, {4, All}]TruncateSum[expr, {All, 4}]dsum = Underoverscript[∑, i = 1, ∞]Underoverscript[∑, j = 1, 10](i^2 + j^3);TruncateSum[dsum, 5]Specify the maximum number of individual terms:
TruncateSum[dsum, {3, 4}]Inactive Sums (1)
For inactive sums, TruncateSum tries to evaluate the truncated sum:
expr = Inactive[Sum][i^2, {i, 1, Infinity}]TruncateSum[expr, n]Use ActivateResultFalse to avoid activating the inactive sum:
TruncateSum[expr, n, ActivateResult -> False]Activate[%]Options (2)
WorkingPrecision (1)
Applications (10)
Differential Equations (4)
Solve the Dirichlet problem for the wave equation on a finite interval:
weqn = D[u[x, t], {t, 2}] == D[u[x, t], {x, 2}];
ic = {u[x, 0] == x ^ 2(Pi - x), Derivative[0, 1][u][x, 0] == 0};
bc = {u[0, t] == 0, u[Pi, t] == 0};The solution is an infinite trigonometric series:
sol = DSolveValue[{weqn, ic, bc}, u[x, t], {x, t}]Extract the first three terms from the Inactive sum:
asol = TruncateSum[sol, 3]Plot3D[asol, {x, 0, Pi}, {t, 0, 4Pi}, ColorFunction -> Hue]Solve the Dirichlet problem for the wave equation in a rectangle:
weqn = D[u[x, y, t], {t, 2}] == Laplacian[u[x, y, t], {x, y}];ic = {u[x, y, 0] == (1 / 10)(x - x ^ 2)(2y - y ^ 2), Derivative[0, 0, 1][u][x, y, 0] == 0};bc = {u[x, 0, t] == 0,
u[0, y, t] == 0, u[1, y, t] == 0, u[x, 2, t] == 0};The solution is a doubly infinite trigonometric series:
(sol = FullSimplify[DSolveValue[{weqn, ic, bc}, u[x, y, t], {x, y, t}], K[1]∈Integers && K[3]∈Integers && K[1] ≥ 1 && K[3] ≥ 1])//TraditionalFormExtract a few terms from the Inactive sums:
h[x_, y_, t_] = TruncateSum[sol, 5]Animate[Plot3D[h[x, y, t], {x, 0, 1}, {y, 0, 2}, Ticks -> False, PlotRange -> {-1 / 36, 1 / 36}, MeshStyle -> Red, PerformanceGoal -> "Quality"], {t, 0, 8}, SaveDefinitions -> True, DefaultDuration -> 12, AnimationRepetitions -> 1]Solve the Dirichlet problem for the heat equation on a finite interval:
heqn = D[u[x, t], t] == D[u[x, t], {x, 2}];
ic = u[x, 0] == x(3 - x) ^ 2;
bc = {u[0, t] == 0, u[3, t] == 0};The solution is a Fourier sine series:
sol = DSolveValue[{heqn, ic, bc }, u[x, t], {x, t}]Truncate the Inactive sum:
asol = TruncateSum[sol, 3]Plot3D[asol//Evaluate, {x, 0, 3}, {t, 0, 3 / 2}, Exclusions -> None, PlotRange -> All]Solve the initial value problem for a Schrödinger equation with Dirichlet boundary conditions:
eqn = I D[ψ[x, t], t] == -2 D[ψ[x, t], {x, 2}];
f[x_] := -350 + 155 x - 22 x^2 + x^3
sol = DSolveValue[{eqn, ψ[5, t] == 0, ψ[10, t] == 0, ψ[x, 2] == f[x]}, ψ, {x, t}]Define a family of partial sums of the solution:
u[k_Integer] = TruncateSum[sol, k]For each k, uk satisfies the differential equation:
Table[eqn /. ψ -> u[k], {k, 4}]//SimplifyThe boundary conditions are also satisfied:
Table[{u[k][5, t] == 0, u[k][10, t] == 0}, {k, 4}]The initial condition is only satisfied for u∞, but there is rapid convergence at t==2:
Grid@Partition[Table[Plot[{u[k][x, 2], f[x]}, {x, 5, 10}, ImageSize -> 200], {k, 4}], 2]Difference Equations (1)
Asymptotics (3)
Compute the power series expansion of
around 0:
pse = Asymptotic[Sin[x], {x, 0, Infinity}]Obtain the first seven nonzero terms in the series:
TruncateSum[pse, 7]Compute the power series expansion of
around 1:
Asymptotic[E ^ x, {x, 1, Infinity}]Obtain the first five terms in the series:
TruncateSum[%, 5]Truncate the series for the Hypergeometric1F1 function:
h1f1[a_, b_, z_] = Inactive[Sum][(Pochhammer[a, i]z^i/Pochhammer[b, i]i!), {i, 0, Infinity}]f[a_, b_, z_, n_] = TruncateSum[h1f1[a, b, z], n + 1]Compare the results with the built-in Hypergeometric1F1 function:
Table[(Hypergeometric1F1[a, b, z] - f[a, b, z, n]) /. {a -> 1.1, b -> 1.2, z -> 2.3}, {n, 5, 20, 5}]Plot[{Hypergeometric1F1[-1.1, 2, z], f[-1.1, 2, z, 5], f[-1.1, 2, z, 10], f[-1.1, 2, z, 15]}, {z, 0, 17}, PlotLegends -> {"Exact", "n=5", "n=10", "n=15"}]Inverse Laplace Transform (2)
Calculate the inverse Laplace transform of a function:
ilt = InverseLaplaceTransform[1 / (s Sinh[3 s] Sinh[5 s]), s, t]Truncate the sum and plot the result:
Plot[TruncateSum[ilt, 45], {t, 0, 60}]The inverse Laplace transform of this function is a piecewise function:
ilt = InverseLaplaceTransform[((Exp[s] - 1) Sin[π / 5]) / (s (Exp[2 s] - 2 Exp[s] Cos[π / 5] + 1)), s, t]Plot[TruncateSum[ilt, 6], {t, 0, 15}]Properties & Relations (4)
TruncateSum[expr,n] truncates each sum in the expression to have at most n terms:
TruncateSum[Underoverscript[∑, i = 1, ∞]f[i] + Underoverscript[∑, j = 1, ∞]g[j], 4]TruncateSum truncates both limits of doubly infinite sums:
TruncateSum[Underoverscript[∑, i = -∞, ∞]f[i], 4]TruncateSum truncates only the lower limit of a sum from –∞ to a finite value:
TruncateSum[Underoverscript[∑, i = -∞, 0]f[i], 4]TruncateSum activates all inactive sums in the expression:
expr = Inactive[Sum][f[i], {i, 1, 100}]TruncateSum[expr, 5]ActivateResult False can be used to avoid activation:
TruncateSum[expr, 5, ActivateResult -> False]See Also
Sum Inactive DSolve Asymptotic RSolve InverseLaplaceTransform
Related Guides
History
Text
Wolfram Research (2024), TruncateSum, Wolfram Language function, https://reference.wolfram.com/language/ref/TruncateSum.html.
CMS
Wolfram Language. 2024. "TruncateSum." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TruncateSum.html.
APA
Wolfram Language. (2024). TruncateSum. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TruncateSum.html
BibTeX
@misc{reference.wolfram_2026_truncatesum, author="Wolfram Research", title="{TruncateSum}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/TruncateSum.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_truncatesum, organization={Wolfram Research}, title={TruncateSum}, year={2024}, url={https://reference.wolfram.com/language/ref/TruncateSum.html}, note=[Accessed: 13-June-2026]}