Subject: How to graph an expression involving sum?
From: Mario Rodriguez
Date: Fri, 09 Sep 2011 00:09:01 -0400
On 09/05/2011 04:08 PM, dlakelan wrote:
> I have a solution of a differential equation in terms of some fourier
> series. I would like to graph one of the spatially varying coefficients,
> so I tried something like:
>
> draw2d(explicit(subst(avals,coefseries),z,0,1));
>
> Where coefseries is something like a[0] + sum(a[i]*cos(...),i,1,17) and
> avals are the values for a[0]...a[17] in a list of the form
> [a[0]=...,a[1]=..., ...]
>
> but what the subst gives me is still in the form 1.234 +
> sum(a[i]*cos(...)...), that is, subst substituted the constant
> coefficient but of course not the individual coefficients in the sum
> (since they only appear as a[i]).
This is what I get:
(%i12) display2d:false$
(%i13) avals: makelist(a[i]=random(10)-5,i,0,17);
(%o13) [a[0] = -2,a[1] = -2,a[2] = 2,a[3] = 3,a[4] = -1,a[5] = 1,a[6] = 0,
a[7] = -5,a[8] = 2,a[9] = 1,a[10] = 0,a[11] = -1,a[12] =
2,a[13] = -3,
a[14] = 3,a[15] = -2,a[16] = -5,a[17] = 1]
(%i14) coefseries: a[0] + sum(a[i]*cos(z*i*%pi),i,1,17);
(%o14) a[17]*cos(17*%pi*z)+a[16]*cos(16*%pi*z)+a[15]*cos(15*%pi*z)
+a[14]*cos(14*%pi*z)+a[13]*cos(13*%pi*z)
+a[12]*cos(12*%pi*z)+a[11]*cos(11*%pi*z)
+a[10]*cos(10*%pi*z)+a[9]*cos(9*%pi*z)
+a[8]*cos(8*%pi*z)+a[7]*cos(7*%pi*z)
+a[6]*cos(6*%pi*z)+a[5]*cos(5*%pi*z)
+a[4]*cos(4*%pi*z)+a[3]*cos(3*%pi*z)
+a[2]*cos(2*%pi*z)+a[1]*cos(%pi*z)+a[0]
Don't you get this expanded expression? Perhaps I misunderstood your
problem.
--
Mario