-------------------------------------------------------------
Maxima version: "5.45.1"
Maxima build date: "2021-12-06 23:50:08"
Host type: "x86_64-pc-linux-gnu"
Lisp implementation type: "GNU Common Lisp (GCL)"
Lisp implementation version: "GCL 2.6.12"
User dir: "/home/devingreene/.maxima"
Temp dir: "/tmp"
Object dir: "/home/devingreene/.maxima/binary/5_45_1/gcl/GCL_2_6_12"
Frontend: false
-------------------------------------------------------------
The integral over the interval [-pi,pi] of cos(n*x), where n is an integer is zero when n != 0 and 2*pi otherwise. However:
(%i1) declare(n,integer)$
(%i2) integrate(cos(n*x),x,-%pi,%pi); /* This should give a case prompt regarding n. */
(%o2) 0
I don't know the internals of the fourie package, but consider this:
(%i3) load(fourie)$
(%i4) fourier(cos(x),x,%pi); /* Incorrect a_1 */
(%t4) a = 0
0
(%t5) a = 0
n
(%t6) b = 0
n
(%o6) [%t4, %t5, %t6]
Obviously a_1 should be 1, not 0. I believe that the integration problem mentioned above is what is causing this.
I think this has been suggested before: make the antiderivative of
costo be(x -> x sinc(x)). Doing so givesBoosting up the
sincsimp code to recognize thatsinc(integer x %pi) = 0is easy to do.Switching to a
sincantiderivative might be OK if it were localized to the definite integral code, but doing this in general would almost surely cause problems with users and problems with vanishing expressions that don't simplify to zero.Last edit: Barton Willis 2026-01-17
Dear Devin Greene,
In case you are interested, our package pdefourier solves this problem and many other potential problems when the input contains trigonometric expressions or a product of a polynomial and a trigonometric expression
https://github.com/emmanuelroque/pdefourier
I hope you find it helpful.
There is also an arxiv preprint where we explain why even Mathematica has many issues regarding Fourier series.
https://arxiv.org/abs/2004.02604
Best,
Emmanuel
Last edit: Robert Dodier 2026-02-05
Possibility: Define
And at the top-level of
defint, set*in-defint*to true. Doing so, I get:Here is a stand alone workaround for this bug:
Example: