0

i want to solve this problem:

alt text http://img265.imageshack.us/img265/6598/greenshot20100727091025.png

i don't want to use "int", i want to use "quad" family (quad,dblquad,triplequad) but i can't. can you help me?

2
  • 1
    The quotes are missing from your question, plus you need to show the relevant portions of your problem along with error messages in your question, don't expect people to download stuff from other websites.
    – Ben Voigt
    Jul 27, 2010 at 12:08
  • yes, but i don't know to write integral in this page.
    – Elmoya
    Jul 27, 2010 at 12:12

4 Answers 4

4

I assume that your real problem is more complex than this trivial one. The best solution is just to use a symbolic integral. Why is numerical integration difficult?

Numerical integration in ONE dimension typically requires on the order of say 100 function evaluations. (The exact number will be very dependent on the accuracy required, the limits, etc.) This makes a 2-d integral typically require on the order of 100^2 = 10000 function evals. So an adaptive, 5-d integral will require on the order of 100^5 = 1e10 function evaluations. (This is only a very rough order of magnitude estimate here.) My point is, you simply don't want to do that!

Better is to reduce the problem in complexity. If your integral is separable (as is this one) then do so! Reduce a 5-d problem into multiple 1-d problems.

Also, in many cases I see people wanting to do a numerical integration of a Gaussian PDF. See that this is easily solved using a call to erf or erfc, coupled with a transformation. The point is that in many cases special functions are defined to greatly reduce the complexity of a problem.

I should add that in many cases, the key to solving a difficult problem in mathematics is to use mathematics to reduce the problem to something simpler. If you can find a way to reduce the dimensionality of your problem just a bit, it will become much more tractable.

2

The integral you show is

  1. Analytically solvable: always do analytically what you can

  2. ?equal to a number: constant expressions should be eliminated from numerical calculations

  3. not easy to get calculated in MATLAB (or very correct).

You can use cumtrapz to integrate over each variable alone, and call trapz the final integration. Remember that this will blow up the error on any problem that is more complicated than the simple sum of linear functions.

Mathematica is more suited to nD integrations, if you have access to that.

1

matlab can do symbolic integration

>> x = sym('x'); y = sym('y'); z = sym('z'); u = sym('u'); v = sym('v'); 
>> int(int(int(int(int(x+y+z+u+v,1,5),-2,3),0,1),-1,1),0,1)

ans =

180
0
0

Just noticed you want to do numeric, not symbolic integration

If you look at the source of dblquad and triplequad

>> edit dblquad

you see that they just call the lower versions. it should be possible for you to add a quadquad and a quintquad (or recursively an n-quad)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.