Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions