The sqrt()
function returns the square root of a number:
> sqrt(25)
[1] 5
The command x^2
raises a number of x to the power 2:
> 4^2
[1] 16
However when those functions are applied to a vector or matrix then,
the sqrt()
function returns the square root of each element of a vector or matrix.
The command x^2
raises each element of x
to the power 2; any powers are possible, including fractional or negative powers.
x
and store it in the variable x.sqrt
x
and store it in x.squared
Use the code below as a starting point.