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:
Problem with the Limits

Subject: Problem with the Limits

From: Shashishekar

Date: 9 May, 2010 14:43:03

Message: 1 of 8

I am a newbie to Mtlb, I want to implement an GUI for an euqn.In this process i want to test if the code works first or not, I am facing a problem with writing the code.

My euqn is :
   I= (pi*r^4)/4 * lim ( n -> inf) ( ( Sum (i=0 -> n-1) ( 1 -i/(n-1))^4)/n) ))

             http://www.flickr.com/photos/rshkiel



""""""""
function [ A ] = current(r,n)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here

 A = (pi*r^4)/4
  for i=1:n-1;
     value_except_n_0(i)=(1- (i/(n-1))^4);
   end
 
 B = (1+ sum(value_except_n_0))/n
 limit(B,n,100)
 I=A*B
 end
"""""""""""""""""""""""""""

Subject: Problem with the Limits

From: Roger Stafford

Date: 10 May, 2010 09:24:05

Message: 2 of 8

"Shashishekar " <betafish@in.com> wrote in message <hs6hln$old$1@fred.mathworks.com>...
> I am a newbie to Mtlb, I want to implement an GUI for an euqn.In this process i want to test if the code works first or not, I am facing a problem with writing the code.
>
> My euqn is :
> I= (pi*r^4)/4 * lim ( n -> inf) ( ( Sum (i=0 -> n-1) ( 1 -i/(n-1))^4)/n) ))
>
> http://www.flickr.com/photos/rshkiel
> """"""""
> function [ A ] = current(r,n)
> %UNTITLED Summary of this function goes here
> % Detailed explanation goes here
>
> A = (pi*r^4)/4
> for i=1:n-1;
> value_except_n_0(i)=(1- (i/(n-1))^4);
> end
>
> B = (1+ sum(value_except_n_0))/n
> limit(B,n,100)
> I=A*B
> end
> """""""""""""""""""""""""""
- - - - - - -
  You are attempting to approximate this limit by using high values of n, n=100 in this case. What you've done here looks correct as far as it goes. However, it would require an n higher than you probably have time and patience for to get the limit accurate enough by matlab standards - that is, to within one part in about 10^15 or so. I judge it would take about that high an n to accomplish this and 10^15 is a very big number! In other words it converges painfully slowly.

  There is another and far better method of finding this limit. It is possible to obtain a general formula for the sum involved here, and it is quite simple once you have placed it in it simplest form. Moreover its limit as n approaches infinity is then obvious, thus obviating endless hours spent over a hot computer with monstrous values of n.

  The secret to finding this formula for the sum is to determine general formulas for each of these four sums:

 1 + 2 + 3 + 4 + ... + (n-1) = ?
 1^2 + 2^2 + 3^2 + 4^2 + ... + (n-1)^2 = ?
 1^3 + 2^3 + 3^3 + 4^3 + ... + (n-1)^3 = ?
 1^4 + 2^4 + 3^4 + 4^4 + ... + (n-1)^4 = ?

You probably already know the first one, namely (n-1)*n/2, but each one of the other three has a convenient general formula too.

  Applying these formulas to your sum above and doing some careful algebraic simplification, you can finally arrive a quite decent general formula for your sum, and as I say, at that point its limit becomes evident.

  It is also quite possible that you could coerce matlab's symbolic toolbox into working out this formula for you without going through all the above hand manipulation. But that would take all the fun out of it, wouldn't it?

Roger Stafford

Subject: Problem with the Limits

From: Roger Stafford

Date: 10 May, 2010 09:57:08

Message: 3 of 8

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hs8jbl$1ft$1@fred.mathworks.com>...
> .....
> 1 + 2 + 3 + 4 + ... + (n-1) = ?
> 1^2 + 2^2 + 3^2 + 4^2 + ... + (n-1)^2 = ?
> 1^3 + 2^3 + 3^3 + 4^3 + ... + (n-1)^3 = ?
> 1^4 + 2^4 + 3^4 + 4^4 + ... + (n-1)^4 = ?
> ......

  Actually you only need the last of the above identities if you look at things the right way.

Roger Stafford

Subject: Problem with the Limits

From: Shashishekar

Date: 10 May, 2010 14:15:22

Message: 4 of 8

I will work on it as advised and post the results in this forum.

Subject: Problem with the Limits

From: TideMan

Date: 10 May, 2010 21:06:53

Message: 5 of 8

On May 10, 9:57 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Roger Stafford" <ellieandrogerxy...@mindspring.com.invalid> wrote in message <hs8jbl$1f...@fred.mathworks.com>...
> > .....
> >  1 + 2 + 3 + 4 + ... + (n-1) = ?
> >  1^2 + 2^2 + 3^2 + 4^2 + ... + (n-1)^2 = ?
> >  1^3 + 2^3 + 3^3 + 4^3 + ... + (n-1)^3 = ?
> >  1^4 + 2^4 + 3^4 + 4^4 + ... + (n-1)^4 = ?
> > ......
>
>   Actually you only need the last of the above identities if you look at things the right way.
>
> Roger Stafford

You're right, but I only got there after a page of algebra.
How could I have gotten there without the algebra?

BTW, the answer I got for the limit is 6/30, correct?

Subject: Problem with the Limits

From: Roger Stafford

Date: 10 May, 2010 22:46:05

Message: 6 of 8

TideMan <mulgor@gmail.com> wrote in message <50885f83-7fdc-4db8-8a6e-7644a4332835@a2g2000prd.googlegroups.com>...
> You're right, but I only got there after a page of algebra.
> How could I have gotten there without the algebra?
> BTW, the answer I got for the limit is 6/30, correct?
- - - - - - - -
  Yes, that's the correct limit, Tideman. (Shashishekar will be grateful to you for spilling the beans. :-) )

  Whether it takes a lot of algebra or not depends on whether you already know the fourth identity, which is in fact:

 1^4 + 2^4 + 3^4 + 4^4 + ... + (n-1)^4 = (n-1)*n*(2*n-1)*(3*n^2-3*n-1)/30

After that it is all smooth sailing, because the summation satisfies

 sum((1-(0:n-1)/(n-1)).^4) = sum(((n-1-(0:n-1))/(n-1)).^4) =
 sum((n-1:-1:0).^4)/(n-1)^4 = sum((0:n-1).^4)/(n-1)^4 ,

this last equality being obtained by doing a 'fliplr' which doesn't alter the sum. So, hardly any algebra is needed after that.

  My ancient "CRC Standard Mathematical Tables" only gave the summation of powers of i up to cubes, so I'll have to confess it took some algebra on my part to work it out for the fourth power, but I am sure some other tables are floating around which contain that formula.

Roger Stafford

Subject: Problem with the Limits

From: TideMan

Date: 10 May, 2010 23:45:57

Message: 7 of 8

On May 11, 10:46 am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> TideMan <mul...@gmail.com> wrote in message <50885f83-7fdc-4db8-8a6e-7644a4332...@a2g2000prd.googlegroups.com>...
> > You're right, but I only got there after a page of algebra.
> > How could I have gotten there without the algebra?
> > BTW, the answer I got for the limit is 6/30, correct?
>
> - - - - - - - -
>   Yes, that's the correct limit, Tideman.  (Shashishekar will be grateful to you for spilling the beans.  :-)  )
>
>   Whether it takes a lot of algebra or not depends on whether you already know the fourth identity, which is in fact:
>
>  1^4 + 2^4 + 3^4 + 4^4 + ... + (n-1)^4 = (n-1)*n*(2*n-1)*(3*n^2-3*n-1)/30
>
> After that it is all smooth sailing, because the summation satisfies
>
>  sum((1-(0:n-1)/(n-1)).^4) = sum(((n-1-(0:n-1))/(n-1)).^4) =
>  sum((n-1:-1:0).^4)/(n-1)^4 = sum((0:n-1).^4)/(n-1)^4 ,
>
> this last equality being obtained by doing a 'fliplr' which doesn't alter the sum.  So, hardly any algebra is needed after that.
>
>   My ancient "CRC Standard Mathematical Tables" only gave the summation of powers of i up to cubes, so I'll have to confess it took some algebra on my part to work it out for the fourth power, but I am sure some other tables are floating around which contain that formula.
>
> Roger Stafford

Oh, I got the 4th power OK from my 40-year old Gradshteyn & Ryzhik
Table of Integrals Series and Products.
What I wanted to know is how you knew that the first 4 terms cancelled
to just leave just the 4th power sum.

Subject: Problem with the Limits

From: Shashishekar

Date: 12 May, 2010 08:43:04

Message: 8 of 8

The problem has been resolved now, It would not have been possible without the help of this forum. Thank you very much for the support

Tags for 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