Dear all, I have an issue with a constrained minimization and FindMinimum.
Consider two cylinders of length L and radius R: the center of the first is located at the origin and its axis is parallel to the z axis, the center of the second is located at {xT, 0, xz}, and its axis is oriented according to the polar angles \theta and \phi.
Given two vectors {r[1],..,r[3]} and {s[1],..,s[3]}, I want to find the minimum of the square distance between them
f(r,s) = (r[1] - s[1])^2 + (r[2] - s[2])^2 + (r[3] - s[3])^2,
with the constraint that the vector {r[1],r[2],r[3]} lies within the first cylinder, and {s[1],..,s[3]} lies within the second cylinder:
In[1]:= R = 1/2;
L = 4;
xT = 78/100;
xz = -4/10;
\[CurlyTheta] = 8/10;
\[Phi] = 3;
In[7]:= FindMinimum[{(r[1] - s[1])^2 + (r[2] - s[2])^2 + (r[3] -
s[3])^2, r[1]^2 + r[2]^2 <= R^2, L + 2 r[3] >= 0,
2 r[3] <=
L, (Sin[\[Phi]] (xT - s[1]) +
Cos[\[Phi]] s[
2])^2 + (Cos[\[CurlyTheta]] (Cos[\[Phi]] (-xT + s[1]) +
Sin[\[Phi]] s[2]) + Sin[\[CurlyTheta]] (xz - s[3]))^2 <= R^2,
2 Cos[\[Phi]] Sin[\[CurlyTheta]] (xT - s[1]) +
2 Cos[\[CurlyTheta]] (xz - s[3]) <=
L + 2 Sin[\[CurlyTheta]] Sin[\[Phi]] s[2],
2 Sin[\[CurlyTheta]] Sin[\[Phi]] s[2] <=
L + 2 Cos[\[Phi]] Sin[\[CurlyTheta]] (xT - s[1]) +
2 Cos[\[CurlyTheta]] (xz - s[3])}, {{r[1], 0}, {s[1], xT}, {r[2],
0}, {s[2], 0}, {r[3], 0}, {s[3], xz}}]
Out[7]= {1.7518957310232823*10^-15, {r[1] -> 0.24200719173126448,
s[1] -> 0.24200723086912757, r[2] -> 0.0173827341902361,
s[2] -> 0.01738274867534208, r[3] -> -0.0952795259719789,
s[3] -> -0.0952795227618218}}
In this example the two cylinders overlap, the minimum is r = s, and the value of the objective function at the minimum must be zero. However, FindMinimum returns some small, but nonzero value 1e-15.
Is there a way to make sure that, if the minimum is x=y, then the minimum for the objective function is exactly zero, i.e., 0.
?
Thank you.