Ask Your Question
0

Plot intersections of two relations

asked 2016-05-23 00:23:52 -0500

slemonide gravatar image

updated 2016-05-23 09:09:35 -0500

calc314 gravatar image

How can I plot an intersection of two relations? For instance, if I have two spheres $x^2 + (y-1)^2 + (z-1)^2 = 1$ and $x^2 + y^2 + z^2 = 1$, how can I plot their intersection on a graph?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-05-23 17:07:00 -0500

Since you have two equations and three variables, first solve the system in terms of one variable:

var('x y z')
f=solve( [ x^2+(y-1)^2+(z-1)^2==1, x^2+y^2+z^2==1 ], y, z )

This gives solutions as a list:

[[y == -1/2*sqrt(-2*x^2 + 1) + 1/2, z == 1/2*sqrt(-2*x^2 + 1) + 1/2], [y == 1/2*sqrt(-2*x^2 + 1) + 1/2, z == -1/2*sqrt(-2*x^2 + 1) + 1/2]]

You can then either copy the solutions into a 3d parametric plot,

p = parametric_plot3d( [ x, -1/2*sqrt(-2*x^2 + 1) + 1/2, 1/2*sqrt(-2*x^2 + 1) + 1/2 ], (x,-1,1) )
p += parametric_plot3d( [ x, 1/2*sqrt(-2*x^2 + 1) + 1/2, -1/2*sqrt(-2*x^2 + 1) + 1/2 ], (x,-1,1) )

or substitute the solutions through the list indices:

p = parametric_plot3d( [ x, y.subs(f[0][0]), z.subs(f[0][1]) ], (x,-1,1) )
p += parametric_plot3d( [ x, y.subs(f[1][0]), z.subs(f[1][1]) ], (x,-1,1) )

and then show the combined plot. Here's an example including a unit sphere in cyan and the parametric solution in blue, with a slightly different output method.

edit flag offensive delete link more

Comments

Thank you.

slemonide gravatar imageslemonide ( 2016-05-24 00:16:39 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-05-23 00:23:52 -0500

Seen: 159 times

Last updated: May 23 '16