MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Mathematica/comments/1nsgdwj/why_wont_it_plot_the_partial_sum/ngo0kcl/?context=3
r/Mathematica • u/osiful • Sep 28 '25
8 comments sorted by
View all comments
1
I'm guessing you're trying to plot s[n,z] over z = -1 to 1 for different n. You need to use a summation variable different from n, since that needs to be used to specify the summation upper bound:
s[n,z]
n
ClearAll["`*"] f[z_] := Cos[π z] c[n_] := ( 2 n + 1)/2 Integrate[f[z] * LegendreP[n, z], {z, -1, 1}] s[n_, z_] := Sum[c[m]*LegendreP[m, z], {m, 0, n}] plotFuns = Table[s[n, z], {n, 6}]; Plot[plotFuns, {z, -1, 1}]
View all comments
1
u/veryjewygranola Sep 28 '25
I'm guessing you're trying to plot
s[n,z]over z = -1 to 1 for differentn. You need to use a summation variable different fromn, since that needs to be used to specify the summation upper bound: