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