On 2014-11-16, Nijso Beishuizen nijso@hotmail.com wrote:
code:
h(theta):=1+3*sin(theta);
A(n):=1/(%pi*a^n)*integrate(h(phi)*cos(n*phi),phi,0,2*%pi);
B(n):=1/(%pi*a^n)*integrate(h(phi)*sin(n*phi),phi,0,2*%pi);
u(r,theta):=1/2 * A(0) +
sum(r^n*(A(n)*cos(n*theta)+B(n)*sin(n*theta)),n,1,inf);
However,
(%i) u(R,Theta)
(%o) 1
Why is that?
Problem is that integrate(h(phi)*cos(n*phi),phi,0,2*%pi)
returns an expression which is not valid for n=1 (as it contains a factor 1/(n^3 - n). Likewise for integrate(h(phi)*sin(n*phi),phi,0,2*%pi)
. The expressions returned simplify to 0 when n is assumed to be an integer (as in the summation code) and therefore sum(...) contributes 0 to u(r, theta)
and the only nonzero bit is A(0)/2.
Integrals involving orthogonal functions often must be described by cases, but I don't think Maxima can do that. The machinery is there -- it just has to return something like "if special_case(n) then special_result else general_result" -- so it's just a matter of convincing the integration code to make use of it.
If you can submit a bug report about the incorrect integral that would be terrific.
best,
Robert Dodier
Diff: