MATLAB: Infinit symbolic series with symsum() – HELP!

MATLABseriessymbolic

Hello everyone,
I am trying to solve the following infinite series problem at MATLAB R2015a:
I have scripted the following:
clear all
clc
syms x t a n
N = [n, n+2]; %Vector with n and n+2
A_N = ((tan(x)).^N);%Integrant of a_n
a_n = int(A_N,x,0,pi/4);%Integral term a_n
s = (1/n)*(a_n(1) + a_n(2));%General term of the series
S = symsum(s,n,1,inf);
which yields for the varialbe S:
S = symsum((int(tan(x)^n, x, 0, pi/4) + int(tan(x)^(n + 2), x, 0, pi/4))/n, n, 1, Inf)
If I use vpa(S), it yields: ans = 1.0
What am I doing wrong? How could I solve this problem properly in matlab?
Thank you in advance
Gabriel

Best Answer

You did make an effort, even though this is homework. And you even got the correct answer. But pencil and paper should suffice, maybe with just a little help from MATLAB. Suppose you make the obvious transformation? That is, what if
u = tan(x)
then we have dx = 1/(u^2 + 1) du. Can you now write a_n in simple form? Perhaps this does not get you all the way there, at least not without a little more work.
Now consider what happens if you form the sum of a_n + a_(n+2). Does that help any? (Hint: YES.) That is, what if you combine
a_n + a_(n+2)
as an integral? Does anything nice happen? Can you factor anything? Hint:
(u^n + u^(n+2))/(u^2 + 1) == u^n
So can you compute a_n + a_(n+2)? I hope so, but to make you feel better, I'll use MATLAB. ;-)
syms u
syms n real positive
int(u^n,[0,1])
ans =
1/(n + 1)
Now, what is the infinite sum?
symsum(1/n/(n+1),1,inf)
ans =
1
What does this say? That you got the correct answer, yet did not believe it would be that simple? Sometimes homework questions really do have a simple solution. In fact, that would be the perfect homework problem - making you do some work, only to yield a simple answer. Sadly, real life is rarely that nice, so enjoy being a student while it is there.