Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Function recursion doubt' topicStudent Support Forum > General > "Function recursion doubt"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
10/03/12 4:14pm

First is a small error and will not fix your problem.
At the end of your Module you have

-dia]]; tabla]]

This should be

-dia]]]; tabla]

Next is a large error and appears to be the cause of your problem.
In your module you have

torneo[n/2]; (*here is recursive function

When you recursively call torneo[n/2] a new copy of torneo does the calculation and then returns the matrix as the value of the recursive call.

You then do nothing with this returned value, you do not use the value to update your matrix, and the result is then discarded.

You must decide how to use the value returned from the recursive call. Perhaps you want to use that returned value to modify tabla in your matrix. I cannot be certain.

Does this make it clear?

This shows an example of recursively creating smaller vectors and then joining the smaller vector to the rest of the original vector.

In[1]:= f[n_]:=Module[{tabla},

Out[2]= {1,2,0,4,0,0,0,8,0,0,0,0,0,0,0,16}

For a matrix it would be more complex to update the original tabla.

URL: ,

Subject (listing for 'Function recursion doubt')
Author Date Posted
Function recursion doubt luis 10/03/12 1:15pm
Re: Function recursion doubt Bill Simpson 10/03/12 4:14pm
< Previous CommentHelp | Reply To Comment | Reply To Topic