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

Q.1) Using Python Plot The Graph of Function F (X) X 3 On The Interval (-5,5) - Ans

The document is a practical assignment for a computer science course, detailing the plotting of various mathematical functions using Python. It includes code snippets for plotting functions such as f(x)=x**3, f(x)=cos(x), f(x)=e**x, and others over specified intervals. Each section provides the necessary imports, data generation, and plotting commands to visualize the functions.

Uploaded by

gostperson12
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)
69 views6 pages

Q.1) Using Python Plot The Graph of Function F (X) X 3 On The Interval (-5,5) - Ans

The document is a practical assignment for a computer science course, detailing the plotting of various mathematical functions using Python. It includes code snippets for plotting functions such as f(x)=x**3, f(x)=cos(x), f(x)=e**x, and others over specified intervals. Each section provides the necessary imports, data generation, and plotting commands to visualize the functions.

Uploaded by

gostperson12
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/ 6

Practical NO.

Name :- Abhang Sanket Bansi

Class:- S.Y.B.sc(computer science)


Div:-B Batch:-F
Roll No:-
Subject:- MTC 242 MNP Practical on Mathematics for computer Science -
1
Title: Plotting of the graph of function y=f(x) against x

Date:- 16/07/2025

__________________________________________________________________________
Q.1 ) Using python plot the graph of function f(x)=x**3 on the interval [-5,5].
Ans:
from math import*
from pylab import*
import numpy as np
x=np.linspace(-5,5,100)
y=x**3
plot(x,y,label="x***3")
xlabel('x-axis')
ylabel('y-axis')
title('Graph of y=x**3')
legend()
show()
Q.2 ) Using python plot the graph of function f(x)=cosx on the interval [0,2 π ].
from math import*
from pylab import*
import numpy as np
x=np.linspace(-10,10,100)
y=e**x
plot(x,y,'r', label="e")
xlabel('x-axis')
ylabel('y-axis')
title('Graph of y=e**x')
legend()
legend()
show()
Q.3 ) Using python plot the graph of function f(x)=e**x on the interval [-10,10].

from math import*


from pylab import*
import numpy as np
x=np.linspace(-10,10,20)
y=e**x
plot(x,y,'r',label="e**x")
xlabel('x-axis')
ylabel('y-axis')
title('Graph of y=e^x')
legend()
show()
Q.4 ) Using python plot the graph of function f(x)=1+x+2*x**2+3*x**3+4*x**4 on the
interval [-10,10].

from math import*


from pylab import*
import numpy as np
x=np.linspace(-10,10,2)
y=1+x+2*x**2+3*x**3+4*x**4
plot(x,y,'r',label="1+x+2*x**2+3*x**3+4*x**4")
xlabel('x-axis')
ylabel('y-axis')
title('Graph of y=1+x+2*x**2+3*x**3+4*x**4')
legend()
show()
Q.5 )Using python plot the graph of function f(x)=log(x)**2+sin(x) on the interval [-5π,5
π ].
Ans:
from math import*
from pylab import*
import numpy as np
x=np.linspace(-5*pi,5*pi,20)
y=log(x)**2+sin(x)
plot(x,y,'b',label="log(x)**2+sin(x)")
xlabel('x-axis')
ylabel('y-axis')
title('Graph of y=log(x)**2+sin(x)')
legend()
show()

You might also like