From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Integrating f(x,y) on a certain line in XY plane
Date: Mon, 9 May 2011 20:39:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 29
Message-ID: <iq9jd9$po9$>
References: <iq5tkg$j6e$> <iq5vo1$nch$> <iq6390$17d$> <iq6t1h$ocu$> <iq704t$1av$> <iq740k$9e4$> <iq7900$jj3$> <iq7sns$1j5$> <iq8oeq$5tv$> <iq9dhr$9bb$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1304973545 26377 (9 May 2011 20:39:05 GMT)
NNTP-Posting-Date: Mon, 9 May 2011 20:39:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:725928

"Roger Stafford" wrote in message <iq9dhr$9bb$>...
>   I didn't say you could reduce your expression to log((XM-X).^2).  What I said was that it could be reduced to the form log(x^2+a^2)) which is a very different entity.
> .........
- - - - - - - - -
  Mohamed, the explanation I gave you earlier could have been made much more intuitively evident.  Hopefully the following is an improvement.

  You start with log(sqrt((X-XM)^2+(Y-YM)^2)) to be integrated along some straight line extending from (X1,Y1) to (X2,Y2).  The quantity within the logarithm is the distance from a point (X,Y), which is moving along this line segment, to the point (XM,YM).  Now find the closest point (X0,Y0) along the extended line to the point (XM,YM).  The three points (X,Y), (XM,YM), and (X0,Y0) will form a right triangle, so by the theorem of Pythagoras we have

 (X-XM)^2+(Y-YM)^2 = (X-X0)^2+(Y-Y0)^2 + (X0-XM)^2+(Y0-YM)^2

If we call t the distance from (X,Y) to (X0,Y0) and f the distance from (X0,Y0) to (XM,YM), this can be written expressed as t^2+f^2.

This means we seek to integrate 

 log(sqrt(t^2+f^2)) = 1/2*log(t^2+f^2)

along the line segment from (X1,Y1) to (X2,Y2).  The indefinite integral of


with respect to t is given by the formula

 t*log(t^2+f^2) - 2*t + 2*f*atan(t/f) + C

which would allow you to express the definite integral in terms of the t values at (X1,Y1) and (X2,Y2) and the constant f.  No need to do numerical integration.

  (I overlooked the fact that the a^2+c^2 quantity in my previous discussion is necessarily equal to 1, so the log(a^2+c^2) constant would have been zero.) 

Roger Stafford