Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trapz for an integral with a variable limit

72 views
Skip to first unread message

Anna Kaladze

unread,
Aug 24, 2010, 8:38:02 AM8/24/10
to
Dear all,
I have a non-integrable function, f(u). It is in the inner integral of a double integral, and the inner one has a variable limit of integration. Like this:
"Integral [(Integral of f(u), du)] dt"
The outer integral (where the integrand is [(Integral of f(u), du)]) has finite limits (40 and 55, and the variable of integration is t). But the inner integral (where integrand is f(u)) has a low limit 0, but the upper limit is t (in principle, t takes the value from 0 to 55). Can someone help me to deal with this issue? The BIG problem is I need to approximate the solution to my problem SOLELY by employing trapz function. I was advised to adhere to quad2d routine. But I must use trapz and only do a numerical approximation (step size 0.01 should be sufficient to get a decent approximation for my purposes). The question is: “how”?
P.S. If the inner integral had constant limits, there would have been no problem even for a dummy like myself, but the inner one's upper limit is t. I tried to do some looping and employed arrayfun but I do not think my skills are up there to crack this problem.
P.P.S. Let us assume f(u) = u^2 (for the sake of an illustration, although that would be easily integrable).
Anna.

Roger Stafford

unread,
Aug 24, 2010, 6:35:08 PM8/24/10
to
"Anna Kaladze" <anna.k...@gmail.com> wrote in message <i50efa$mcb$1...@fred.mathworks.com>...
- - - - - - - - - -
You are still misusing the word "non-integrable", Anna! If your function were actually non-integrable neither you nor anyone else be able to integrate it. It would be an ill-defined notion.

Your problem is ideal for cumtrapz as the inner integral, which is simply the cumulative form of trapz, and trapz for the outer integral. If you cannot use cumtrapz, you could always call on trapz multiple times with an increasing upper bound, which is just what cumtrapz would do for you.

Roger Stafford

Anna Kaladze

unread,
Aug 27, 2010, 10:57:05 PM8/27/10
to
Roger,
thanks a lot. cumtrapz solved the problem, which is great.
Best,
Anna.

"Roger Stafford" <ellieandr...@mindspring.com.invalid> wrote in message <i51hes$8eh$1...@fred.mathworks.com>...

0 new messages