Path: news.mathworks.com!newsfeed-00.mathworks.com!nlpi057.nbdc.sbc.com!prodigy.net!news.glorb.com!news2!postnews.google.com!v15g2000yqn.googlegroups.com!not-for-mail
From: Peter <petersamsimon2@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to integration a polynomial on a polygon?
Date: Mon, 22 Dec 2008 12:26:05 -0800 (PST)
Organization: http://groups.google.com
Lines: 50
Message-ID: <7a94aa85-bcb0-440c-a75c-491783014dbd@v15g2000yqn.googlegroups.com>
References: <gikgkj$4qp$1@fred.mathworks.com> <gikgtu$mfv$1@fred.mathworks.com> 
	<bb03a633-a402-444a-aed7-00ca729eba07@s16g2000vbp.googlegroups.com> 
	<gini8e$3mn$1@fred.mathworks.com> <giooii$pf5$1@fred.mathworks.com>
NNTP-Posting-Host: 75.4.248.244
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1229977565 3926 127.0.0.1 (22 Dec 2008 20:26:05 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 22 Dec 2008 20:26:05 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: v15g2000yqn.googlegroups.com; posting-host=75.4.248.244; 
	posting-account=SC1WwgkAAABiObOlxxQD3J1U2fKBEJiV
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) 
	Gecko/2008120122 Firefox/3.0.5,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:508415

On Dec 22, 11:08=A0am, "Roger Stafford"
<ellieandrogerxy...@mindspring.com.invalid> wrote:
> "Roger Stafford" <ellieandrogerxy...@mindspring.com.invalid> wrote in mes=
sage >
> > .....
> > =A0int('y^2*((x1*y2-x2*y1+(x2-x1)*y)/(y2-y1))^4/4','y')
> > .....
>
> =A0 Peter, when I wrote that expression for the line integral of Q(x,y) =
=3D x^4*y^2/4 from (x1,y1) to (x2,y2) I had in mind still obtaining a close=
d expression in terms of these points' coordinates for use in an exact summ=
ation. =A0As a problem in numerical integration that would not be the right=
 way to proceed. =A0For example, it would blow up if y1 were equal to y2. =
=A0It would be better to write something like this:
>
> =A0int('Q(x,y)*sin(a12)','s',0,'s12')
>
> for integration along each segment where s is the length along the segmen=
t with
>
> =A0s12 =3D sqrt((x2-x1)^2+(y2-y1)^2)
> =A0a12 =3D atan2(y2-y1,x2-x1)H
> =A0x =3D x1 + s*cos(a12)
> =A0y =3D y1 + s*sin(a12)
> =A0dy =3D sin(a12)*ds
>
> =A0 An analogous numerical line integration procedure exists for polynomi=
als by computing their area integrals in terms of polygon segments projecte=
d triangularly to the origin. =A0As in the case of your Q(x,y), the result =
of the first integration along the projecting lines to the origin is an eas=
ily-found explicit expression. =A0The second integration along the polygona=
l line segments at the far end of these triangles could then be done numeri=
cally.
>
> Roger Stafford

Hi, Roger.

I understood the original question to be asking for a numerical
evaluation of the integral, not a closed-form symbolic solution.  The
Q polynomial coefficients could be calculated automatically by the
user's own code (no toolbox required), and their contributions along
each edge would be summed numerically inside of a loop over the edges,
again without requiring any external toolbox.  Certainly things get a
lot more complicated if you want an explicit formula derived in terms
of the polygon vertex locations.  I guess I was misleading when I
referred to the "formulas", by which I meant the formulas (finite
sums) needed for obtaining a numerical result.

--Peter