So I have this equation:
x^2 + 4*(z+10)^2 = e^(-0.05*z)
How cant I plot it using, for example, Matplotlib.pyplot and Numpy packages?
Wand ellipse() function in Python Just similar to drawing circle the ellipse() function requires two pairs of point that is, origin and a pair of (x, y) radius of the ellipse. To draw a partial ellipse, provide a pair of starting & ending degrees as the third parameter. pair which represents origin x and y of ellipse.
To graph an ellipse, mark points a units left and right from the center and points b units up and down from the center. Draw an ellipse through these points. The orientation of an ellipse is determined by a and b. If a>b then the ellipse is wider than it is tall and is considered to be a horizontal ellipse.
My solution is: Calculate each side of equation for a given x and z gridded. Then I contour points that satisfy the equation. One side minus other equals to zero.
import numpy as np
import matplotlib.pyplot as plt
z = -np.linspace(9,15,100)
x = np.linspace(-26,26,1000)
x,z = np.meshgrid(x,z)
Z = -np.exp(-0.05*z) +4*(z+10)**2
X = x**2
plt.contour(x,z,(X+Z),[0])
plt.xlim([-1.5,1.5])
plt.ylim([-11.5,-8.5])
Use the plot_implicit function of sympy http://docs.sympy.org/latest/modules/plotting.html or use Sage http://www.sagemath.org/.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With