Re: SAGE question

1 view
Skip to first unread message

William Stein

unread,
Mar 8, 2012, 2:26:11 PM3/8/12
to Draza Miloshevich, uw-sage-2012
On Thu, Mar 8, 2012 at 11:20 AM, Draza Miloshevich <draza...@gmail.com> wrote:
> Hi William,
>
> I'm trying to compute the fourier series coefficients for f(x) = (1 + (x /
> |x|))*x^2  for x in [-.5,.5] using SAGE and I'm using the following code:
>
> f = lambda x:(1 + (x / abs(x)))*x^2
> f.fourier_series_cosine_coefficient(-.5,.5)
>
> but coming up with an error. What am I doing wrong?

You have to make a Piecewise function:

sage: f(x) = (1 + (x / abs(x)))*x^2
sage: g = Piecewise([( (-1/2,1/2), f) ])
sage: g.fourier_series_cosine_coefficient(-1/2,1/2)
(pi^2 - 8)/pi^3

>
> --
> Draza Miloshevich
> AS Navigation Assistant
> Disability Resource Center
> 303-618-8515

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Reply all
Reply to author
Forward
0 new messages