Skip to content
Snippets Groups Projects
Commit 5ec1443c authored by Bonnemains Matthieu's avatar Bonnemains Matthieu
Browse files

Delete visualizer.py

parent 7f83cc0f
No related branches found
No related tags found
No related merge requests found
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def plot_3d_function(f, x_range=(-200, 200), y_range=(-200, 200), resolution=5000):
x = np.linspace(x_range[0], x_range[1], resolution)
y = np.linspace(y_range[0], y_range[1], resolution)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, cmap='viridis')
ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')
ax.set_title('3D Function Visualization')
plt.show()
# Example usage: Visualizing z = sin(sqrt(x^2 + y^2))
def goldstein_price(x, y):
return (1 + (x + y + 1)**2 * (19 - 14*x + 3*x**2 - 14*y + 6*x*y + 3*y**2)) * (30 + (2*x - 3*y)**2 * (18 - 32*x + 12*x**2 + 48*y - 36*x*y + 27*y**2))
def square_function(x, y):
return x**2 + y**2
plot_3d_function(square_function)
plot_3d_function(goldstein_price)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment