29 views (last 30 days)

Show older comments

高木 範明 on 20 Jul 2024 at 9:10

Commented: 高木 範明 about 13 hours ago

Accepted Answer: John D'Errico

There is a cylinder centered at (0,0) and extending in the direction of the z-axis. Then there is a 3D surface represented by some z=f(x,y). I want to express the equation of the intersection of these two by z=g(x,y). Please show me how to do this calculation.

I executed the following code, but I do not know what the calculated value indicates. I would appreciate it if you could tell me this as well.

----------------------------------

% シンボリック変数の定義

syms x y z

% 円筒と平面の方程式

r = 5; % 円筒の半径

cylinder_eq = x^2 + y^2 == r^2; % 円筒の方程式

plane_eq = z == x * y + 3; % 平面の方程式

z_range = z < 1000;

% 連立方程式を解く

sol = solve([cylinder_eq, plane_eq, z_range], [x, y, z]);

% 解の表示

disp(sol)

disp(sol.x)

disp(sol.y)

disp(sol.z)

----------------------------------

x: [7×1 sym]

y: [7×1 sym]

z: [7×1 sym]

(25/2 - 589^(1/2)/2)^(3/2)/3 - (25*(25/2 - 589^(1/2)/2)^(1/2))/3

(589^(1/2)/2 + 25/2)^(3/2)/3 - (25*(589^(1/2)/2 + 25/2)^(1/2))/3

(25*(25/2 - 589^(1/2)/2)^(1/2))/3 - (25/2 - 589^(1/2)/2)^(3/2)/3

(25*(589^(1/2)/2 + 25/2)^(1/2))/3 - (589^(1/2)/2 + 25/2)^(3/2)/3

(25/2 - 589^(1/2)/2)^(1/2)

(589^(1/2)/2 + 25/2)^(1/2)

-5

5

-(25/2 - 589^(1/2)/2)^(1/2)

-(589^(1/2)/2 + 25/2)^(1/2)

3

3

3

##### 2 Comments Show NoneHide None

Show NoneHide None

Sam Chak about 23 hours ago

#### Direct link to this comment

https://webchat.mathworks.com/matlabcentral/answers/2138956-the-equation-of-the-curve-at-the-intersection-of-the-two-3d-surface-one-is-a-cylinder#comment_3216281

Edited: Sam Chak about 23 hours ago

Open in MATLAB Online

Hi @高木 範明,

Are you imagining this "intersection"?

[x, y] = meshgrid(-7:0.5:7);

r = 5; % 円筒の半径

% cylinder_eq = x^2 + y^2 == r^2; % 円筒の方程式

% plane_eq = z == x * y + 3; % 平面の方程式

z = x.*y + 3;

surf(x, y, z), hold on

num = 90;

[X,Y,Z] = cylinder(r, num);

h = 50;

Z = Z*h - h/2;

surf(X, Y, Z),

xlabel('x'), ylabel('y'), zlabel('z')

高木 範明 about 21 hours ago

#### Direct link to this comment

https://webchat.mathworks.com/matlabcentral/answers/2138956-the-equation-of-the-curve-at-the-intersection-of-the-two-3d-surface-one-is-a-cylinder#comment_3216306

Yes, this image is correct. We want to know the equation of this intersecting curve.

Sign in to comment.

Sign in to answer this question.

### Accepted Answer

John D'Errico about 22 hours ago

Edited: John D'Errico about 15 hours ago

Open in MATLAB Online

It is not always trivial to find that curve as some explicit function. Here, yes, you can do so easily enough.

r = 5; % radius of the cylinder

% A cylinder that runs parallel to the z axis, centered at the origin

cylinder_eq = x^2 + y^2 == r^2;

In fact though, a good way to represent that cylinder is to think about it in cylindrical coordinates, thus (r,theta,z), where the cylinder is now simply the surface represented as

r = 5

The second surface is a hyperbolic one, NOT a plane.

hyper_eq = z == x * y + 3;

But here is where the cylindrical coordinate change helps. If we replace

x = r*cos(theta)

y = r*sin(theta)

into that second surface relation, we will get:

syms theta

subs(hyper_eq,[x,y],[r*cos(theta),r*sin(theta)])

ans=

Now we can plot that curve in 3-d as:

t = linspace(0,2*pi);

plot3(r*cos(t),r*sin(t),cos(t).*sin(t)*r^2 + 3,'-b')

box on

grid on

I suppose I could do more, and plot the two surfaces on top of this in a translucent form. But @Sam Chak already plotted them in a comment.

Anyway, what happened when you did as you used solve? You supplied it three equations, one of which was only an inequality? In fact, that inequaity is not even ever used. Solve actually found 7 distinct "solutions", even though there are infinitely many solutions. Solve was a bit confused as to what you wanted to see.

##### 3 Comments Show 1 older commentHide 1 older comment

Show 1 older commentHide 1 older comment

高木 範明 about 20 hours ago

#### Direct link to this comment

https://webchat.mathworks.com/matlabcentral/answers/2138956-the-equation-of-the-curve-at-the-intersection-of-the-two-3d-surface-one-is-a-cylinder#comment_3216356

Thank you for your detailed explanation. I understand it very well. I did not realize that both cylinders and surfaces are converted to polar coordinates. I was only thinking of solving the cylinder by somehow converting it to rectilinear coordinates. In fact, I was planning to differentiate the curve obtained afterwards to find the maxima of z. With polar coordinates, I only need to consider the differential of t, which is very easy to understand.

Translated with www.DeepL.com/Translator (free version)

John D'Errico about 12 hours ago

#### Direct link to this comment

https://webchat.mathworks.com/matlabcentral/answers/2138956-the-equation-of-the-curve-at-the-intersection-of-the-two-3d-surface-one-is-a-cylinder#comment_3216481

Edited: John D'Errico about 12 hours ago

Open in MATLAB Online

Polar coordinates is such a natural thing to do there, because the cylinder is so perfectly represented in polar form. As well, we also know the solution locus lies on a perfect circle in the (x,y) plane, because any point must also lie on the cylinder. And that just steers it directly into a polar representation .

Could we have solved the problem using purely rectilinear coordinates? Well, surely the answer would be yes. No problem ever seems to have only one approach. Just that others may take more thought. :)

syms x y z

r = 5; % radius of the cylinder

% A cylinder that runs parallel to the z axis, centered at the origin

cylinder_eq = x^2 + y^2 == r^2;

hyper_eq = z == x * y + 3;

We want to solve for z, as a function of the other parameters. So one idea might be to just throw it into solve, and maybe it can think of something intelligent.

solve(cylinder_eq,hyper_eq,z)

ans = Empty sym: 0-by-1

And of course, that fails, miserably. Stupid computers. But we might try harder.

xsol = solve(cylinder_eq,x)

xsol=

z_eq = subs(hyper_eq,x,xsol)

z_eq=

It appears we have two branches. As long as the square roots yield a real result, then z will be real. That means we must have -5<=y<=5.

This solution seems not to care about x, But you can choose any value of y, and it will generate the value of z. Then if you know the value of y, you can also recover x, but there are two branches. Lets see what this result looks like. I hope it is the same. I'll need to use both branches to get the entire curve.

fplot3(sqrt(r.^2 - y.^2),y,y.*sqrt(5 - y).*sqrt(y+5)+3,[-5,5],'r')

hold on

fplot3(-sqrt(r.^2 - y.^2),y,3 - y.*sqrt(5 - y).*sqrt(y+5),[-5,5],'b')

Now I suppose there may be an easier way to solve this while still living in the cartesian system, but you should compare just how natural the solution was in polar form. And even if another approach may work out better than what I did, I'd not think it will be as simple as the polar one.

高木 範明 about 11 hours ago

#### Direct link to this comment

https://webchat.mathworks.com/matlabcentral/answers/2138956-the-equation-of-the-curve-at-the-intersection-of-the-two-3d-surface-one-is-a-cylinder#comment_3216541

It's great!

I see that the equation for the intersecting curves can be calculated even in the rectilinear coordinate system. I also tried until I got "Empty sym: 0-by-1", but gave up there. I thought of solving it as an implicit function, so I didn't realize that I had to change it to an explicit function. Thank you so much for your teaching.

Sign in to comment.

### More Answers (0)

Sign in to answer this question.

### See Also

### Categories

Mathematics and OptimizationSymbolic Math ToolboxMathematicsCalculus

Find more on **Calculus** in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

**An Error Occurred**

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

- América Latina (Español)
- Canada (English)
- United States (English)

Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français

- United Kingdom(English)

Asia Pacific

- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)

Contact your local office