Mse Practical
Mse Practical
Mse Practical
Ques 1
a.
a = np.array([4,3,2]) # vector u
b = np.array([8,5,6]) # vector v:
b_norm = np.sqrt(sum(b**2))
a_norm = np.sqrt(sum(a**2))
B.
ax = plt.axes(projection='3d')
t = np.linspace(0,5,1000)
X = (4+np.sin(20*t))*np.cos(t)
Y = (4+np.sin(20*t))*np.sin(t)
Z = np.cos(20*t)
ax.plot3D(x, y, z, 'green')
t=Symbol('t')
vec=[X, Y, Z]
diffvec=[]
for el in vec:
diffvec.append(diff(el,t))
tmp = 0
for elem in diffvec:
tmp = simplify(tmp + elem**2)
tmp
arc_length=Integral(tmp**(1/2), (t,1,2)).doit()
print("The arc length is", arc_length)
arc_length
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-21-f1e683e42944> in <module>
18 tmp = 0
19 for elem in diffvec:
---> 20 tmp = simplify(tmp + elem**2)
21 tmp
22 arc_length=Integral(tmp**(1/2), (t,1,2)).doit()
QUES 2
A. i
In [24]: x, y= np.meshgrid(range(10),range(10))
z=np.tan(x)
ax= plt.figure().gca(projection='3d')
ax.plot_surface(x,y,z)
plt.title("Plane")
ax.set_xlabel('$X$')
ax.set_ylabel('$Y$')
ax.set_zlabel('$Z$')
plt.show()
A. ii.
%matplotlib inline
x=np.arange(-10,10,0.1)
y=np.arange(-10,10,0.1)
X,Y=np.meshgrid(x,y)
Z=9*(((X)**2)/9 + ((Y)**2)/16 - 1)*(1/2)
fig=plt.figure(figsize=(6,6))
ax=fig.add_subplot(111,projection='3d')
ax.plot_surface(X,Y,Z)
plt.show()
A. iii.
In [25]: x, y= np.meshgrid(range(10),range(10))
z=(8*x**2-y)
#plot the surface
ax= plt.figure().gca(projection='3d')
ax.plot_surface(x,y,z)
plt.title("Plane")
ax.set_xlabel('$X$')
ax.set_ylabel('$Y$')
ax.set_zlabel('$Z$')
plt.show();
B.
In [26]: init_printing()
t=Symbol('t')
r=Matrix([t+1, t**2+1, 2*t])
v=simplify(diff(r,t))
speed=sqrt(sum(matrix_multiply_elementwise(v, v)))
A=simplify(diff(v,t))
print("Position vector, r(t)=",r[0]," i + ",r[1]," j + ", r[2], " k")
print("Velocity vector, v(t)=",v[0]," i + ",v[1]," j + ", v[2], " k")
print("Speed, |v(t)|=",speed)
print("Acceleration, a(t)=",A[0]," i + ",A[1]," j + ", A[2], " k")
r_p=r.subs(t, 7*pi/4)
v_p=v.subs(t, 7*pi/4)
speed_p=speed.subs(t, 7*pi/4)
tan_p=simplify(r_p+(v_p/speed_p))
ax = plt.axes(projection='3d')
t = np.linspace(0, 10, 1000)
X = t+1
Y = t**2+1
Z = 2*t
X_tan=np.array([float(r_p[0]), float(tan_p[0])])
Y_tan=np.array([float(r_p[1]), float(tan_p[1])])
Z_tan=np.array([float(r_p[2]), float(tan_p[2])])
ax.plot3D(X, Y, Z)
ax.plot3D(X_tan, Y_tan, Z_tan)
In [ ]: