how to find minimum of discontinuous symbolic function

2 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 2 Aug 2021
Could we have the other variable values to test with?
Maggie liu
Maggie liu on 2 Aug 2021
@Walter Roberson Sorry for not showing them when I asked the question. I have updated the description with the sample variables. Thanks!

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 2 Aug 2021
%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

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!