<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015</link>
    <title>MATLAB Central Newsreader - Common tangent</title>
    <description>Feed for thread: Common tangent</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 11 Feb 2008 03:38:01 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#414176</link>
      <author>Giuseppe Brunello</author>
      <description>Thank you for all replies and sorry I didn't reply earlier.&lt;br&gt;
&lt;br&gt;
I agree that having a function, as opposed to a set of&lt;br&gt;
points, would make the implementation much neater, but alas&lt;br&gt;
the problem I had in mind is to obtain a phase diagram for a&lt;br&gt;
binary mixture from the the Gibb's free energy. The material&lt;br&gt;
system minimizes the energy, and if a binary mixture of the&lt;br&gt;
two has a lower energy than a single phase then you'll get&lt;br&gt;
two phases (the system's energy lies on the common tangent,&lt;br&gt;
it being the weighted sum of the energy of the two phases).&lt;br&gt;
&lt;br&gt;
Also the slope of the system approaches infinity as you&lt;br&gt;
approach pure substances (i.e. the chemical potential of B&lt;br&gt;
in pure A is infinite). &lt;br&gt;
&lt;br&gt;
For an implementation with discreet points I was thinking of&lt;br&gt;
searching for the minimum of both curves, and then scan both&lt;br&gt;
sides with a tangent. If the tangent is lower then the other&lt;br&gt;
curves at all points I continue searching, if not I've&lt;br&gt;
intersected the other curve (and have a close approximation&lt;br&gt;
of the common tangent). &lt;br&gt;
&lt;br&gt;
Anyways thanks for all your help, I just thought this&lt;br&gt;
problem was neat.&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 17:58:51 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403579</link>
      <author>Bruno Luong</author>
      <description>"John D'Errico" &amp;lt;woodchips@rochester.rr.com&amp;gt; wrote in&lt;br&gt;
message &amp;lt;fik8j5$jpn$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Are you kidding? I'm trying to suggest that&lt;br&gt;
&amp;gt; an optimization will be fraught with problems.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Sorry for miss-reading John. It seems that you gave a lot of&lt;br&gt;
hints about chosing the metric for calcution of distance&lt;br&gt;
between two tangents. The metric must be explicitely defined&lt;br&gt;
in the optimization framework, and it is extremely&lt;br&gt;
important, I agree. But how is the impact of metric on the&lt;br&gt;
performance of a zero solver of multivariable function?&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 17:30:13 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403567</link>
      <author>John D'Errico</author>
      <description>"Bruno Luong" &amp;lt;b.luong@fogale.fr&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fik01e$csg$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "John D'Errico" &amp;lt;woodchips@rochester.rr.com&amp;gt; wrote in&lt;br&gt;
&amp;gt; message &amp;lt;fijhn9$bfi$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Also in the event of the optimization, recognize&lt;br&gt;
&amp;gt; &amp;gt; that while an optimizer can solve the problem,&lt;br&gt;
&amp;gt; &amp;gt; this may well have multiple local minima, or it&lt;br&gt;
&amp;gt; &amp;gt; may have no true solution at all. You will need&lt;br&gt;
&amp;gt; &amp;gt; good starting values, or you will need to start&lt;br&gt;
&amp;gt; &amp;gt; off the optimizer at multiple points, taking the&lt;br&gt;
&amp;gt; &amp;gt; best overall solution.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; John,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Why you are suggesting optimization tool for such problem&lt;br&gt;
&amp;gt; with all the eventual drawbacks (e.g., metric tbd, i.e.,&lt;br&gt;
&amp;gt; closest notion tbd, local minima, hard to find all the&lt;br&gt;
&amp;gt; solutions, hard to distinguish whereas a numerical solution&lt;br&gt;
&amp;gt; is a real solution)?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; It seems to me optimization is a too complex tool and not&lt;br&gt;
&amp;gt; suitable for such problem. I would avoid it all together.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; There is much better way to find intersection of two curves&lt;br&gt;
&amp;gt; in the plane.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
&lt;br&gt;
Are you kidding? I'm trying to suggest that&lt;br&gt;
an optimization will be fraught with problems.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 17:07:45 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403558</link>
      <author>Bruno Luong</author>
      <description>A little program for fun. Zeros solver is dirty written, one&lt;br&gt;
can do much better.&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
&lt;br&gt;
% Input function&lt;br&gt;
x=[-5:0.5:5];&lt;br&gt;
f=sin(x) + 0.01*x.^3;&lt;br&gt;
g=sin(x/2+1) - 2;&lt;br&gt;
&lt;br&gt;
%&lt;br&gt;
% Call function&lt;br&gt;
%&lt;br&gt;
commontangent(x, f, g);&lt;br&gt;
&lt;br&gt;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&lt;br&gt;
&lt;br&gt;
function commontangent(x, f, g)&lt;br&gt;
%&lt;br&gt;
% Solve and graphic output for common tangent&lt;br&gt;
%&lt;br&gt;
&lt;br&gt;
% Spline&lt;br&gt;
F=spline(x,f);&lt;br&gt;
G=spline(x,g);&lt;br&gt;
% Derivative&lt;br&gt;
DF=splinederive(F);&lt;br&gt;
DG=splinederive(G);&lt;br&gt;
% Constant term&lt;br&gt;
AF=coef0(F,DF);&lt;br&gt;
AG=coef0(G,DG);&lt;br&gt;
&lt;br&gt;
% fine grid&lt;br&gt;
xx=linspace(min(x),max(x),100);&lt;br&gt;
&lt;br&gt;
af=ppval(AF,xx); bf=ppval(DF,xx);&lt;br&gt;
ag=ppval(AG,xx); bg=ppval(DG,xx);&lt;br&gt;
&lt;br&gt;
cf=[af./sqrt(1+bf.^2); bf; xx];&lt;br&gt;
cg=[ag./sqrt(1+bg.^2); bg; xx];&lt;br&gt;
&lt;br&gt;
%&lt;br&gt;
% Solve for common tangent; dirty way&lt;br&gt;
%&lt;br&gt;
c=poly2poly(cf, cg);&lt;br&gt;
&lt;br&gt;
%&lt;br&gt;
% Graphic output&lt;br&gt;
%&lt;br&gt;
figure(1);&lt;br&gt;
clf;&lt;br&gt;
&lt;br&gt;
subplot(2,1,1);&lt;br&gt;
hf=plot(x,f,'b+',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xx,ppval(F,xx),'b',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x,g,'g+',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;xx,ppval(G,xx),'g');&lt;br&gt;
hold on;&lt;br&gt;
&lt;br&gt;
for n=1:size(c,2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cn=c(:,n);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;b=cn(2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a=cn(1)*sqrt(1+b^2);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;x2=cn([3 6]); &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ht=plot(x2, polyval([b a], x2), 'ko-');&lt;br&gt;
end&lt;br&gt;
h=[hf(1) hf(3) ht(1)];&lt;br&gt;
legend(h, 'f', 'g', 'common tangents');&lt;br&gt;
&lt;br&gt;
subplot(2,1,2);&lt;br&gt;
h=plot(cf(1,:),cf(2,:),'b',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cg(1,:),cg(2,:),'g',...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c(1,:), c(2,:), 'k.');&lt;br&gt;
legend(h, 'f-tangent', 'g-tangent', 'common tangents'); &lt;br&gt;
&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% derivative of a spline&lt;br&gt;
function d=splinederive(pp)&lt;br&gt;
d=pp;&lt;br&gt;
d.order=pp.order-1;&lt;br&gt;
order=d.order:-1:1;&lt;br&gt;
d.coefs=pp.coefs(:,1:d.order).*repmat(order,pp.pieces,1);&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% constant coefficient of the tangent&lt;br&gt;
function A=coef0(F,DF)&lt;br&gt;
A=F;&lt;br&gt;
z=zeros(DF.pieces,1);&lt;br&gt;
P=[DF.coefs z] + ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;[z repmat(DF.breaks(1:end-1)',1,DF.order).*DF.coefs];&lt;br&gt;
A.coefs=F.coefs-P;&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% intersection of two line segments&lt;br&gt;
function c=seg2seg(s1, s2)&lt;br&gt;
&lt;br&gt;
M=[s1(1:2,2)-s1(1:2,1) -s2(1:2,2)+s2(1:2,1)];&lt;br&gt;
rhs=s2(1:2,1)-s1(1:2,1);&lt;br&gt;
sol=M\rhs;&lt;br&gt;
if all(sol&amp;gt;=0 &amp; sol&amp;lt;=1)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c=[s1*[1-sol(1) sol(1)]'; ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;s2*[1-sol(2) sol(2)]']; &lt;br&gt;
else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c=[];&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% intersection of a q segment and a polygone&lt;br&gt;
function c=seg2poly(s1, P)&lt;br&gt;
c=[];&lt;br&gt;
for i=2:size(P,2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c=[c seg2seg(s1, P(:,i-1:i))]; %#ok&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
% intersection of two polygones&lt;br&gt;
function c=poly2poly(P1, P2)&lt;br&gt;
c=[];&lt;br&gt;
for i=2:size(P1,2)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;c=[c seg2poly(P1(:,i-1:i), P2)];%#ok&lt;br&gt;
end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 15:04:14 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403531</link>
      <author>Bruno Luong</author>
      <description>"John D'Errico" &amp;lt;woodchips@rochester.rr.com&amp;gt; wrote in&lt;br&gt;
message &amp;lt;fijhn9$bfi$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Also in the event of the optimization, recognize&lt;br&gt;
&amp;gt; that while an optimizer can solve the problem,&lt;br&gt;
&amp;gt; this may well have multiple local minima, or it&lt;br&gt;
&amp;gt; may have no true solution at all. You will need&lt;br&gt;
&amp;gt; good starting values, or you will need to start&lt;br&gt;
&amp;gt; off the optimizer at multiple points, taking the&lt;br&gt;
&amp;gt; best overall solution.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
John,&lt;br&gt;
&lt;br&gt;
Why you are suggesting optimization tool for such problem&lt;br&gt;
with all the eventual drawbacks (e.g., metric tbd, i.e.,&lt;br&gt;
closest notion tbd, local minima, hard to find all the&lt;br&gt;
solutions, hard to distinguish whereas a numerical solution&lt;br&gt;
is a real solution)?&lt;br&gt;
&lt;br&gt;
It seems to me optimization is a too complex tool and not&lt;br&gt;
suitable for such problem. I would avoid it all together.&lt;br&gt;
&lt;br&gt;
There is much better way to find intersection of two curves&lt;br&gt;
in the plane.&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 15:04:11 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403530</link>
      <author>Bruno Luong</author>
      <description>"John D'Errico" &amp;lt;woodchips@rochester.rr.com&amp;gt; wrote in&lt;br&gt;
message &amp;lt;fijhn9$bfi$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Also in the event of the optimization, recognize&lt;br&gt;
&amp;gt; that while an optimizer can solve the problem,&lt;br&gt;
&amp;gt; this may well have multiple local minima, or it&lt;br&gt;
&amp;gt; may have no true solution at all. You will need&lt;br&gt;
&amp;gt; good starting values, or you will need to start&lt;br&gt;
&amp;gt; off the optimizer at multiple points, taking the&lt;br&gt;
&amp;gt; best overall solution.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
John,&lt;br&gt;
&lt;br&gt;
Why you are suggesting optimization tool for such problem&lt;br&gt;
with all the eventual drawbacks (e.g., metric tbd, i.e.,&lt;br&gt;
closest notion tbd, local minima, hard to find all the&lt;br&gt;
solutions, hard to distinguish whereas a numerical solution&lt;br&gt;
is a real solution)?&lt;br&gt;
&lt;br&gt;
It seems to me optimization is a too complex tool and not&lt;br&gt;
suitable for such problem. I would avoid it all together.&lt;br&gt;
&lt;br&gt;
There is much better way to find intersection of two curves&lt;br&gt;
in the plane.&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 15:04:09 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403529</link>
      <author>Bruno Luong</author>
      <description>"John D'Errico" &amp;lt;woodchips@rochester.rr.com&amp;gt; wrote in&lt;br&gt;
message &amp;lt;fijhn9$bfi$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Also in the event of the optimization, recognize&lt;br&gt;
&amp;gt; that while an optimizer can solve the problem,&lt;br&gt;
&amp;gt; this may well have multiple local minima, or it&lt;br&gt;
&amp;gt; may have no true solution at all. You will need&lt;br&gt;
&amp;gt; good starting values, or you will need to start&lt;br&gt;
&amp;gt; off the optimizer at multiple points, taking the&lt;br&gt;
&amp;gt; best overall solution.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
John,&lt;br&gt;
&lt;br&gt;
Why you are suggesting optimization tool for such problem&lt;br&gt;
with all the eventual drawbacks (e.g., metric tbd, i.e.,&lt;br&gt;
closest notion tbd, local minima, hard to find all the&lt;br&gt;
solutions, hard to distinguish whereas a numerical solution&lt;br&gt;
is a real solution)?&lt;br&gt;
&lt;br&gt;
It seems to me optimization is a too complex tool and not&lt;br&gt;
suitable for such problem. I would avoid it all together.&lt;br&gt;
&lt;br&gt;
There is much better way to find intersection of two curves&lt;br&gt;
in the plane.&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 10:59:53 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403500</link>
      <author>John D'Errico</author>
      <description>"Bruno Luong" &amp;lt;brunoluong@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fij6n6$9h7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt;&lt;br&gt;
&amp;gt; wrote in message &amp;lt;fiivds$lqs$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;   As John intimated, if you only possess f and g in the&lt;br&gt;
&amp;gt; form of discrete &lt;br&gt;
&amp;gt; &amp;gt; vectors, you cannot expect to find precise solutions to&lt;br&gt;
&amp;gt; the problem but would &lt;br&gt;
&amp;gt; &amp;gt; have to settle for solutions to finite difference&lt;br&gt;
&amp;gt; approximations.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; After formalization, this problem is equivalent to be&lt;br&gt;
&amp;gt; finding two abscissas so that two coefficients that describe&lt;br&gt;
&amp;gt; the tangent at respective points are matched. This is like&lt;br&gt;
&amp;gt; finding an intersection of two parametric curves in R^2&lt;br&gt;
&amp;gt; (each axis of the plane corresponds to a coefficient of the&lt;br&gt;
&amp;gt; tangent).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Well, first the derivative must be computed one way or&lt;br&gt;
&amp;gt; another, finite difference would provide the derivative, but&lt;br&gt;
&amp;gt; only at discrete points.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; IMHO the "tricky" part is to be able to calculate the&lt;br&gt;
&amp;gt; derivative - not only at discrete point - but at any point.&lt;br&gt;
&amp;gt; The same applied for the input functions. And it's better if&lt;br&gt;
&amp;gt; one can provide a continuous functions and its derivatives,&lt;br&gt;
&amp;gt; so that the two parametric curves are continuous, and they&lt;br&gt;
&amp;gt; intersection can be solved.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If one can parametrize the input functions by cubic-spline,&lt;br&gt;
&amp;gt; its derivative is continuous (even C^1 IIRC). Both are&lt;br&gt;
&amp;gt; piecewise polynomials.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Next, it is just a question of solving it. There is&lt;br&gt;
&amp;gt; certainly a little bit of work, but I can't see any major&lt;br&gt;
&amp;gt; difficulty to implement an algorithm to solve the problem.&lt;br&gt;
&lt;br&gt;
Yes. It will either be a problem of comparing all&lt;br&gt;
pairs of tangent lines, taking the two which are&lt;br&gt;
"closest" under some metric, or an optimization,&lt;br&gt;
to find the two points x1 and x2, one for each&lt;br&gt;
continuous curve. Fminsearch will probably be&lt;br&gt;
adequate for the optimization task, since this is&lt;br&gt;
only a two variable problem. Of course, fsolve&lt;br&gt;
will also suffice. You can formulate it for either&lt;br&gt;
solver.&lt;br&gt;
&lt;br&gt;
In the latter case, you will need continuous&lt;br&gt;
functions, so it seems silly to discretize the&lt;br&gt;
problem with vectors of points, which then&lt;br&gt;
need to be interpolated by splines. Keep them&lt;br&gt;
as functions to be evaluated if at all possible.&lt;br&gt;
Of course, if they are indeed functions, then&lt;br&gt;
you need to differentiate them accurately. You&lt;br&gt;
might need to use a tool like my derivest, from&lt;br&gt;
the file exchange. So perhaps a pair of spline&lt;br&gt;
interpolants might be a good choice, since they&lt;br&gt;
will be easy and efficient to interpolate.&lt;br&gt;
&lt;br&gt;
Also in the event of the optimization, recognize&lt;br&gt;
that while an optimizer can solve the problem,&lt;br&gt;
this may well have multiple local minima, or it&lt;br&gt;
may have no true solution at all. You will need&lt;br&gt;
good starting values, or you will need to start&lt;br&gt;
off the optimizer at multiple points, taking the&lt;br&gt;
best overall solution.&lt;br&gt;
&lt;br&gt;
Finally, in either event, you will need to choose&lt;br&gt;
some metric to compare two lines. How will you&lt;br&gt;
define two lines as being the same, since in an&lt;br&gt;
optimization, the two lines will generally be&lt;br&gt;
only approximately the same and you need to&lt;br&gt;
minimize the difference? I'd imagine that a&lt;br&gt;
reasonable metric is the integral of the square&lt;br&gt;
of the difference of the two lines, integrated&lt;br&gt;
over the domain of the interval where the&lt;br&gt;
functions will be compared. Knowing the slopes&lt;br&gt;
and intercepts of the two lines, this objective&lt;br&gt;
should be computable directly using a little&lt;br&gt;
algebra.&lt;br&gt;
&lt;br&gt;
So while Bruno is correct that it is doable, it&lt;br&gt;
might take a bit of work to do it well.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 07:52:06 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403472</link>
      <author>Bruno Luong</author>
      <description>"Roger Stafford" &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt;&lt;br&gt;
wrote in message &amp;lt;fiivds$lqs$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   As John intimated, if you only possess f and g in the&lt;br&gt;
form of discrete &lt;br&gt;
&amp;gt; vectors, you cannot expect to find precise solutions to&lt;br&gt;
the problem but would &lt;br&gt;
&amp;gt; have to settle for solutions to finite difference&lt;br&gt;
approximations.&lt;br&gt;
&lt;br&gt;
After formalization, this problem is equivalent to be&lt;br&gt;
finding two abscissas so that two coefficients that describe&lt;br&gt;
the tangent at respective points are matched. This is like&lt;br&gt;
finding an intersection of two parametric curves in R^2&lt;br&gt;
(each axis of the plane corresponds to a coefficient of the&lt;br&gt;
tangent).&lt;br&gt;
&lt;br&gt;
Well, first the derivative must be computed one way or&lt;br&gt;
another, finite difference would provide the derivative, but&lt;br&gt;
only at discrete points.&lt;br&gt;
&lt;br&gt;
IMHO the "tricky" part is to be able to calculate the&lt;br&gt;
derivative - not only at discrete point - but at any point.&lt;br&gt;
The same applied for the input functions. And it's better if&lt;br&gt;
one can provide a continuous functions and its derivatives,&lt;br&gt;
so that the two parametric curves are continuous, and they&lt;br&gt;
intersection can be solved.&lt;br&gt;
&lt;br&gt;
If one can parametrize the input functions by cubic-spline,&lt;br&gt;
its derivative is continuous (even C^1 IIRC). Both are&lt;br&gt;
piecewise polynomials.&lt;br&gt;
&lt;br&gt;
Next, it is just a question of solving it. There is&lt;br&gt;
certainly a little bit of work, but I can't see any major&lt;br&gt;
difficulty to implement an algorithm to solve the problem.&lt;br&gt;
&lt;br&gt;
Bruno&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 Nov 2007 05:47:40 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403469</link>
      <author>Roger Stafford</author>
      <description>"Giuseppe Brunello" &amp;lt;gbrunello3@gatech.edu&amp;gt; wrote in message &amp;lt;fihu0m&lt;br&gt;
$quf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I want to find between two functions f and g their common&lt;br&gt;
&amp;gt; tangent(s). Is there a built in MatLab command that will&lt;br&gt;
&amp;gt; take two vectors (calculated from f and g) and return the&lt;br&gt;
&amp;gt; common tangent(s)?&lt;br&gt;
---------&lt;br&gt;
&amp;nbsp;&amp;nbsp;If I understand you correctly, Giuseppe, your "common tangents" problem is &lt;br&gt;
equivalent to finding values for arguments, a and b, which satisfy the &lt;br&gt;
equations:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;(f(b)-g(a))/(b-a) = f'(b) = g'(a)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;I am far from being knowledgeable about the Optimization Toolbox but it &lt;br&gt;
seems to me that the 'fsolve' function therein could be used for this purpose, &lt;br&gt;
provided you have it on your computer and can compute the two derivative &lt;br&gt;
(gradient) functions, f' and g'.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;As John intimated, if you only possess f and g in the form of discrete &lt;br&gt;
vectors, you cannot expect to find precise solutions to the problem but would &lt;br&gt;
have to settle for solutions to finite difference approximations.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 27 Nov 2007 22:53:48 -0500</pubDate>
      <title>Re: Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403446</link>
      <author>John D'Errico</author>
      <description>"Giuseppe Brunello" &amp;lt;gbrunello3@gatech.edu&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fihu0m$quf$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I want to find between two functions f and g their common&lt;br&gt;
&amp;gt; tangent(s). Is there a built in MatLab command that will&lt;br&gt;
&amp;gt; take two vectors (calculated from f and g) and return the&lt;br&gt;
&amp;gt; common tangent(s)?&lt;br&gt;
&lt;br&gt;
No. Its something that you would have to write.&lt;br&gt;
Remember that there will not be an exactly&lt;br&gt;
common tangent if you are providing a list of&lt;br&gt;
points from each function. So you will need to&lt;br&gt;
find a the best possible line.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 27 Nov 2007 20:17:26 -0500</pubDate>
      <title>Common tangent</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/160015#403440</link>
      <author>Giuseppe Brunello</author>
      <description>I want to find between two functions f and g their common&lt;br&gt;
tangent(s). Is there a built in MatLab command that will&lt;br&gt;
take two vectors (calculated from f and g) and return the&lt;br&gt;
common tangent(s)?&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
