How to Plot x² + y² = z²
At a glance
- 1. Read the equation
Assume the equation is x² + y² = z²; it describes a surface in three-dimensional space.
- 2. Identify both branches
Solving for z gives z = √(x² + y²) and z = −√(x² + y²), forming a double cone.
- 3. Choose a plotting range
Restrict x and y to a finite interval so the plotted surface fits in the graph.
- 4. Plot both surfaces
Use a 3D plotting tool to graph the positive and negative square-root branches.
Assuming the intended equation is , its graph is a three-dimensional surface, not a single curve. It is a double cone with its tip at the origin and its axis along the -axis. You can plot it by expressing in terms of and and graphing both possible values.
Rewrite the equation as two surfaces
Taking square roots gives
Both signs are required because the original equation contains . The positive branch is the upper nappe of the cone, and the negative branch is the lower nappe. If the intended equation also includes the restriction , then plot only the positive branch.
The equation is symmetric in and . For any fixed value , the cross-section satisfies , which is a circle of radius in the horizontal plane. As increases, these circles get larger, producing the cone shape.
Plot it in Python
This example uses NumPy to calculate the surface and Matplotlib to draw it. Install the packages first if needed with python -m pip install numpy matplotlib.
import numpy as np
import matplotlib.pyplot as plt
# Sample a square region in the x-y plane.
limit = 3
x = np.linspace(-limit, limit, 120)
y = np.linspace(-limit, limit, 120)
X, Y = np.meshgrid(x, y)
R = np.sqrt(X**2 + Y**2)
fig = plt.figure()
ax = fig.add_subplot(111, projection="3d")
# Plot the upper and lower nappes.
ax.plot_surface(X, Y, R, cmap="viridis", alpha=0.85)
ax.plot_surface(X, Y, -R, cmap="viridis", alpha=0.85)
z_limit = np.sqrt(2) * limit
ax.set_xlim(-limit, limit)
ax.set_ylim(-limit, limit)
ax.set_zlim(-z_limit, z_limit)
ax.set_box_aspect((2 * limit, 2 * limit, 2 * z_limit))
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.set_title("x² + y² = z²")
plt.show()
The grid is limited to , so the displayed cone is only a finite portion of an otherwise unbounded surface. R computes at every grid point; plotting R and -R supplies the two branches. The box aspect ratio matches the axis ranges so that equal coordinate distances are shown at comparable scales.
Check the plot with points and slices
A point belongs to the surface exactly when its coordinates satisfy the equation. For example, lies on it because
The point lies on it too, since . By contrast, does not: its left side is , while its right side is .
You can also verify the shape using horizontal slices. At , the cross-section is , a circle of radius . At , it is the same circle. At , the only point is the origin.
Common plotting mistakes
- Plotting only one branch: Graphing shows only the upper cone. The equation with includes the lower cone as well.
- Treating the equation as a 2D graph: There are three variables, so the full graph is a surface in 3D. A 2D plot can show a cross-section, such as the circle at a fixed value.
- Using an infinite plotting range: A computer plot needs finite coordinate limits. Changing the grid range changes how much of the cone is visible, not the equation itself.
- Ignoring the equation’s signs or operators: If the intended expression was not , its graph may be different. For instance, adding to the left side and setting the result equal to a constant gives a sphere, not a cone.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.