From: Shashishekar on 9 May 2010 10:43 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 """""""""""""""""""""""""""
From: Roger Stafford on 10 May 2010 05:24 "Shashishekar " <betafish(a)in.com> wrote in message <hs6hln$old$1(a)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
From: Roger Stafford on 10 May 2010 05:57 "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <hs8jbl$1ft$1(a)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
From: Shashishekar on 10 May 2010 10:15 I will work on it as advised and post the results in this forum.
From: TideMan on 10 May 2010 17:06
On May 10, 9:57 pm, "Roger Stafford" <ellieandrogerxy...(a)mindspring.com.invalid> wrote: > "Roger Stafford" <ellieandrogerxy...(a)mindspring.com.invalid> wrote in message <hs8jbl$1f...(a)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? |