#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))
Get Answers For Free
Most questions answered within 1 hours.