1

An equation which is represent as below

sin(x)*sin(y)*sin(z)+cos(x)*sin(y)*cos(z)=0

I know the code to plot function for z=f(x,y) using matplotlib but to plot above function I don’t know the code, but I tried MATLAB MuPad code which is as follows

Plot(sin(x)*sin(y)*sin(z)+cos(x)*sin(y)*cos(z),#3d)
4
  • 1
    Does this answer your question? Plotting a function of three variables in python Commented Feb 2, 2020 at 15:07
  • You can try mplot3d. matplotlib.org/tutorials/toolkits/… Commented Feb 2, 2020 at 15:15
  • All the above resources (1) takes different values of z to give different plots but my aim is to mimic the function in mupad to plot an expression equating to 0. Resource (2) has all the function where z is the function of two other variables but in my code z is also an independent variable so function in that library fails Commented Feb 3, 2020 at 0:58
  • Do you have any domain for the values of x, y, z? Commented Feb 3, 2020 at 14:45

2 Answers 2

1

This will be much easier if you can isolate z. Your equation is the same as sin(z)/cos(z) = -cos(x)*sin(y)/(sin(x)*sin(y)) so z = atan(-cos(x)*sin(y)/(sin(x)*sin(y))).

Sign up to request clarification or add additional context in comments.

2 Comments

If you simplify further, you can cancel sin(y) in numerator and denominator, but I don't think its proper.
Ah, I didn't notice that. So really the equation is z = atan(-1/tan(x)) or y = n*pi (for integer n). These two can be plotted separately on top of each other using most standard 3d plotting toolkits.
0

Please don't mistake me, but I think your given equation to plot can be reduced to a simple 2D plot.

sin(x)*sin(y)*sin(z)+cos(x)*sin(y)*cos(z) = 0
sin(y)[sin(x)*sin(z)+cos(x)*cos(z)] = 0
sin(y)*cos(x-z) = 0
Hence sin(y) = 0 or cos(x-z)=0
Hence y = n*pi (1) or x-z=(2*n + 1)pi/2
Implies, x = z + (2*n + 1)pi/2 (2)

For (1), it will be a straight line (the plot of y vs n) and in second case, you will get parallel lines which cuts x-axis at (2*n + 1)pi/2 and distance between two parallel lines would be pi. (Assuming you keep n constant).

Assuming, your y can't be zero, you could simplify the plot to a 2D plot with just x and z.

And answering your original question, you need to use mplot3d to plot 3D plots. But as with any graphing tool, you need values or points of x, y, z. (You can compute the possible points by programming). Then you feed those points to the plot, like below.

from mpl_toolkits import mplot3d

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = plt.axes(projection="3d")
xs = [] # X values
ys = [] # Y values
zs = [] # Z values
ax.plot3D(xs, ys, zs)
plt.show()

1 Comment

y = 0 or x - z = pi/2 are only some of the solutions. The real answers should be periodic, like y = n*pi or x - z = n*pi - pi/2 for integer n.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.