Answer to Question #281736 in Python for abhiman

Question #281736

. Define the following vectors and matrices:

vec1 = np.array([ -1., 4., -9.])

mat1 = np.array([[ 1., 3., 5.], [7., -9., 2.], [4., 6., 8. ]]

Perform the following operations on the vector and matrices given above:

a. You can multiply vectors by constants.

Compute vec2 = (np.pi/4) * vec1

b. The cosine function can be applied to a vector to yield a vector of cosines.

Compute 1 vec2 = np.cos( vec2 )


1
Expert's answer
2021-12-21T17:20:53-0500
import numpy as np
vec1 = np.array([ -1., 4., -9.])
mat1 = np.array([[ 1., 3., 5.], [7., -9., 2.], [4., 6., 8. ]])
vec2 = (np.pi/4) * vec1
vec3 = np.cos( vec2 )
print(vec2, vec3)

# Output
# [-0.78539816  3.14159265 -7.06858347] [ 0.70710678 -1.          0.70710678]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS