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:
Warning: Explicit integral could not be found.

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 2 Jul, 2011 22:53:07

Message: 1 of 11

I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".

(2*R^-9) + (A*R^-11) / ((A+R^2)^2)

I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A

Thanks,
Ashwin

Subject: Warning: Explicit integral could not be found.

From: Roger Stafford

Date: 3 Jul, 2011 01:24:09

Message: 2 of 11

"Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iuo7gj$oi7$1@newscl01ah.mathworks.com>...
> I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".
>
> (2*R^-9) + (A*R^-11) / ((A+R^2)^2)
>
> I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
> I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A
>
> Thanks,
> Ashwin
- - - - - - - - - -
  My own ancient version of 'solve' managed to handle that (with a rather messy solution.) I don't see why later versions should be less skillful than mine. Mine did make the rather unwarranted assumption that the quantity A+R^2 was always positive throughout the R range from 1 to 2 when it used log(A+R^2) in the indefinite integral at one point. Perhaps your version is more careful about that and wants more information about A before committing itself. If A is actually supposed to be positive, you might try using B^2 in place of A to see if that would remove its doubts since there is no chance that B^2+R^2 could be negative.

Roger Stafford

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 3 Jul, 2011 06:21:10

Message: 3 of 11

"Roger Stafford" wrote in message <iuogbp$fih$1@newscl01ah.mathworks.com>...
> "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iuo7gj$oi7$1@newscl01ah.mathworks.com>...
> > I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".
> >
> > (2*R^-9) + (A*R^-11) / ((A+R^2)^2)
> >
> > I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
> > I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A
> >
> > Thanks,
> > Ashwin
> - - - - - - - - - -
> My own ancient version of 'solve' managed to handle that (with a rather messy solution.) I don't see why later versions should be less skillful than mine. Mine did make the rather unwarranted assumption that the quantity A+R^2 was always positive throughout the R range from 1 to 2 when it used log(A+R^2) in the indefinite integral at one point. Perhaps your version is more careful about that and wants more information about A before committing itself. If A is actually supposed to be positive, you might try using B^2 in place of A to see if that would remove its doubts since there is no chance that B^2+R^2 could be negative.
>
> Roger Stafford

---------------------------------------------------------------------------------------------------------
Hello Roger,

I tried going in with A = B^2, i.e. my eqn now changed to,

[(2*R^-9 + B^2*R^-11)]/(B^2 + R^2)^2.

But still I get the same warning. I get an answer for 2 conditions
When B=1 or for that matter when A=1, I have an answer
But when B or A is not equal to 1 (otherwise) I get an answer again in terms of an integral.

Whats the way to solve these kind of integrals..??

-Ashwin

Subject: Warning: Explicit integral could not be found.

From: Roger Stafford

Date: 4 Jul, 2011 02:08:10

Message: 4 of 11

"Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iup1om$qeb$1@newscl01ah.mathworks.com>...
> > > I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".
> > >
> > > (2*R^-9) + (A*R^-11) / ((A+R^2)^2)
> > >
> > > I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
> > > I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A
> > >
> Whats the way to solve these kind of integrals..??
> -Ashwin
- - - - - - - - - -
  Could you please show us exactly how you called on 'int'? Give all the details of how you defined the function 'fun'. To make 'int' work you need to have declared both R and A as symbolic objects with the 'syms' declaration. I have the feeling that your version of 'int' really should be able to give a solution to the function you have described if it is dealt with properly.

Roger Stafford

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 5 Jul, 2011 01:35:09

Message: 5 of 11

"Roger Stafford" wrote in message <iur7aa$b19$1@newscl01ah.mathworks.com>...
> "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iup1om$qeb$1@newscl01ah.mathworks.com>...
> > > > I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".
> > > >
> > > > (2*R^-9) + (A*R^-11) / ((A+R^2)^2)
> > > >
> > > > I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
> > > > I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A
> > > >
> > Whats the way to solve these kind of integrals..??
> > -Ashwin
> - - - - - - - - - -
> Could you please show us exactly how you called on 'int'? Give all the details of how you defined the function 'fun'. To make 'int' work you need to have declared both R and A as symbolic objects with the 'syms' declaration. I have the feeling that your version of 'int' really should be able to give a solution to the function you have described if it is dealt with properly.
------------------------------
Below is the exact code that I used.

>> syms A R
>> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]
 
Eqn1 =
 
(A/R^11 + 2/R^9)/(R^2 + A)^2
 
>> pretty(Eqn1)
 
   A 2
  --- + --
   11 9
  R R
  ---------
    2 2
  (R + A)
>> int(Eqn1,R,1,2)
Warning: Explicit integral could not be found.
 
ans =
 
piecewise([A = 1, log(64/25) - 8913/10240], [A <> 1, int(2/(R^9*(R^2 + A)^2), R = 1..2) + int(A/(R^11*(R^2 + A)^2), R = 1..2)])
 

Please correct me if I am wrong. I am still getting the same error. Even if I use A=B^2, its the same. Is there a way to address this integral.

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 5 Jul, 2011 02:39:11

Message: 6 of 11

"Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iutpod$rhd$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <iur7aa$b19$1@newscl01ah.mathworks.com>...
> > "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iup1om$qeb$1@newscl01ah.mathworks.com>...
> > > > > I need to Integrate the below function, but when I use the int(fun,R,1,2) command in Matlab it returns to me with an error saying "Explicit integral could not be found".
> > > > >
> > > > > (2*R^-9) + (A*R^-11) / ((A+R^2)^2)
> > > > >
> > > > > I am integrating over the limits [1,2] with respect to R and A is a constant. Could you please help and guide me through this problem. How do we obtain solutions to such Integrals using Matlab. I would come across many more similar integrals in my work which I would need to solve, so please guide me through the solution for these kind of problems.
> > > > > I need the answer for this integral to be in terms of constant A. So that further apply my conditions I could solve for A
> > > > >
> > > Whats the way to solve these kind of integrals..??
> > > -Ashwin
> > - - - - - - - - - -
> > Could you please show us exactly how you called on 'int'? Give all the details of how you defined the function 'fun'. To make 'int' work you need to have declared both R and A as symbolic objects with the 'syms' declaration. I have the feeling that your version of 'int' really should be able to give a solution to the function you have described if it is dealt with properly.
> ------------------------------
> Below is the exact code that I used.
>
> >> syms A R
> >> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]
>
> Eqn1 =
>
> (A/R^11 + 2/R^9)/(R^2 + A)^2
>
> >> pretty(Eqn1)
>
> A 2
> --- + --
> 11 9
> R R
> ---------
> 2 2
> (R + A)
> >> int(Eqn1,R,1,2)
> Warning: Explicit integral could not be found.
>
> ans =
>
> piecewise([A = 1, log(64/25) - 8913/10240], [A <> 1, int(2/(R^9*(R^2 + A)^2), R = 1..2) + int(A/(R^11*(R^2 + A)^2), R = 1..2)])
>
>
> Please correct me if I am wrong. I am still getting the same error. Even if I use A=B^2, its the same. Is there a way to address this integral.
------------------------------------
I also tried using the quad function in matlab.

below is my code:

function y = myfun(x)
syms A x
y = ((A*x^-11) + (2*x^-9)) / ((A + x^2)^2);
Q = quad(@myfun,1,2);

when i run the code I am getting the below error,

??? Maximum recursion limit of 500 reached. Use
set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available
stack space can
crash MATLAB and/or your computer.

Error in ==> sym.sym>convertChar

How do I address this ??

-Ashwin

Subject: Warning: Explicit integral could not be found.

From: Roger Stafford

Date: 5 Jul, 2011 04:57:10

Message: 7 of 11

"Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iuttgf$6tu$1@newscl01ah.mathworks.com>...
> "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iutpod$rhd$1@newscl01ah.mathworks.com>...
> > Below is the exact code that I used.
> > >> syms A R
> > >> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]
> > ......
> > >> int(Eqn1,R,1,2)
> > Warning: Explicit integral could not be found.
> I also tried using the quad function in matlab.
> below is my code:
>
> function y = myfun(x)
> syms A x
> y = ((A*x^-11) + (2*x^-9)) / ((A + x^2)^2);
> Q = quad(@myfun,1,2);
> .....
- - - - - - - - - - -
  I am curious as to why you used brackets in this expression:

>> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]

rather than parentheses, Brackets are the symbolic toolbox notation for symbolic matrices. They are not meant for grouping operands as with parentheses. Since these symbolic matrices (hopefully) have only one element it shouldn't make any difference, but I would advise you to try integrating again, replacing the brackets with parentheses, just to make sure. In any case it is not a good practice to use brackets in this manner.

  This expression is different from the one you originally gave at the beginning of this thread. That one was lacking both brackets and parentheses in the numerator, so that it constituted a different function. However I also tried symbolically integrating this new integrand on my (ancient) system and it again was able to solve it. The indefinite integral it found is:

3/2/A^5/R^2 - 1/2/A^4/R^4 + 1/6/A^3/R^6 - 1/10/A/R^10 ...
+ 1/2/A^5/(A+R^2) + 4/A^6*log(R) - 2/A^6*log(A+R^2)

and when differentiated with respect to R this gives back the original expression. You can easily use this to find the definite integral between 1 and 2 as a function of A.

  If replacing the brackets does not produce success, I would advise you to consult directly with the support people at Mathworks as to why it has failed. There should be no reason why an old system like mine could outdo new versions in this manner. After all, the above integration only involves very standard tricks with partial fractions that we all learned in elementary calculus and should be a breeze for your symbolic toolbox.

  As to using 'quad', this is a purely numerical quadrature function and cannot give an answer unless all parameters involved in the integrand are given specific numerical values. In particular it does not know how to handle the parameter A unless A has been given a definite numerical value.

  (The error message you received is spectacularly inappropriate as is often true with error messages. These come from a failure on the part of programmers to anticipate all the errors that users might make.)

  The symbolic toolbox is your only hope for obtaining general integral formulas in terms of symbolic parameters using matlab.

Roger Stafford

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 13 Jul, 2011 01:08:08

Message: 8 of 11

"Roger Stafford" wrote in message <iuu5j6$pjs$1@newscl01ah.mathworks.com>...
> "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iuttgf$6tu$1@newscl01ah.mathworks.com>...
> > "Ashwin Balaji" <ashwinb1@umbc.edu> wrote in message <iutpod$rhd$1@newscl01ah.mathworks.com>...
> > > Below is the exact code that I used.
> > > >> syms A R
> > > >> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]
> > > ......
> > > >> int(Eqn1,R,1,2)
> > > Warning: Explicit integral could not be found.
> > I also tried using the quad function in matlab.
> > below is my code:
> >
> > function y = myfun(x)
> > syms A x
> > y = ((A*x^-11) + (2*x^-9)) / ((A + x^2)^2);
> > Q = quad(@myfun,1,2);
> > .....
> - - - - - - - - - - -
> I am curious as to why you used brackets in this expression:
>
> >> Eqn1 = [(2*R^-9) + (A*R^-11)] / [((A+R^2)^2)]
>
> rather than parentheses, Brackets are the symbolic toolbox notation for symbolic matrices. They are not meant for grouping operands as with parentheses. Since these symbolic matrices (hopefully) have only one element it shouldn't make any difference, but I would advise you to try integrating again, replacing the brackets with parentheses, just to make sure. In any case it is not a good practice to use brackets in this manner.
>
> This expression is different from the one you originally gave at the beginning of this thread. That one was lacking both brackets and parentheses in the numerator, so that it constituted a different function. However I also tried symbolically integrating this new integrand on my (ancient) system and it again was able to solve it. The indefinite integral it found is:
>
> 3/2/A^5/R^2 - 1/2/A^4/R^4 + 1/6/A^3/R^6 - 1/10/A/R^10 ...
> + 1/2/A^5/(A+R^2) + 4/A^6*log(R) - 2/A^6*log(A+R^2)
>
> and when differentiated with respect to R this gives back the original expression. You can easily use this to find the definite integral between 1 and 2 as a function of A.
>
> If replacing the brackets does not produce success, I would advise you to consult directly with the support people at Mathworks as to why it has failed. There should be no reason why an old system like mine could outdo new versions in this manner. After all, the above integration only involves very standard tricks with partial fractions that we all learned in elementary calculus and should be a breeze for your symbolic toolbox.
>
> As to using 'quad', this is a purely numerical quadrature function and cannot give an answer unless all parameters involved in the integrand are given specific numerical values. In particular it does not know how to handle the parameter A unless A has been given a definite numerical value.
>
> (The error message you received is spectacularly inappropriate as is often true with error messages. These come from a failure on the part of programmers to anticipate all the errors that users might make.)
>
> The symbolic toolbox is your only hope for obtaining general integral formulas in terms of symbolic parameters using matlab.
>
> Roger Stafford
-----------------------------------------
Thanks Roger, it worked...!!Thanks very much.
-Ashwin

Subject: Warning: Explicit integral could not be found.

From: Christopher Creutzig

Date: 20 Jul, 2011 11:11:09

Message: 9 of 11

"Roger Stafford" wrote in message <iuogbp$fih$1@newscl01ah.mathworks.com>...
> Perhaps your version is more careful about that and wants more information about A before committing itself. If A is actually supposed to be positive, you might try using B^2 in place of A to see if that would remove its doubts since there is no chance that B^2+R^2 could be negative.

Since symbolic by default assumes it is working in the complex plane, that would not suffice. What does work, however, is explicitly assuming A to be positive:

>> syms A positive
>> syms R
>> int((2*R^-9) + (A*R^-11) / ((A+R^2)^2), R, 1, 2)
 
ans =
 
255/1024 - (12*log(A + 1) - 12*log(A + 4) + 24*log(2) + A^2*(3*log(A + 1) - 3*log(A + 4) + 6*log(2) - 45/8) + (27*A^3)/32 - (135*A^4)/256 + (1809*A^5)/5120 - (513*A^6)/2048 - (1023*A^7)/10240 + A*(15*log(A + 1) - 15*log(A + 4) + 30*log(2) - 9))/(A^6*(A^2 + 5*A + 4))

>> int(((2*R^-9) + (A*R^-11)) / ((A+R^2)^2), R, 1, 2)
 
ans =
 
(8*log(A + 1) - 8*log(A + 4) + 16*log(2) + A^2*(2*log(A + 1) - 2*log(A + 4) + 4*log(2) - 15/4) + (9*A^3)/16 - (45*A^4)/128 + (603*A^5)/2560 + (1023*A^6)/2048 + (1023*A^7)/10240 + A*(10*log(A + 1) - 10*log(A + 4) + 20*log(2) - 6))/(A^6*(A^2 + 5*A + 4))


Christopher

Subject: Warning: Explicit integral could not be found.

From: Ashwin Balaji

Date: 22 Sep, 2011 19:27:28

Message: 10 of 11

"Christopher Creutzig" <christopher.creutzig@mathworks.de> wrote in message <j06d4d$o44$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <iuogbp$fih$1@newscl01ah.mathworks.com>...
> > Perhaps your version is more careful about that and wants more information about A before committing itself. If A is actually supposed to be positive, you might try using B^2 in place of A to see if that would remove its doubts since there is no chance that B^2+R^2 could be negative.
>
> Since symbolic by default assumes it is working in the complex plane, that would not suffice. What does work, however, is explicitly assuming A to be positive:
>
> >> syms A positive
> >> syms R
> >> int((2*R^-9) + (A*R^-11) / ((A+R^2)^2), R, 1, 2)
>
> ans =
>
> 255/1024 - (12*log(A + 1) - 12*log(A + 4) + 24*log(2) + A^2*(3*log(A + 1) - 3*log(A + 4) + 6*log(2) - 45/8) + (27*A^3)/32 - (135*A^4)/256 + (1809*A^5)/5120 - (513*A^6)/2048 - (1023*A^7)/10240 + A*(15*log(A + 1) - 15*log(A + 4) + 30*log(2) - 9))/(A^6*(A^2 + 5*A + 4))
>
> >> int(((2*R^-9) + (A*R^-11)) / ((A+R^2)^2), R, 1, 2)
>
> ans =
>
> (8*log(A + 1) - 8*log(A + 4) + 16*log(2) + A^2*(2*log(A + 1) - 2*log(A + 4) + 4*log(2) - 15/4) + (9*A^3)/16 - (45*A^4)/128 + (603*A^5)/2560 + (1023*A^6)/2048 + (1023*A^7)/10240 + A*(10*log(A + 1) - 10*log(A + 4) + 20*log(2) - 6))/(A^6*(A^2 + 5*A + 4))
>
>
> Christopher
---------------------------------------------------------------------------------------------------------
Hello All,

Thanks for all your valuable inputs and help last time when I was facing this error, I was able to resolve this then and get ahead. But now I am faced with a similar problem with an different integral. Below is my code

>> syms A positive
>> syms m r
>> Eqn1=((((r^(2)-A)^((m-2)/2))*(2*r^(2)-A))/(r^(3)))
Eqn1 =
-((r^2 - A)^(m/2 - 1)*(A - 2*r^2))/r^3
>> pretty(Eqn1)
 
            m
            - - 1
            2
      2 2
    (r - A) (A - 2 r )
  - ------------------------
                3
               r
>> int(Eqn1,r)
Warning: Explicit integral could not be found.
ans =
int(-((r^2 - A)^(m/2 - 1)*(A - 2*r^2))/r^3, r)

And I am again getting an same error.

Could anyone answer me on this. I need to figure this out at the earliest

Thanks,
-Ashwin

Subject: Warning: Explicit integral could not be found.

From: Christopher Creutzig

Date: 27 Sep, 2011 08:37:24

Message: 11 of 11

On 22.09.11 21:27, Ashwin Balaji wrote:

>>> syms A positive
>>> syms m r
>>> Eqn1=((((r^(2)-A)^((m-2)/2))*(2*r^(2)-A))/(r^(3)))
> Eqn1 =
> -((r^2 - A)^(m/2 - 1)*(A - 2*r^2))/r^3
>>> pretty(Eqn1)
>
> m
> - - 1
> 2
> 2 2
> (r - A) (A - 2 r )
> - ------------------------
> 3
> r
>>> int(Eqn1,r)
> Warning: Explicit integral could not be found.
> ans =
> int(-((r^2 - A)^(m/2 - 1)*(A - 2*r^2))/r^3, r)
>
> And I am again getting an same error.

It is quite possible that there is simply no symbolic closed form
integral of this expression. Or maybe there is one involving a sum up to
m, with different formulas for m odd and even, but the symbolic engine
just can't find it – notice you didn't tell it that m was integer, or
positive, or even real, although in this case, nothing of that helps.

You may still be able to guess a formula from looking at special cases:

>> pretty(int(subs(Eqn1, 'm', 1), r))

         / 2 1/2 \
         | (r - A) |
   3 atan| ----------- |
         | 1/2 | 2 1/2
         \ A / (r - A)
   --------------------- - -----------
             1/2 2
          2 A 2 r
>> pretty(int(subs(Eqn1, 'm', 3), r))

                                                                     /
 2 1/2 \
                                                             1/2 |
(r - A) |
                                                            A atan|
----------- |
                                / 2 1/2 1/2 \ |
   1/2 | 2 1/2
       2 1/2 1/2 | (r - A) + (-A) | \
  A / A (r - A)
   2 (r - A) - 2 (-A) log| --------------------- | -
------------------------ + -------------
                                \ r / 2
                     2

                   2 r
>> pretty(int(subs(Eqn1, 'm', 5), r))

                              / 2 1/2 \
                      3/2 | (r - A) |
                   7 A atan| ----------- |
       2 3/2 | 1/2 | 2 2
    1/2
   2 (r - A) \ A / 2 1/2 A (r
 - A)
   ------------- + -------------------------- - 3 A (r - A) -
--------------
         3 2 2
                                                                       2 r
>> pretty(int(subs(Eqn1, 'm', 7), r))

                                                 / 2 1/2 \
                                         5/2 | (r - A) |
                                      9 A atan| ----------- |
                          2 5/2 | 1/2 |
            3 2 1/2
      2 2 1/2 2 (r - A) \ A / 2
    3/2 A (r - A)
   4 A (r - A) + ------------- - -------------------------- - A (r
 - A) + --------------
                            5 2
                   2

                2 r

E.g., the atan term does not change, which is not really surprising, and
seems to receive a pretty predictable factor, which probably can be
shown by integration by parts. If you have a guess for the integral
formula, you can use diff and simplify etc. to validate or reject it.


Christopher

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