Subject: How to graph an expression involving sum?
From: Robert Dodier
Date: Fri, 9 Sep 2011 23:17:04 -0600
On 9/5/11, dlakelan <dlakelan at street-artists.org> 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]).
>
> What's the right way to go about graphing something like this?
After thinking about this for a bit, the only way I can see
to make it work is to bind the values a[0], a[1], etc so that
evaluation pulls them into the sum. I.e. you need a[i]:whatever
instead of a[i]=whatever. Then you don't need any special
evaluation of coefseries; plot2d(coefseries, [z, 0, 1]) has the
expected effect, probably draw as well.
If it's important to avoid collisions (multiple uses of the symbol a
or something like that) probably one could play games with
gensym or something like that.
Incidentally it would help others understand the problem if you
just paste in whatever non-working code you have.
best
Robert Dodier