Infinit symbolic series with symsum() - HELP!

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

 Accepted 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.

3 Comments

Hi John,
The fact is that this homework WAS SUPPOSED to be answered using MATLAB and ONLY it. The class is about MATLAB for scientific computing, so there is that.
Yes, in fact, I did not believe the anwser could be that simple considering my original anwser for the sum (S = symsum((int(tan(x)^n, x, 0, pi/4) + int(tan(x)^(n + 2), x, 0, pi/4))/n, n, 1, Inf)): since MATLAB did not returned a resonable value, but actually the used functions, I did not believe that the answer using vpa(S) = 1.0 would be right.
But thank you for the explanation and for the answer, it was very helpful! ;-)
One question still remains: Why couldn't MATLAB return me S = 1.0 in my scrpit?
You should be able to use MATLAB to solve it as I showed. I gave you the general outline of where to go in the solution. My goal is not to do your homework.
I would guess that MATLAB was unable to make the leap to solve the problem as I did, recognizing that things can be simplified quite heavily when you combine a_n and a_(n+2), especially so when the problem is transformed. That is not uncommon. Symbolic tools are great at brute force, but they don't have much intuition, much ability to foresee where things are going.
In my case, I looked at a few specific cases for increasing n first, saw what was happening, then saw how to make things collapse, partly because I now knew what to look for.
However, it looks like VPA forced it to turn the result into numerical form. Again not uncommon with the symbolic toolbox, where on many problems it leaves a result as a nasty mess, not realizing that everything just collapses.
I am not asking or trying to make you solve my homework what so ever and I am very thankful for your clarification and help. Indeed, I was just trying to understand why MATLAB could not solve properly a problem that is possible to be hand-solved. Good to know symbolic toolbox has its drawbacks, considring future applications.
Well, thank you for your help and time!

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!