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:
integration is there a faster method??

Subject: integration is there a faster method??

From: Dhritiman

Date: 16 Jan, 2009 07:57:04

Message: 1 of 5

the following integration takes atleast 7 to 10 minutes in my pc. Is there are faster method to do this.......i need to run this integration many times with diffferent upper and lower bounds new_z1,new_z2

syms z w
y=int(138.2528*84.626456371135150*z*(1-0.99*z)*((1/w)^3.680000000000001)*((1/((2)*.06^3))*(z^(3-1))*(2.718281828459046^(-z/.06))),z,new_z1,new_z2)

Subject: integration is there a faster method??

From: Roger Stafford

Date: 16 Jan, 2009 08:31:54

Message: 2 of 5

"Dhritiman " <dhritiman-bhattacharya@uiowa.edu> wrote in message <gkpekf$699$1@fred.mathworks.com>...
> the following integration takes atleast 7 to 10 minutes in my pc. Is there are faster method to do this.......i need to run this integration many times with diffferent upper and lower bounds new_z1,new_z2
>
> syms z w
> y=int(138.2528*84.626456371135150*z*(1-0.99*z)*((1/w)^3.680000000000001)*((1/((2)*.06^3))*(z^(3-1))*(2.718281828459046^(-z/.06))),z,new_z1,new_z2)

  Factor out all the stuff that doesn't depend on z and you can reduce the integral to:

 y=int(z^3*(1-0.99*z)*exp(-z/.06),z,new_z1,new_z2)

That ought to integrate a lot faster. Then multiply the removed factors back in.

Roger Stafford

Subject: integration is there a faster method??

From: Roger Stafford

Date: 16 Jan, 2009 09:03:01

Message: 3 of 5

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gkpglq$qff$1@fred.mathworks.com>...
> "Dhritiman " <dhritiman-bhattacharya@uiowa.edu> wrote in message <gkpekf$699$1@fred.mathworks.com>...
> > the following integration takes atleast 7 to 10 minutes in my pc. Is there are faster method to do this.......i need to run this integration many times with diffferent upper and lower bounds new_z1,new_z2
> >
> > syms z w
> > y=int(138.2528*84.626456371135150*z*(1-0.99*z)*((1/w)^3.680000000000001)*((1/((2)*.06^3))*(z^(3-1))*(2.718281828459046^(-z/.06))),z,new_z1,new_z2)
>
> Factor out all the stuff that doesn't depend on z and you can reduce the integral to:
>
> y=int(z^3*(1-0.99*z)*exp(-z/.06),z,new_z1,new_z2)
>
> That ought to integrate a lot faster. Then multiply the removed factors back in.
>
> Roger Stafford

  Second thought. Instead of forcing 'int' to solve the same definite integral over and over again for differing bounds, do an indefinite integral of the above simplified function of z just once. Then you can find its definite integral for various lower and upper bounds by simple substitution according to the rules of calculus.

  It looks as if the indefinite integral should be fairly easy for the symbolic toolbox to find. (You could even solve it yourself by consulting a good table of integrals.)

Roger Stafford

Subject: integration is there a faster method??

From: Walter Roberson

Date: 16 Jan, 2009 16:13:49

Message: 4 of 5

Dhritiman wrote:
> the following integration takes atleast 7 to 10 minutes in my pc.

That's odd -- it only takes a fraction of a second for the indefinite integral
on my systems. But when you look at the indefinite integral, it obviously will
have big precision problems, so the 7 to 10 minutes you are seeing might have
to do with adaptive numeric integration in order to attempt to get the
result as accurate as is numerically possible.

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: integration is there a faster method??

From: Roger Stafford

Date: 16 Jan, 2009 16:56:02

Message: 5 of 5

Walter Roberson <roberson@hushmail.com> wrote in message <Qm2cl.110291$2w3.40094@newsfe19.iad>...
>
> That's odd -- it only takes a fraction of a second for the indefinite integral
> on my systems. But when you look at the indefinite integral, it obviously will
> have big precision problems, so the 7 to 10 minutes you are seeing might have
> to do with adaptive numeric integration in order to attempt to get the
> result as accurate as is numerically possible.
> .......

  I get

 int('z^3*(1-a*z)*exp(-z/b)','z') =
 b*(a*z^4+(4*a*b-1)*(z^3+3*b*z^2+6*b^2*z+6*b^3))*exp(-z/b)

I don't see anything inherently difficult about that.

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