-1

Python: How to graph $y^2=x^3-7+3$?

I have been searching online but I can't find a way to do it.

2 Answers2

3

Matplotlib's contour function can be used to plot the solution to implicit equations:

import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()

y, x = np.ogrid[-4:4:1000j, -6:6:1000j]
plt.contour(
    x.ravel(), y.ravel(), y**2 - x**3 + 7*x -3, [0])
plt.show()

yields

enter image description here

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
0

With matplotlib and numpy:

import matplolib.pyplot as plt
import numpy as np
from math import sqrt

x = np.arange(10,100) # You have to choose the domain you are looking to plot
y = [sqrt(i**3 - 7 + 3) for i in x]

plt.plot(x,y)
plt.show()

Well, actually you have to be careful with the domain of the function, in order to choose +sqrt or -sqrt.

tomasyany
  • 1,132
  • 3
  • 15
  • 32