Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Programing Tail-Recursive functions..

Subject: Programing Tail-Recursive functions..

From: machatsk

Date: 24 Sep, 2010 18:03:09

Message: 1 of 3

I am trying to solve a tail-recursive for the function..

A=1-1/2+1/3-1/4+1/5-1/6+.....

The signs are alternating between odd and even numbers. I am new to matlab and I am not sure how to use odd or evens in the program.

Any help to get me going would be apprecited.

Thanks

Subject: Programing Tail-Recursive functions..

From: Walter Roberson

Date: 24 Sep, 2010 18:16:43

Message: 2 of 3

On 10-09-24 01:03 PM, machatsk wrote:
> I am trying to solve a tail-recursive for the function..
>
> A=1-1/2+1/3-1/4+1/5-1/6+.....
>
> The signs are alternating between odd and even numbers. I am new to
> matlab and I am not sure how to use odd or evens in the program.
>
> Any help to get me going would be apprecited.

Matlab is not documented as implementing tail-recursion optimization.

There are quite a few ways that you can determine whether a number is odd or
even. What is the mathematical definition of an "even number" ?

Subject: Programing Tail-Recursive functions..

From: Walter Roberson

Date: 24 Sep, 2010 19:31:11

Message: 3 of 3

On 10-09-24 01:03 PM, machatsk wrote:
> I am trying to solve a tail-recursive for the function..
>
> A=1-1/2+1/3-1/4+1/5-1/6+.....
>
> The signs are alternating between odd and even numbers. I am new to
> matlab and I am not sure how to use odd or evens in the program.

Hint:

1-1/2+1/3-1/4+1/5-1/6 = 0-(1/6-(1/5-(1/4-(1/3-(1/2-1)))))

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us