Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!postnews.google.com!p16g2000yqj.googlegroups.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Double Integral Singularities quad2d
Date: Tue, 25 Oct 2011 03:51:47 -0700 (PDT)
Organization: http://groups.google.com
Lines: 153
Message-ID: <d15f286c-7e52-4d35-8bad-9d77923e72a0@p16g2000yqj.googlegroups.com>
References: <j838vr$9nu$1@newscl01ah.mathworks.com> <41a15ffe-e999-41b9-8261-bd74f589cb23@l12g2000vby.googlegroups.com>
 <272cde32-3068-4756-baba-6252dcd80cbd@c1g2000vbw.googlegroups.com> <j85u6k$8ue$1@newscl01ah.mathworks.com>
NNTP-Posting-Host: 192.102.151.35
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1319540002 18099 127.0.0.1 (25 Oct 2011 10:53:22 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 25 Oct 2011 10:53:22 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: p16g2000yqj.googlegroups.com; posting-host=192.102.151.35; posting-account=X3eThQoAAACh5vOSip_rNRzKAq7k0jPW
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ARLUEHNKC
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;
 Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR
 3.0.04506.648; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:747078

On 25 Okt., 11:06, "S " <simaher2...@yahoo.co.uk> wrote:
> Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <272cde32-3068-4756-baba-6252dcd80...@c1g2000vbw.googlegroups.com>...
> > On 24 Okt., 17:18, "S " <simaher2...@yahoo.co.uk> wrote:
> > > Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <36eea4f4-4887-4557-8c14-744e0c5bb...@q13g2000vbd.googlegroups.com>...
> > > > On 24 Okt., 11:51, "S " <simaher2...@yahoo.co.uk> wrote:
> > > > > Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <db464627-33b0-456e-907c-47f521590...@f36g2000vbm.googlegroups.com>...
> > > > > > On 24 Okt., 11:24, "S " <simaher2...@yahoo.co.uk> wrote:
> > > > > > > Torsten <Torsten.Hen...@umsicht.fraunhofer.de> wrote in message <41a15ffe-e999-41b9-8261-bd74f589c...@l12g2000vby.googlegroups.com>...
> > > > > > > > On 24 Okt., 10:52, "S " <simaher2...@yahoo.co.uk> wrote:
> > > > > > > > > Hi,
>
> > > > > > > > > I have a problem in solving the double integral below in matlab.
>
> > > > > > > > > As I increase f and g to larger values then matlab complains of singularity and unsuccessful integration.
>
> > > > > > > > > 3 - 2*cos(y).*cos(f*x+g*y) - cos((f-1)*x + g*y)  ./  4 - 2*cos(y).*(cos(y) + cos(x)) dxdy
>
> > > > > > > > > Over limits -pi to pi for x and -pi to pi for y.
>
> > > > > > > > > I have been using:
> > > > > > > > > quad2d(@(x,y)my_func(x,y,f,g),-pi,pi,-pi,pi)
>
> > > > > > > > > Can anyone please help? How can I overcome this problem as I would like to integrate this function for various 'f' and 'g' up to ~2000.
>
> > > > > > > > > Thanks!
>
> > > > > > > > Since the period of your function becomes smaller and smaller with
> > > > > > > > increasing values for f and g,
> > > > > > > > you should integrate it analytically with the help of MATLAB's int.
>
> > > > > > > > Best wishes
> > > > > > > > Torsten.
>
> > > > > > > Hi Torsten,
>
> > > > > > > Thanks for your reply.
>
> > > > > > > I take your point but I would like to integrate this numerically. Ideally, I would like to compute the integral for various f and g.
>
> > > > > > > Any ideas how I can do this?- Zitierten Text ausblenden -
>
> > > > > > > - Zitierten Text anzeigen -
>
> > > > > > Can you prescribe an initial x- and y-grid for MATLAB's quad2d ?
> > > > > > If so, choose the increment in x and y very small to ensure that your
> > > > > > highly oscillating function
> > > > > > is sufficiently resolved.
> > > > > > To get an impression of your function, you should plot it for high
> > > > > > values of f and g.
> > > > > > Do you see now why quad2d has difficulties to integrate it
> > > > > > numerically ?
>
> > > > > > I repeat: Integrate your function _analytically_ using MATLAB's 'int'.
>
> > > > > > Best wishes
> > > > > > Torsten.
>
> > > > > Thanks for your reply and so fast.
>
> > > > > However, I do not have the symbolic toolbox installed :-(
>
> > > > > Surely there must be another way?- Zitierten Text ausblenden -
>
> > > > > - Zitierten Text anzeigen -
>
> > > > Using
> > > >http://integrals.wolfram.com
> > > > ,I get
> > > > 8*Pi^2 + sin(Pi*f)*sin(Pi*g)*(1/(g*(f-1)) + 8*g/(f*(1-g^2)))
> > > > for your integral.
> > > > But you should double-check the result.
>
> > > > Best wishes
> > > > Torsten.
>
> > > Thanks for reply.
>
> > > @ Torsten. Very good website btw. However, the website is unable to integrate the function.- Zitierten Text ausblenden -
>
> > > - Zitierten Text anzeigen -
>
> > Use the website as follows:
> > First integrate your function with respect to x by treating y as
> > constant:
> > int(3) = 3*x
> > int(- 2*cos(y)*cos(f*x+g*y))=-2*cos(y)*1/f*sin(f*x+g*y)
> > int(- cos((f-1)*x + g*y)  ./  4 ) = -1/(f-1)*sin((f-1)*x + g*y)/4
> > int(- 2*cos(y).*(cos(y))=-2*x*cos^2(y)
> > int(- 2*cos(y).*cos(x)) = -2*cos(y)*sin(x)
> > Thus
> > int(3 - 2*cos(y).*cos(f*x+g*y) - cos((f-1)*x + g*y)  ./  4 -
> > 2*cos(y).*(cos(y) + cos(x)) dx) =
> > 3*x-2*cos(y)*1/f*sin(f*x+g*y)-1/(f-1)*sin((f-1)*x + g*y)/
> > 4-2*x*cos^2(y)-2*cos(y)*sin(x)
> > Evaluate in the limits between -pi and pi:
> > 3*pi-2*cos(y)*1/f*sin(f*pi+g*y)-1/(f-1)*sin((f-1)*pi + g*y)/
> > 4-2*pi*cos^2(y) -
> > ( 3*(-pi)-2*cos(y)*1/f*sin(-f*pi+g*y)-1/(f-1)*sin(-(f-1)*pi + g*y)/
> > 4-2*(-pi)*cos^2(y)) =
> > 6*pi-2*cos(y)*1/f*(sin(f*pi+g*y)-sin(-f*pi+g*y))-0.25/
> > (f-1)*(sin((f-1)*pi + g*y)-sin(-(f-1)*pi + g*y))-4*pi*cos^2(y)
> > Now use the
> >http://integrals.wolfram.com
> > to integrate this expression term by term.
> > (Of course you have to substitute the y in the expressions by an x
> > because the wolfram-integrator assumes
> > the functions to integrate to depend on the variable x).
> > Subsequently evaluate in the limits between -pi and pi.
>
> > The cases in which f=0 and |g|=1 may be treated seperately.
>
> > Best wishes
> > Torsten.
>
> Im really sorry. I see where some of my misgivings have coome from.
>
> In my initial post I forgot to include the brackets around the denominator. The function is:
> (3 - 2*cos(y).*cos(f*x+g*y) - cos((f-1)*x + g*y))  ./  (4 - 2*cos(y).*(cos(y) + cos(x))) dxdy
>
> Really sorry about that.- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -

Then - as a further difficulty - you will have problems with the
points where your
denominator gets zero, e.g. (0,0) or (pi,pi) (where (pi,pi) is more
critical than
(0,0) because the numerator usually is different from 0 there).
This might explain the error message of quad2d (if you entered the
function
correctly in the MATLAB-file).

Best wishes
Torsten.