Question: Please code this i R studio Exercises Let's define a couple of functions to perform basic vector operations with 3-dimensional vectors. Recall that the length
Please code this i R studio

Exercises Let's define a couple of functions to perform basic vector operations with 3-dimensional vectors. Recall that the length of a 3-dimensional vector a=a1,a2,a3 is given by a=a12+a22+a32. 1. Write a function in R which computes the length of a 3-dimensional vector. Call the function "length3". (Why shouldn't we use "length" as the name of the function?) Test your function using the two vectors below and verify that you get the results shown below: v1=c(2,3,6)v2=c(2,4,7)length3(v1)##[1]7length3(v2)##[1]8.306624 Also recall that given two 3-dimensional vectors a=a1,a2,a3 and b=b1,b2,b3, the dot product ab is defined by ab=a1b1+a2b2+a3b3, and the cross product ab is given by ab=a2b3a3b2,a3b1a1b3,a1b2a2b1 2. Write a function called "myvectorops" that takes two 3-dimensional vectors as inputs (let's call them a and b ) and computes four things: (i) a, (ii) b, (iii) ab, and (iv) ab. Try to format the output so that it appears exaclty as shown below (using the same vectors v1 and v2 that we used in the previous exercise): myvectorops (v1, v2) \#\# Basic Vector Operations ##a=2,3,6,b=2,4,7 ##a=7,b=8.306624 \#\# dot product: ab=26 \#\# cross product: a x b =45,26,2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
