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:
Can I integrate the following function in MATLAB??

Subject: Can I integrate the following function in MATLAB??

From: kumar vishwajeet

Date: 30 May, 2011 22:57:02

Message: 1 of 8

I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)

where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.

Subject: Can I integrate the following function in MATLAB??

From: John D'Errico

Date: 30 May, 2011 23:11:02

Message: 2 of 8

"kumar vishwajeet" wrote in message <is17bu$i8i$1@newscl01ah.mathworks.com>...
> I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
> f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)
>
> where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.

You cannot do a numerical integration of a symbolic function.

Those tools are for numerical integration. Try the symbolic
toolbox.

John

Subject: Can I integrate the following function in MATLAB??

From: Roger Stafford

Date: 30 May, 2011 23:25:20

Message: 3 of 8

"kumar vishwajeet" wrote in message <is17bu$i8i$1@newscl01ah.mathworks.com>...
> I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
> f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)
>
> where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.
- - - - - - - - -
  I can't reconcile the two aspects of your request. On the one hand you seem to be asking for a general formula for the above double integral as a function of a, b, c, d, and e, and yet on the other hand you want to do the integration numerically. It is conceivable that the symbolic toolbox could come up with the first part, (though I have serious doubts,) but I don't really know what you mean by doing the integration numerically in such a way that it incorporates the five undefined symbols. Perhaps you can clarify your question.

Roger Stafford

Subject: Can I integrate the following function in MATLAB??

From: kumar vishwajeet

Date: 31 May, 2011 04:06:04

Message: 4 of 8

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <is1866$juu$1@newscl01ah.mathworks.com>...
> "kumar vishwajeet" wrote in message <is17bu$i8i$1@newscl01ah.mathworks.com>...
> > I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
> > f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)
> >
> > where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.
>
> You cannot do a numerical integration of a symbolic function.
>
> Those tools are for numerical integration. Try the symbolic
> toolbox.
>
> John

I tried symbolic toolbox with "int", but since the function is quite complex, I donot get a closed form solution. I first tried to integrate it w.r.t. "x" but I did not get any explicit value. That's why I want to use numerical integration. Is it possible to do it?

Subject: Can I integrate the following function in MATLAB??

From: kumar vishwajeet

Date: 31 May, 2011 04:08:02

Message: 5 of 8

"Roger Stafford" wrote in message <is1910$lsl$1@newscl01ah.mathworks.com>...
> "kumar vishwajeet" wrote in message <is17bu$i8i$1@newscl01ah.mathworks.com>...
> > I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
> > f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)
> >
> > where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.
> - - - - - - - - -
> I can't reconcile the two aspects of your request. On the one hand you seem to be asking for a general formula for the above double integral as a function of a, b, c, d, and e, and yet on the other hand you want to do the integration numerically. It is conceivable that the symbolic toolbox could come up with the first part, (though I have serious doubts,) but I don't really know what you mean by doing the integration numerically in such a way that it incorporates the five undefined symbols. Perhaps you can clarify your question.
>
> Roger Stafford

I want to integrate the function in such a way that the result is still a function of a,b,c,d,e. I tried to do it using symbolic toolbox, but did not get any explicit solution. That's why I want to do it numerically.

Subject: Can I integrate the following function in MATLAB??

From: Roger Stafford

Date: 31 May, 2011 05:19:04

Message: 6 of 8

"kumar vishwajeet" wrote in message <is1pj2$15a$1@newscl01ah.mathworks.com>...
> I want to integrate the function in such a way that the result is still a function of a,b,c,d,e. I tried to do it using symbolic toolbox, but did not get any explicit solution. That's why I want to do it numerically.
- - - - - - - - - -
  I pose the question to you, Kumar. Given that you cannot obtain a formula giving your double integral as an explicit function of the five parameters, what form would you expect a "numerical" solution to be in?

  When faced with just this problem for other functions, mathematicians, especially in the past, have used tables such as sine and cosine values as functions of their angles that were calculated numerically. In more modern times, they have used computers with programs that could quickly carry out numerical computations necessary for their calculation. Every time you call on 'exp', 'log', or 'atan2' you are calling on such programs.

  Now you are faced with a function of five different arguments, a, b, c, d, and e. It would probably be quite impractical to produce tables with five independent variables like this. If each variable were allowed to range over, say, a thousand different values to ensure good accuracy, your table would have to contain a thousand, million, million entries.

  So what is the next best thing you can do? Of course. Write yourself a matlab function with five arguments, which carries out the desired numerical double integration for whatever particular values of a, b, c, d, and e are entered. This is the best you can hope to do in lieu of said monstrous tables or explicit formulas that no-one has ever discovered. But that does mean that you must give up the idea of obtaining an answer in terms of five symbolic parameters! Anyone who uses your function must specify all five arguments as definite numerical quantities.

Roger Stafford

Subject: Can I integrate the following function in MATLAB??

From: John D'Errico

Date: 31 May, 2011 11:51:04

Message: 7 of 8

"kumar vishwajeet" wrote in message <is1pfc$nl$1@newscl01ah.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message <is1866$juu$1@newscl01ah.mathworks.com>...
> > "kumar vishwajeet" wrote in message <is17bu$i8i$1@newscl01ah.mathworks.com>...
> > > I want to numerically integrate the following function. Is it possible to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of symbolic constants in these commands.
> > > f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y)
> > >
> > > where a,b,c,d,e are symbolic constants and limit of integration is (0,1) for x and (0,1) for y.
> >
> > You cannot do a numerical integration of a symbolic function.
> >
> > Those tools are for numerical integration. Try the symbolic
> > toolbox.
> >
> > John
>
> I tried symbolic toolbox with "int", but since the function is quite complex, I donot get a closed form solution. I first tried to integrate it w.r.t. "x" but I did not get any explicit value. That's why I want to use numerical integration. Is it possible to do it?

Numerical schemes use adaptive methods, based on the shape
of the function to be integrated. But a function with symbolic
parameters cannot be integrated in this way, because it cannot
know the values of those parameters.

As I said, you cannot integrate a symbolic function using
numerical tools, and if no closed symbolic form exists, then
you are out of luck.

Just wanting to do something does not make it mathematically
possible. Even wanting to do something very much is not
sufficient.

Your main choice is to wait until you actually have values for
those unknown parameters. At that point in time, a symbolic
solution might be possible, and a numerical solution will
definitely be possible.

John

Subject: Can I integrate the following function in MATLAB??

From: Steven_Lord

Date: 31 May, 2011 13:30:37

Message: 8 of 8



"kumar vishwajeet" <kwzeet@gmail.com> wrote in message
news:is1pfc$nl$1@newscl01ah.mathworks.com...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message
> <is1866$juu$1@newscl01ah.mathworks.com>...
>> "kumar vishwajeet" wrote in message
>> <is17bu$i8i$1@newscl01ah.mathworks.com>...
>> > I want to numerically integrate the following function. Is it possible
>> > to do it in MATLAB?? I tried quad2d, dblquad. But there is no scope of
>> > symbolic constants in these commands.
>> > f(x,y) = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 -
>> > y) - e*x*y)
>> >
>> > where a,b,c,d,e are symbolic constants and limit of integration is
>> > (0,1) for x and (0,1) for y.
>>
>> You cannot do a numerical integration of a symbolic function.
>>
>> Those tools are for numerical integration. Try the symbolic
>> toolbox.
>>
>> John
>
> I tried symbolic toolbox with "int", but since the function is quite
> complex, I donot get a closed form solution. I first tried to integrate it
> w.r.t. "x" but I did not get any explicit value. That's why I want to use
> numerical integration. Is it possible to do it?

Only if you specify numeric values for a, b, c, d, and e.

syms a b c d e x y
f = log(1-x)*exp(-a*log(x) - b*log(1-x) - c*log(y) - d*log(1 - y) - e*x*y);
g = matlabFunction(subs(f, {a,b,c,d,e}, {1,2,3,4,5}), 'vars', [x y]);
z = quad2d(g, 0.25, 0.75, 0.25, 0.75)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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