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()