MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Thread Subject: integral function f(x,y) has singularity ?

 Subject: integral function f(x,y) has singularity ? From: mathslife Date: 8 Nov, 2011 04:36:14 Message: 1 of 7 hi, i am working on a program about collocation method and i need to find \int_{0}^{2+pi} 1/cos(x+y)dy i would like to use guad function. for the collocation point we have x_k=2*pi*i*k/(2*n+1)  i wrote a program for it like  m=@(y) 1./ cos(x(k+n+1)+y);                                  T=quad(m,0,2*pi); and of course it is giving singularity error but i dont know how to handle it... I tired to discretize y like x but i got the same error again..can someone help me?
 Subject: integral function f(x,y) has singularity ? From: Roger Stafford Date: 8 Nov, 2011 06:12:13 Message: 2 of 7 "mathslife " wrote in message ... > i am working on a program about collocation method and i need to find > \int_{0}^{2+pi} 1/cos(x+y)dy - - - - - - - - -   Over the range where cos(x+y) is positive, an indefinite integral for your function would be:  log((1+sin(x+y))/cos(x+y)) + C For cos(x+y) negative it will be: log(-(1+sin(x+y))/cos(x+y)) + C Either form produces infinite values whenever the cosine denominator approaches zero, which means that your function is not integrable over the range you specify. There are infinite areas occurring between your curve and the zero level.   You need to express your problem in some other way to get a meaningful answer. There is no way of "handling it" in the integral form you have it in here. Even if (by some miracle) your integrand were integrable over the y-range from 0 to 2*pi it would be independent of the value of x since cos(x+y) is periodic with a 2*pi period. This strongly suggests that there is something seriously amiss in your formulation of the problem. Roger Stafford
 Subject: integral function f(x,y) has singularity ? From: Bruno Luong Date: 8 Nov, 2011 07:29:10 Message: 3 of 7 "mathslife " wrote in message ... > hi, > i am working on a program about collocation method and i need to find > \int_{0}^{2+pi} 1/cos(x+y)dy > i would like to use guad function. for the collocation point we have x_k=2*pi*i*k/(2*n+1) > i wrote a program for it like > > m=@(y) 1./ cos(x(k+n+1)+y); > > T=quad(m,0,2*pi); > It looks like you are building the matrix of integral equation. The matrix is a limits when the singularity converges towards the collocation points, and not taken the integral when the singularity is AT the collocation which - in some case such as double layer potential - gives a meaningless answer as Roger pointed out. This limit is called "jump relation" and you can find the close form expression in many books. No need to compute limit of the integral numerically. Bruno
 Subject: integral function f(x,y) has singularity ? From: Christopher Creutzig Date: 8 Nov, 2011 13:08:00 Message: 4 of 7 On 08.11.11 05:36, mathslife wrote: > hi, > i am working on a program about collocation method and i need to find > \int_{0}^{2+pi} 1/cos(x+y)dy > i would like to use guad function. for the collocation point we have x_k=2*pi*i*k/(2*n+1) > i wrote a program for it like > > m=@(y) 1./ cos(x(k+n+1)+y); > > T=quad(m,0,2*pi); > > and of course it is giving singularity error but i dont know how to handle it... First, you should check carefully what you expect as the result of the integration, i.e., why you wish to take the integral in the first place. As long as x is real, you have two poles of order 1 in your interval, so the integral diverges. It is possible to regard the Cauchy principal value, but that is obviously 0. (Also, it should be obvious that the integral is independent of the real part of x.) Christopher
 Subject: integral function f(x,y) has singularity ? From: mathslife Date: 8 Nov, 2011 15:50:14 Message: 5 of 7 Christopher Creutzig wrote in message <4EB929B0.5000103@mathworks.com>... > On 08.11.11 05:36, mathslife wrote: > > hi, > > i am working on a program about collocation method and i need to find > > \int_{0}^{2+pi} 1/cos(x+y)dy > > i would like to use guad function. for the collocation point we have x_k=2*pi*i*k/(2*n+1) > > i wrote a program for it like > > > > m=@(y) 1./ cos(x(k+n+1)+y); > > > > T=quad(m,0,2*pi); > > > > and of course it is giving singularity error but i dont know how to handle it... > > First, you should check carefully what you expect as the result of the > integration, i.e., why you wish to take the integral in the first place. > As long as x is real, you have two poles of order 1 in your interval, so > the integral diverges. It is possible to regard the Cauchy principal > value, but that is obviously 0. (Also, it should be obvious that the > integral is independent of the real part of x.) > > > > Christopher Thanks alot, maybe i need to explain a bit more, subject is collocation method for second kind.there is a problem i need to implement , and point are x(k)=2*pi*i*k/(2*pi+1). it is like ( I +\int e^(i*y) / (5+3*cos(x+y)) dy )F(x)=g(x) i need to get this integral from the interval 0 to 2*pi, i think i should do this integration only for this point maybe i should do it like quad(m,x(k),x(k+1))
 Subject: integral function f(x,y) has singularity ? From: Bruno Luong Date: 8 Nov, 2011 19:13:11 Message: 6 of 7 "mathslife " wrote in message ... > Christopher Creutzig wrote in message <4EB929B0.5000103@mathworks.com>... > > On 08.11.11 05:36, mathslife wrote: > > > hi, > > > i am working on a program about collocation method and i need to find > > > \int_{0}^{2+pi} 1/cos(x+y)dy > > > i would like to use guad function. for the collocation point we have x_k=2*pi*i*k/(2*n+1) > > > i wrote a program for it like > > > > > > m=@(y) 1./ cos(x(k+n+1)+y); > > > > > > T=quad(m,0,2*pi); > > > > > > and of course it is giving singularity error but i dont know how to handle it... > > > > First, you should check carefully what you expect as the result of the > > integration, i.e., why you wish to take the integral in the first place. > > As long as x is real, you have two poles of order 1 in your interval, so > > the integral diverges. It is possible to regard the Cauchy principal > > value, but that is obviously 0. (Also, it should be obvious that the > > integral is independent of the real part of x.) > > > > > > > > Christopher > Thanks alot, maybe i need to explain a bit more, subject is collocation method for second kind.there is a problem i need to implement , and point are x(k)=2*pi*i*k/(2*pi+1). > it is like ( I +\int e^(i*y) / (5+3*cos(x+y)) dy )F(x)=g(x) > > i need to get this integral from the interval 0 to 2*pi, > i think i should do this integration only for this point maybe i should do it like quad(m,x(k),x(k+1)) In the integral equation of the second kind - usually derived from a double-layer potential as I stated above - the integral is a *limit*, i.e., sometime called "a principal integral value". It seems you want to compute the integral, which is incorrect formulation (which translate by the singularity we have pointed out to you). Bruno
 Subject: integral function f(x,y) has singularity ? From: Christopher Creutzig Date: 9 Nov, 2011 12:39:59 Message: 7 of 7 On 08.11.11 16:50, mathslife wrote: > Christopher Creutzig wrote in message <4EB929B0.5000103@mathworks.com>... >> On 08.11.11 05:36, mathslife wrote: >> > i wrote a program for it like >> > >> > m=@(y) 1./ cos(x(k+n+1)+y); >> > >> > T=quad(m,0,2*pi); > Thanks alot, maybe i need to explain a bit more, subject is collocation method for second kind.there is a problem i need to implement , and point are x(k)=2*pi*i*k/(2*pi+1). > it is like ( I +\int e^(i*y) / (5+3*cos(x+y)) dy )F(x)=g(x) That's a completely different problem, though. You should not run into singularity errors for this one. (I have no idea about “collocation methods” and can't comment on whether you really want to compute an approximation to this integral.) 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.