how to find minimum of discontinuous symbolic function

2 ビュー (過去 30 日間)
Maggie liu
Maggie liu 2021 年 8 月 2 日
回答済み: Walter Roberson 2021 年 8 月 2 日
My function looks something like this
%parameters for a capped cylinder centered on z axis
R = 0.5; %radius of sphere
r = 0.5; %radius of cylinder
L = 3; %length of cylinder
h = sqrt(R^2-r^2);
shift = (L/2)-h;
A = [-0.4322 0.2514 0.7427] %a point on cylinder surface
B = [-0.0987 -0.2834 1.8999] %a point on sphere surface
a1 = A(1); a2 = A(2); a3 = A(3);
b1 = B(1); b2 = B(2); b3 = B(3);
syms phi
D = @(phi) sqrt((r.*(atan2(a2,a1)-phi)).^2+(a3-L./2).^2) ... %distance between the two points as a function of phi
+ R*acos(((b1.*cos(phi)+b2.*sin(phi)+(b3-shift)*(L./2-shift)))./R.^2);
And this is its graph over 0,2pi
as shown above, the minimum occurs at one of the asymptote. My question is how can I get the x coordinate of the asymptote?
Thanks for your help!!
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 8 月 2 日
Could we have the other variable values to test with?
Maggie liu
Maggie liu 2021 年 8 月 2 日
@Walter Roberson Sorry for not showing them when I asked the question. I have updated the description with the sample variables. Thanks!

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2021 年 8 月 2 日
%parameters for a capped cylinder centered on z axis
R = 0.5; %radius of sphere
r = 0.5; %radius of cylinder
L = 3; %length of cylinder
h = sqrt(R^2-r^2);
shift = (L/2)-h;
A = [-0.4322 0.2514 0.7427] %a point on cylinder surface
A = 1×3
-0.4322 0.2514 0.7427
B = [-0.0987 -0.2834 1.8999] %a point on sphere surface
B = 1×3
-0.0987 -0.2834 1.8999
a1 = A(1); a2 = A(2); a3 = A(3);
b1 = B(1); b2 = B(2); b3 = B(3);
syms phi real
D = @(phi) sqrt((r.*(atan2(a2,a1)-phi)).^2+(a3-L./2).^2) ... %distance between the two points as a function of phi
+ R*acos(((b1.*cos(phi)+b2.*sin(phi)+(b3-shift)*(L./2-shift)))./R.^2);
DD = D(phi)
DD = 
DD1c = simplify(cos(2*children(DD,1)))
DD1c = 
limpoint = vpasolve(DD1c == 1, pi)
limpoint = 
3.7910906782081747162135888997947
D(limpoint)
ans = 
0.9588763931357714838022843054125

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by