0% found this document useful (0 votes)
5 views

3.3D_graph_plotting[1]

The document contains a series of programming tasks focused on plotting various mathematical functions using Python's 3D plotting capabilities. Each task includes a function definition, a grid setup for the x and y values, and a plotting command to visualize the function in specified intervals. The functions plotted include exponential, polynomial, trigonometric, and absolute value functions, with outputs displayed in contour, surface, and wireframe formats.

Uploaded by

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

3.3D_graph_plotting[1]

The document contains a series of programming tasks focused on plotting various mathematical functions using Python's 3D plotting capabilities. Each task includes a function definition, a grid setup for the x and y values, and a plotting command to visualize the function in specified intervals. The functions plotted include exponential, polynomial, trigonometric, and absolute value functions, with outputs displayed in contour, surface, and wireframe formats.

Uploaded by

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

Dr.D.Y.

Patil ACS, Pimpri Pune-18


Name=RITESH MUNDE
Roll no.:187
Batch:S7
Practical no.:3

Q.1 Plot a graph of f(x)=e-x^2-y2 in the interval [-1,1].

Program:

def f(x,y):

return e**(-x**2-y**2)

x=linspace(-1,1,30)

y=linspace(-1,1,30)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,51)

xlabel('x')

ylabel('y')

title('e**(-x**2-y**2)')

show()

Output:

17
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.2 Plot z=x2+y2 in interval [-6,6].

Program:

from mpl_toolkits

import mplot3d

from pylab import*

def f(x,y):return x**2+y**2

x=linspace(-6,6,85)

y=linspace(-6,6,85)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,51)

xlabel('x')

ylabel('y')

title('x^2+y^2')

show()

Output:

18
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.3 Plot the function z=xe-x^2-y^2 with interval [-6,6].

Program:

def f(x,y):

return x*e**(-x**2-y**2)

x=linspace(-6,6,85)

y=linspace(-6,6,85)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('x*e**(-x**-y**2)')

show()

Output:

19
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.4 Plot the function z=cos(x^2+y^2-0.5) in internal [-6,6].

Program:

def f(x,y):

return cos(x**2+y**2-0.5)

x=linspace(-1,1,30)

y=linspace(-1,1,30)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,51)

xlabel('x')

ylabel('y')

title('cos(x**2+y**2-0.5)')

show()

Output:

20
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.5 Plot the function z=(sin(4*x)-cos(5*y))/5 in interval [-1,1].

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return (sin(4*x)-cos(5*y))/5

x=linspace(-1,1,30)

y=linspace(-1,1,30)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,51)

xlabel('x')

ylabel('y')

title('(sin(4*x)-cos(5*y))/5')

show()

Output:

21
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.6 Plot the function f(x)=cos(x2+y2-0.5) in the interval [-1,1].(contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(x**2+y**2-0.5)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,200)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

22
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.7 Plot the function f(x)=cos(x2+y2-0.5) in the interval [-1,1].(Surface plot)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(x**2+y**2-0.5)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('surface plot')

show()

Output:

23
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.8 Plot the function f(x)=cos(x2+y2-0.5) in the interval [-1,1].(Wireframe)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(x**2+y**2-0.5)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_wireframe(x,y,z,rstride=3,cstride=3)

xlabel('x')

ylabel('y')

title('wireframe')

show()

Output:

24
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.9 Plot the function f(x)=cos|x+y| in the interval [-1,1].(contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(abs(x)+abs(y))

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour(x,y,z,200)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

25
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.10 Plot the function f(x)=cos|x+y| in the interval [-1,1].(Meshgrid)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(abs(x)+abs(y))

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

26
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.11 Plot the function f(x)=cos|x+y| in the interval [-1,1].(Wireframe)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return cos(abs(x)+abs(y))

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_wireframe(x,y,z,rstride=2,cstride=2)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

27
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.12 Plot the function f(x)=sin(4*x)-cos(5*y) in the interval [-1,1].(contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(4*x)-cos(5*y)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour(x,y,z,200)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

28
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.13 Plot the function f(x)=sin(4*x)-cos(5*y) in the interval [-1,1].(Contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(4*x)-cos(5*y)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('contour')

show()

Output:

29
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.14 Plot the function f(x)=sin(4*x)-cos(5*y) in the interval [-1,1].(surface)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(4*x)-cos(5*y)

x=linspace(-1,1,100)

y=linspace(-1,1,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_wireframe(x,y,z,rstride=2,cstride=2)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

30
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.15 Plot the graph f(x)=sin(x)+cos(y) with interval [-6,6].(contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x)+cos(y)

x=linspace(-5,5,100)

y=linspace(-5,5,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour(x,y,z,200)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

31
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.16 Plot the graph f(x)=sin(x)+cos(y) with interval [-6,6].(Surface)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x)+cos(y)

x=linspace(-6,6,100)

y=linspace(-6,6,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

32
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.17 Plot the graph f(x)=sin(x)+cos(y) with interval [-6,6].(Surface)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x)+cos(y)

x=linspace(-6,6,100)

y=linspace(-6,6,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_wireframe(x,y,z,rstride=2,cstride=2)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

33
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.18 Plot the graph f(x)=x3+y3+x2+y2 with interval [-2,2].(contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return x**3+y**3+x**2+y**2+x+y+5

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour(x,y,z,200)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

34
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.19 Plot the graph f(x)=x3+y3+x2+y2 with interval [-2,2].(

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return x**3+y**3+x**2+y**2+x+y+5

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

35
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.20 Plot the graph f(x)=x3+y3+x2+y2 with interval [-2,2].(Surface)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return x**3+y**3+x**2+y**2+x+y+5

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

36
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.21 Plot the function F(x)=sin(x2+y) with interval of [-2,2]. (Surface)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x**2+y)

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_surface(x,y,z)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

37
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.22 Plot the function F(x)=sin(x2+y) with interval of [-2,2]. (Contour)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x**2+y)

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.contour3D(x,y,z,50)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

38
Dr.D.Y.Patil ACS, Pimpri Pune-18

Q.23 Plot the function F(x)=sin(x2+y) with interval of [-2,2]. (Wireframe)

Program:

from mpl_toolkits import mplot3d

from pylab import*

def f(x,y):

return sin(x**2+y)

x=linspace(-2,2,100)

y=linspace(-2,2,100)

x,y=meshgrid(x,y)

z=f(x,y)

ax=axes(projection='3d')

ax.plot_wireframe(x,y,z,rstride=2,cstride=2)

xlabel('x')

ylabel('y')

title('graph')

show()

Output:

39

You might also like