Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!a21g2000prj.googlegroups.com!not-for-mail
From: tzygmund <tzygmund@googlemail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: quad error
Date: Wed, 20 Apr 2011 06:01:58 -0700 (PDT)
Organization: http://groups.google.com
Lines: 37
Message-ID: <08a764a6-e15f-4e26-90ef-57d723e4af7b@a21g2000prj.googlegroups.com>
References: <2d350472-226f-4122-8c33-4ed7b7ee5ddc@t19g2000prd.googlegroups.com>
 <iol57d$1sj$1@fred.mathworks.com>
NNTP-Posting-Host: 128.54.250.224
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1303304518 4454 127.0.0.1 (20 Apr 2011 13:01:58 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 20 Apr 2011 13:01:58 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a21g2000prj.googlegroups.com; posting-host=128.54.250.224; posting-account=d0ZnjAoAAACoBOGGXQZyBG9_Cp9X6UEf
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16)
 Gecko/20110319 Firefox/3.6.16,gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:722913


Thanks Roger and Steven for excellent suggestions.


On Apr 19, 4:18 pm, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> tzygmund <tzygm...@googlemail.com> wrote in message <2d350472-226f-4122-8c33-4ed7b7ee5...@t19g2000prd.googlegroups.com>...
> > ........
> > I have a simple function to numerically integrate and it depends on
> > the scalar 't':
>
> > %%%%%%%%%%%%%%%%%
> > function omegafun = omegafun(mM1, t)
> >  omegafun =  sqrt(det(eye(size(mM1, 1)) -2*t.*mM1))
> > end
> > %%%%%%%%%%%%%%%%%
> > .......
>
> - - - - - - - - - -
>   Your integrand is the square root of a polynomial in t that can be expressed in terms of the eigenvalues of nM1.  You can use this fact to allow t to be accepted as a vector.
>
> [D,T] = ndgrid(eig(nM1),t);
> omega = sqrt(prod(1-2*T.*D,1));
>
> The above will accept the argument t as a vector.  (Write your function so it accepts the eigenvalues of nM1 as input rather than nM1 itself to keep from repeatedly computing the same eigenvalues.)
>
>   (It is to be hoped that the range of t will keep the above product always non-negative to avoid imaginary values for the square root.  I am not sure 'quad' would handle them properly.)
>
> Roger Stafford