Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Problem with the Limits
Date: Mon, 10 May 2010 09:24:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 41
Message-ID: <hs8jbl$1ft$1@fred.mathworks.com>
References: <hs6hln$old$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273483445 1533 172.30.248.35 (10 May 2010 09:24:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 May 2010 09:24:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:634165

"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