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:
trapz for an integral with a variable limit

Subject: trapz for an integral with a variable limit

From: Anna Kaladze

Date: 24 Aug, 2010 12:38:02

Message: 1 of 3

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.

Subject: trapz for an integral with a variable limit

From: Roger Stafford

Date: 24 Aug, 2010 22:35:08

Message: 2 of 3

"Anna Kaladze" <anna.kaladze@gmail.com> wrote in message <i50efa$mcb$1@fred.mathworks.com>...
> 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.
- - - - - - - - - -
  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

Subject: trapz for an integral with a variable limit

From: Anna Kaladze

Date: 28 Aug, 2010 02:57:05

Message: 3 of 3

Roger,
thanks a lot. cumtrapz solved the problem, which is great.
Best,
Anna.

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i51hes$8eh$1@fred.mathworks.com>...
> "Anna Kaladze" <anna.kaladze@gmail.com> wrote in message <i50efa$mcb$1@fred.mathworks.com>...
> > 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.
> - - - - - - - - - -
> 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

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