how to find minimum of discontinuous symbolic function

조회 수: 1 (최근 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 CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by