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:
int in R2008b, same integral?

Subject: int in R2008b, same integral?

From: Joerg Buchholz

Date: 12 Dec, 2008 22:10:17

Message: 1 of 7

Is there a mathematical reason, why R2008b can solve:

>> int ('1/sqrt(1-x^2)')
 
ans =
 
asin(x)

but cannot solve:

>> int ('sqrt(1/(1-x^2))')
Warning: Explicit integral could not be found.
> In sym.int at 64
  In char.int at 9
 
ans =
 
int((-1/(x^2 - 1))^(1/2), x)

Is there a way to make R2008b simplify 'sqrt(1/(1-x^2))' to '1/sqrt(1-x^2)'?

Subject: int in R2008b, same integral?

From: Georgios

Date: 13 Dec, 2008 01:17:02

Message: 2 of 7

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <ghung9$3as$1@fred.mathworks.com>...
> Is there a mathematical reason, why R2008b can solve:
>
> >> int ('1/sqrt(1-x^2)')
>
> ans =
>
> asin(x)
>
> but cannot solve:
>
> >> int ('sqrt(1/(1-x^2))')
> Warning: Explicit integral could not be found.
> > In sym.int at 64
> In char.int at 9
>
> ans =
>
> int((-1/(x^2 - 1))^(1/2), x)
>
> Is there a way to make R2008b simplify 'sqrt(1/(1-x^2))' to '1/sqrt(1-x^2)'?

No. These are equivalent only over the range -1..1. Outside of that range they are not equivalent, that is why you get a closed form answer for the first integral and not for the second. Without integrating, try plugging in some numbers greater that 1 into both functions, and see what happens. For example, using a value of x=1.3333, the first function yields -1.133899898*I while the second one yields 1.133899899*I. If you integrate using a bounded range, say -1..1, then you should get an answer of pi for both. Once the range goes beyond this, the answers will differ with a sign change with respect to the imaginary variable.

Regards,
Georgios

Subject: int in R2008b, same integral?

From: Roger Stafford

Date: 13 Dec, 2008 02:11:05

Message: 3 of 7

"Georgios" <gkokovid@yahoo.com> wrote in message <ghv2ee$h15$1@fred.mathworks.com>...
> "Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <ghung9$3as$1@fred.mathworks.com>...
> > .......
> > Is there a way to make R2008b simplify 'sqrt(1/(1-x^2))' to '1/sqrt(1-x^2)'?
>
> No. These are equivalent only over the range -1..1. Outside of that range they are not equivalent, that is why you get a closed form answer for the first integral and not for the second. Without integrating, try plugging in some numbers greater that 1 into both functions, and see what happens. For example, using a value of x=1.3333, the first function yields -1.133899898*I while the second one yields 1.133899899*I. If you integrate using a bounded range, say -1..1, then you should get an answer of pi for both. Once the range goes beyond this, the answers will differ with a sign change with respect to the imaginary variable.
>
> Regards,
> Georgios

  Well, that might be a reason, but in my opinion it's not a very good reason. The square root function in the complex plane has two branches. If one integrates half way around the singularity at z = 1 in a semi-circle, a different answer is obtained for a counterclockwise route than a clockwise one. However, that is no reason for 'int' to misbehave itself for z restricted to the real interval (-1,+1). The log(z) function has infinitely many branches about its z = 0 singularity but that would be no reason for 'int' to fail to furnish accurate answers for z restricted to positive reals.

Roger Stafford

Subject: int in R2008b, same integral?

From: Georgios

Date: 13 Dec, 2008 05:21:02

Message: 4 of 7

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <ghv5jp$71n$1@fred.mathworks.com>...
> "Georgios" <gkokovid@yahoo.com> wrote in message <ghv2ee$h15$1@fred.mathworks.com>...
> > "Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <ghung9$3as$1@fred.mathworks.com>...
> > > .......
> > > Is there a way to make R2008b simplify 'sqrt(1/(1-x^2))' to '1/sqrt(1-x^2)'?
> >
> > No. These are equivalent only over the range -1..1. Outside of that range they are not equivalent, that is why you get a closed form answer for the first integral and not for the second. Without integrating, try plugging in some numbers greater that 1 into both functions, and see what happens. For example, using a value of x=1.3333, the first function yields -1.133899898*I while the second one yields 1.133899899*I. If you integrate using a bounded range, say -1..1, then you should get an answer of pi for both. Once the range goes beyond this, the answers will differ with a sign change with respect to the imaginary variable.
> >
> > Regards,
> > Georgios
>
> Well, that might be a reason, but in my opinion it's not a very good reason. The square root function in the complex plane has two branches. If one integrates half way around the singularity at z = 1 in a semi-circle, a different answer is obtained for a counterclockwise route than a clockwise one. However, that is no reason for 'int' to misbehave itself for z restricted to the real interval (-1,+1). The log(z) function has infinitely many branches about its z = 0 singularity but that would be no reason for 'int' to fail to furnish accurate answers for z restricted to positive reals.
>
> Roger Stafford

Some symbolic engines handle branch cuts better than others. I'm assuming that R2008b is using MuPad for this. I tried the above in native Maple, and got the same result; i.e. the answers were not the same. But Maxima returns arcsin(x) for both functions. I have no way of evaluating this in Matlab because I do not use the symbolic toolbox.

Regards,
Georgios

Subject: int in R2008b, same integral?

From: Joerg Buchholz

Date: 13 Dec, 2008 12:46:02

Message: 5 of 7

"Georgios"
> If you integrate using a bounded range, say -1..1, then you should get an answer of pi for both.


Unfortunately, this is not the case:

>> int ('sqrt(1/(1-x^2))', -1, 1)
Warning: Explicit integral could not be found.
> In sym.int at 64
  In char.int at 9
 
ans =
 
int((-1/(x^2 - 1))^(1/2), x = -1..1)

Even explicitely restricting the range of x does not help:

>> evalin (symengine, 'assume (x<1)');
>> evalin (symengine, 'assumeAlso (x>-1)');
>> evalin (symengine, 'getprop(x)')
 
ans =
 
(-1, 1)
 
>> int ('sqrt(1/(1-x^2))', -1, 1)
Warning: Explicit integral could not be found.
> In sym.int at 64
  In char.int at 9
 
ans =
 
int((-1/(x^2 - 1))^(1/2), x = -1..1)

Subject: int in R2008b, same integral?

From: Joerg Buchholz

Date: 15 Jan, 2009 15:52:01

Message: 6 of 7

The bug has not been fixed in R2009a.

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <gi0aqa$e0u$1@fred.mathworks.com>...
> "Georgios"
> > If you integrate using a bounded range, say -1..1, then you should get an answer of pi for both.
>
>
> Unfortunately, this is not the case:
>
> >> int ('sqrt(1/(1-x^2))', -1, 1)
> Warning: Explicit integral could not be found.
> > In sym.int at 64
> In char.int at 9
>
> ans =
>
> int((-1/(x^2 - 1))^(1/2), x = -1..1)
>
> Even explicitely restricting the range of x does not help:
>
> >> evalin (symengine, 'assume (x<1)');
> >> evalin (symengine, 'assumeAlso (x>-1)');
> >> evalin (symengine, 'getprop(x)')
>
> ans =
>
> (-1, 1)
>
> >> int ('sqrt(1/(1-x^2))', -1, 1)
> Warning: Explicit integral could not be found.
> > In sym.int at 64
> In char.int at 9
>
> ans =
>
> int((-1/(x^2 - 1))^(1/2), x = -1..1)

Subject: int in R2008b, same integral?

From: Christopher Creutzig

Date: 16 Feb, 2009 10:24:01

Message: 7 of 7

"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <gknm31$sf6$1@fred.mathworks.com>...
> The bug has not been fixed in R2009a.

 Correction: The enhancement is not in the 2009a prerelease. Please check again when the final release is available.


Christopher

Tags for 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