Question

Create vectors x=(1,2,...,10) and y=(2,2^2,...,2^10). Then compute the Euclidean distance and inner product between x and...

Create vectors x=(1,2,...,10) and y=(2,2^2,...,2^10). Then compute the Euclidean distance and inner product between x and y, respectively.

( Use R language and Do Not use "for")

Homework Answers

Answer #1

#creating vector x using sequence function
print('Vector x is : ')
x=print(seq(1, 10, by = 1))

#seq function will create an array till 10 with the difference of 1 unit

#creating vector y=(2,2^2,2^3,...,2^10) using function  `^`(2,vector x)
print('Vector y is :')
y=print(`^`(2,x))  


print('Vector x-y is :')
sub.result <- x-y
print(sub.result)

#Euclidean distance between x and y
Euclidean_Distance<-sum(abs(x-y)^2)^(1/2)
print('Euclidean distance between x and y is: ')
print(Euclidean_Distance)

#Inner product between x and y
Inner_product <- x*y
print('Inner product between x and y is: ')
print(sum(Inner_product))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
3. a. Consider R^2 with the Euclidean inner product (i.e. dot product). Let v = (x1,...
3. a. Consider R^2 with the Euclidean inner product (i.e. dot product). Let v = (x1, x2) ? R^2. Show that (x2, ?x1) is orthogonal to v. b. Find all vectors (x, y, z) ? R^3 that are orthogonal (with the Euclidean inner product, i.e. dot product) to both (1, 3, ?2) and (2, 7, 5). C.Let V be an inner product space. Suppose u is orthogonal to both v and w. Prove that for any scalars c and d,...
Prove the Inner Product properties. *Please use your vectors as x,y,z*
Prove the Inner Product properties. *Please use your vectors as x,y,z*
first use Gram-Schmidt on x1, x2 to create orthogonal vectors v1 and v2 with the same...
first use Gram-Schmidt on x1, x2 to create orthogonal vectors v1 and v2 with the same span as x1, x2. Now use the formula p =((y, v1)/(v1, v1))v1 + ((y, v2)/(v2, v2))v2 to compute the projection of y onto that span. Of course, replace the inner product with the dot product when working with standard vectors 1) Compute the projection of y = (1, 2, 3)  onto span (x1, x2) where x1 =(1, 1, 1) x2 =(1, 0, 1) The inner...
Orthogonalize the basis vectors in the spanning set p=2x=1 and q=3x+2 with the inner product of...
Orthogonalize the basis vectors in the spanning set p=2x=1 and q=3x+2 with the inner product of p and q defined to be the evaluation inner product evaluated at x=-1 and x=2. Use gram Schmidt to orthogonalize.
first use Gram-Schmidt on x1, x2 to create orthogonal vectors v1 and v2 with the same...
first use Gram-Schmidt on x1, x2 to create orthogonal vectors v1 and v2 with the same span as x1, x2. Now use the formula p =((y, v1)/(v1, v1))v1 + ((y, v2)/(v2, v2))v2 to compute the projection of y onto that span. Of course, replace the inner product with the dot product when working with standard vectors 2) Compute the projection of y = (1, 2, 2, 2, 1)  onto span (x1, x2) where x1 =(1, 1, 1, 1, 1)   x2 =(4,...
Let V be a finite dimensional vector space over R with an inner product 〈x, y〉...
Let V be a finite dimensional vector space over R with an inner product 〈x, y〉 ∈ R for x, y ∈ V . (a) (3points) Let λ∈R with λ>0. Show that 〈x,y〉′ = λ〈x,y〉, for x,y ∈ V, (b) (2 points) Let T : V → V be a linear operator, such that 〈T(x),T(y)〉 = 〈x,y〉, for all x,y ∈ V. Show that T is one-to-one. (c) (2 points) Recall that the norm of a vector x ∈ V...
Find the area of the indicated region. between y=2x^2+6x-3 and y=-x^2+3x+3 for x in [-2,2]
Find the area of the indicated region. between y=2x^2+6x-3 and y=-x^2+3x+3 for x in [-2,2]
If X and Y are vectors of magnitude 1 and 2, respectively, with an angle of...
If X and Y are vectors of magnitude 1 and 2, respectively, with an angle of 120º between them. Determine I3X + 2YI and the direction of vector 3X + 2Y. Vectors are 2D
In MATLAB, generate a 3D plot as follows: Create 2 vectors x and y, both ranging...
In MATLAB, generate a 3D plot as follows: Create 2 vectors x and y, both ranging from -5 to 5 with interval of 0.05 using linspace or colon operator. Generate grid of values X and Y using the vectors x and y. Define the variable Z as follows: Z = 2X3 + 4Y2 + 7 +sinX3 + Y2 Generate a surface and a mesh plot with the variables X,Y,Z. Show your plots.
Let R be the region in enclosed by y=1/x, y=2, and x=3. a) Compute the volume...
Let R be the region in enclosed by y=1/x, y=2, and x=3. a) Compute the volume of the solid by rotating R about the x-axis. Use disk/washer method. b) Give the definite integral to compute the area of the solid by rotating R about the y-axis. Use shell method.  Do not evaluate the integral.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT