+ Reply to Thread
Results 1 to 7 of 7

Need to Integrate

  1. #1
    Registered User
    Join Date
    07-11-2008
    Location
    THE NORTH
    Posts
    52

    Question Need to Integrate

    I need to use excel to integrate this equation:
    R(m,n) = (1/2*pi) * integral <between 0 and 2*pi> (1/t) *[1 - (t-1/t+1)^(m+n) * (t-i/t+i)^(m-n)] wrt dt
    (Please see attached).

    How can I do this?

    As well I want to iterate this integral over a variable grid size. For example, size 5 x 5. In the very worst case scenario the grid would be say 1000 x 1000. So I will have a table of 5 rows and 5 columns and the results will get fed in to the table depending upon the index used. e.g. m = 0 and n= 0 is the top left hand corner of the table/grid.

    I want to find the solution for this equation for each grid/table position.

    Any ideas how I can do this?

    All suggestions and help are very much appreciated.

    Thanks
    Attached Images Attached Images

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,872

    Re: Need to Integrate

    I'm not sure where to begin, because I'm not sure how much calculus you've had. See if this makes sense.

    One common interpretation of the integral is as the area under the curve. Numerical integration methods are about finding an approximation to the curve for which one can easily calculate the area. One of the easiest is a rectangle. If you approximate the curve as a rectangle, you can simply multiply the height by the width to get the integral. A single rectangle is not usually going to be a good approximation, so what is usually done is to subdivide the integral in question into several small rectangular slices, find the area of each slice, then add up those areas to get the total. These are called Riemann sums (Wikipedia has an article that describes these).

    If I were setting this up in a spreadsheet, I would set up a table that looks something like this:

    x(i),f(x(i)),dx usually constant,area=f(x(i))*dx

    Then use a =sum() function to add up the individual areas. I would probably set it up to calculate a few different integrals (right hand sum, left hand sum, midpoint sum, trapezoidal rule) to get an idea of how accurately I'm calculating the integral. Repeat this process with different dx's until I'm comfortable that I have the correct answer within the desired accuracy.

  3. #3
    Registered User
    Join Date
    07-11-2008
    Location
    THE NORTH
    Posts
    52

    Re: Need to Integrate

    Thanks Mr Shorty for your advice.

    It could be hard to keep a handle on the accuracy doing this for 100's of integrals.Hmmm... I really want to do this in excel but I'm thinking now that Excel just isn't up to the task.

    I've been trying to search around for any UDFs that people may have created. Surely, I'm not the first to want to integrate in excel. Does anyone know a site where one can download UDFs?

    Thanks

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,872

    Re: Need to Integrate

    It could be hard to keep a handle on the accuracy doing this for 100's of integrals.
    Define "hard." I would not call it "hard" -- just part of any numerical solution. It's also a question that doesn't go away by changing programming language. Part of programming any numerical method is knowing how to determine the accuracy and how to decide when the computation is "accurate enough." As anything else, it becomes easier with understanding and practice.

    Hmmm... I really want to do this in excel but I'm thinking now that Excel just isn't up to the task.
    Excel is no worse (and probably no better) than any other programming language for numerical integration. It might be nice to find an application (MathCadd type applications might) that has the numerical integration routines built into the application, but they are using the same basic algorithms that can be programmed into a spreadsheet or other language. Even if you do find an application with the routines pre-programmed in, it will be useful to you to understand the theory behind numerical integration so you can evaluate the output and make sure it is reasonable.

    Programming a UDF to do the numerical integration isn't hard, assuming you already understand the theory behind numerical integration and understand your programming language. The logic is basically the same as I put into the spreadsheet solution, you would simply be converting that into blocks of code.

    I'm almost certain I've seen a couple of routines posted on this board over the years. Adapting someone else's UDF to your own problem will still require some adaptation on your part, and enough understanding on your part to make it work. It is unlikely to be as simple as "download UDF, plug into code module, perform integration."

    Do you expect to be performing these kinds of computations occasionally or even frequently throughout your career? If this is the only time you'll ever need to do this, then find the easiest solution (which might be a little tedious, like the solution I've proposed) and get it done. If you will likely use these same methods on future problem, I would suggest a little bit of research into these numerical methods (a numerical methods text might be a good investment here) so you'll be able to use them in future problems.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Integrate

    What is i in the expression?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    07-11-2008
    Location
    THE NORTH
    Posts
    52

    Re: Need to Integrate

    Quote Originally Posted by shg View Post
    What is i in the expression?
    complex numbers sqrt(-1)

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Integrate

    Yikes. That makes the function something like

    =IMPRODUCT(COMPLEX(1/t, 0), IMPRODUCT(COMPLEX(1 - ((t-1) / (t+1)) ^ (m+n), 0), IMPOWER(IMDIV(COMPLEX(t, -1), COMPLEX(t, 1)), m-n)))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1