Got Questions? Get Answers.
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:
Double Numerical Integration

Subject: Double Numerical Integration

From: V

Date: 14 Jan, 2009 17:20:17

Message: 1 of 5

Hi All,
I am trying to numerically evaluate a double integral function, z = f(x,y) over the limits (0,75000). The typical values of z are in the range 0 to 10^5. So the volume calculated under the surface plot is very large. This integration step takes several minutes (typically 15-20 mins) but when the step is repeated 75 times (for varying limits - still in 10^3 units), the whole process can take several hours to complete.
I am wondering if anyone knows of a simpler way of solving the problem which takes large limits that takes reasonable to solve as opposed to the current time of a few hours.

Cheers...

Subject: Double Numerical Integration

From: Sadik

Date: 14 Jan, 2009 17:31:01

Message: 2 of 5

"V" <javiar@rediffmail.com> wrote in message <gkl6sh$97r$1@fred.mathworks.com>...
> Hi All,
> I am trying to numerically evaluate a double integral function, z = f(x,y) over the limits (0,75000). The typical values of z are in the range 0 to 10^5. So the volume calculated under the surface plot is very large. This integration step takes several minutes (typically 15-20 mins) but when the step is repeated 75 times (for varying limits - still in 10^3 units), the whole process can take several hours to complete.
> I am wondering if anyone knows of a simpler way of solving the problem which takes large limits that takes reasonable to solve as opposed to the current time of a few hours.
>
> Cheers...

Hello V, :)

I believe the answer to your question depends on your function f(x,y). Could you give a few more details about it?

Thanks.

Subject: Double Numerical Integration

From: V

Date: 14 Jan, 2009 17:45:03

Message: 3 of 5

To simplify it .. lets say i would like to evaluate the volume of a cuboid over the limits x_Lower = y_lower = 0 and x_Upper = y_Upper = 75000. The height of z is kept constant at say 3. There is a loop where this process is repeated 75 times but each time a slightly lower volume is calculated until the volume calculated comes to zero. The above example takes approx 20 mins to solve.
I was hoping if i could find a way of solving the same prob in lesser time <5 min

Cheers ..

Subject: Double Numerical Integration

From: Roger Stafford

Date: 15 Jan, 2009 01:52:01

Message: 4 of 5

"V" <javiar@rediffmail.com> wrote in message <gkl8av$ho5$1@fred.mathworks.com>...
> To simplify it .. lets say i would like to evaluate the volume of a cuboid over the limits x_Lower = y_lower = 0 and x_Upper = y_Upper = 75000. The height of z is kept constant at say 3. There is a loop where this process is repeated 75 times but each time a slightly lower volume is calculated until the volume calculated comes to zero. The above example takes approx 20 mins to solve.
> I was hoping if i could find a way of solving the same prob in lesser time <5 min
>
> Cheers ..

  There is at least one way you can presumably save time. When you say, "each time a slightly lower volume is calculated", that sounds as though the area covered in the x-y plane is gradually shrinking. If I have understood correctly, this means that there are portions that are being covered repeatedly and this is a very wasteful way to proceed.

  Let us say that one time you integrate over the area 0<=x<=40000, and 0<=y<=40000. The next time you cover 0<=x<=39000 and 0<=y<=39000. This second area was already covered in the first integration and need not be recalculated (unless your function z=f(x,y) has been altered.) To get from the first integral to the second one, all you need is the integral over the L-shaped area between the two squares, which can then be subtracted from the first integral. Since it covers a smaller area it can be computed more quickly (hopefully!) To integrate over the L-shape with 'dblquad', break it into two rectangles.

  If you reverse the order, integrating the smallest area first and expanding from there, then instead of subtracting integral values you can accumulate them with possibly greater convenience and accuracy.

  There is the option in 'dblquad' of setting a tolerance level. The smaller the errors tolerated, the longer it takes to integrate, so you should carefully balance between allowed errors and computation time based on your needs.

  Sadik asked you for information about f(x,y). It might help if you could describe it. We have no idea how ugly an integrand you are faced with. There may be other tricks that can be played with it.

Roger Stafford

Subject: Double Numerical Integration

From: V

Date: 23 Jan, 2009 16:37:01

Message: 5 of 5

Roger,
Yes you are right, i am integrating over a square for each iteration along the xy axes. In the original volume, the value of z is constanlty evolving. In the case of the cuboid, the value of z remains constant. So it is practical to integrate only the 'L' portion for each subsequent iteration.
The equation of z = (1-theta)^-0.5 * exp(-0.5*(1-theta^2)^-1 * (x^2 + y^2)) * exp(0.5*(x^2 + y^2)), theta = constant. This function to imagine it simply looks like a nice peak from Ben Nevis ;)
My problem is further compounded by the fact that i am forced to calculate the volume each time over the rectangular region but i need to assign any z value obtained equal to zero when the value of x has crossed a certain threshold value, which again changes for each limit decrease/increase.
I have also played around with tolerances, and so far the tol of 1e-6 is proving to be the minimum necessary for good results.
I have tried to overcome the above problem by normalizing the value of z, so that the largest value of z does not exceed 1. But again, i gain a penalty by increasing the tolerance target to 1e-10. Slight improvement in speed only ;((
Any bright ideas...
Regards,
V

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