0% found this document useful (0 votes)
2 views6 pages

Prac2-8869

The document contains a series of Jupyter Notebook code snippets that generate 3D contour plots for various mathematical functions. Each function is defined, and the corresponding 3D plot is created using matplotlib's mplot3d toolkit. The functions include parabolas and trigonometric expressions, showcasing different mathematical behaviors over specified ranges.

Uploaded by

sbaig1062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Prac2-8869

The document contains a series of Jupyter Notebook code snippets that generate 3D contour plots for various mathematical functions. Each function is defined, and the corresponding 3D plot is created using matplotlib's mplot3d toolkit. The functions include parabolas and trigonometric expressions, showcasing different mathematical behaviors over specified ranges.

Uploaded by

sbaig1062
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1/18/25, 4:29 PM Pr-2-(8880) - Jupyter

Pr-2-(8869) JupyterNotebook
Notebook

In [1]: #Q1
from mpl_toolkits import mplot3d
import numpy as np
from pylab import*
def f(x,y):
return x**2+y**2
x=np.linspace(-6,6,30)
y=np.linspace(-6,6,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:Z=x^2+y^2$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 1/6
1/18/25, 4:29 PM Pr-2-(8880) - Jupyter
Pr-2-(8869) JupyterNotebook
Notebook

In [2]: #Q2
def f(x,y):
return x*np.e**(-x**2-y**2)
x=np.linspace(-6,6,30)
y=np.linspace(-6,6,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:Z=x*e**(-x**2-y**2)$")
show()

In [3]: #Q3
def f(x,y):
return np.cos(abs(x)+abs(y))
x=np.linspace(-1,1,30)
y=np.linspace(-1,1,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:Z=cos(abs(x)+abs(y))$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 2/6
1/18/25, 4:29 PM Pr-2-(8880) - Jupyter
Pr-2-(8869) JupyterNotebook
Notebook

In [4]: #Q4
def f(x,y):
return np.cos(x**2+y**2-0.5)-0.5
x=np.linspace(-1,1,30)
y=np.linspace(-1,1,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:Z=cos(x**2+y**2-0.5)-0.5$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 3/6
1/18/25, 4:29 PM Pr-2-(8880) - Jupyter
Pr-2-(8869) JupyterNotebook
Notebook

In [5]: #Q5
def f(x,y):
return np.sin(x)+cos(y)
x=np.linspace(-5,5,30)
y=np.linspace(-5,5,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:sin(x)+cos(y)$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 4/6
1/18/25, 4:29 PM Pr-2-(8880) - Jupyter
Pr-2-(8869) JupyterNotebook
Notebook

In [6]: #Q6 - 1
def f(x,y):
return e**(x**2+y**2)
x=np.linspace(0,2*pi,30)
y=np.linspace(0,2*pi,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
figure(figsize=(7,7))
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:e**(x**2+y**2)$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 5/6
1/18/25, 4:29 PM Pr-2-(8880) - Jupyter
Pr-2-(8869) JupyterNotebook
Notebook

In [7]: #Q6 - 2
def f(x,y):
return e**(x**2-y**2)
x=np.linspace(0,2*pi,30)
y=np.linspace(0,2*pi,30)
X,Y=np.meshgrid(x,y)
Z=f(X,Y)
figure(figsize=(5,5))
ax=axes(projection='3d')
ax.contour3D(X,Y,Z,50)
xlabel("X-Axis")
ylabel("Y-Axis")
title("$Parabola:e**(x**2-y**2)$")
show()

localhost:8888/notebooks/Pr-2-(8880).ipynb
localhost:8869/notebooks/Pr-2-(8869).ipynb 6/6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy