Answer to Question #205479 in Python for Reoma Alurd

Question #205479

2. The shape of a lima¸con can be defined parametrically as


r = r0 + cos θ

x = r cos θ

y = r sin θ


When r0 = 1, this curve is called a cardioid. Use this definition to plot the shape of a limacon for r0 = 0.8, r0 = 1.0, and r0 = 1.2. Be sure to use enough points that the curve is closed and appears smooth (except for the cusp in the cardioid). Use a legend to identify which curve is which. 


1
Expert's answer
2021-06-13T10:24:04-0400
import numpy as np
from matplotlib import pyplot as plt


# array of theta values ranging from 0 to 10
theta = np.linspace(0, 10, 200)


# r = r0 + cos θ
r = 0.8 + np.cos(theta)


r1 = 1.0 + np.cos(theta)


r2 = 1.2 + np.cos(theta)


# x and y values for r=0.8
x = r * np.cos(theta)


y = r * np.sin(theta)


#x and y values for r = 1.0
x1 = r1 * np.cos(theta)


y1 = r1 * np.sin(theta)


#x and y values for r = 1.2
x2 = r2 * np.cos(theta)


y2 = r2 * np.sin(theta)


# plot licamon for r = 0.8
plt.plot(x,y)
plt.title('r=0.8')
plt.show()



# plot licamon for r = 1.0
plt.plot(x1,y1)
plt.title('r=1.0')
plt.show()


# plot licamon for r = 1.2
plt.plot(x2,y2)
plt.title('r=1.2')
plt.show()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS