Welcome to R Write a script to solve these Problems. Submit your Question and Answers to [email protected] 1. Create a vector of the values of ex cos(x) at x = 3, 3.1, 3.2, . . . , 6. 2. Create the following vectors: (a) (0.13 0.2 1, 0.1 60.2 4,β¦, 0.1 360.2 34) (b) ( 2, 22 23 2 , 3 ,β¦ , 225 25 ) 1. Calculate the following: 3 2 (a) β100 π=10(π + 4π ) 2π 3π π π (b) β25 π=1 ( + 2 ) 2. By using the function cumprod or otherwise, calculate 1+ 2 24 246 2 4 38 ) + β―+ ( β¦ ) +( )+( 3 35 357 3 5 39 3. Solve the following system of linear equations in five unknowns x1 + 2x2 + 3x3 + 4x4 + 5x5 = 7 2x1 + x2 + 2x3 + 3x4 + 4x5 = β1 3x1 + 2x2 + x3 + 2x4 + 3x5 = β3 4x1 + 3x2 + 2x3 + x4 + 2x5 = 5 5x1 + 4x2 + 3x3 + 2x4 + x5 = 17 By considering an appropriate matrix equation Ax = y. Make use of the special form of the matrix A. The method used for the solution should easily generalise to a larger set of equations where the matrix A has the same structure; hence the solution should not involve typing in every number of A. 4. Write a function tmpFn(xVec) such that if xVec is the vector x = (x1, . . . , xn) then tmpFn(xVec) returns the vector of moving averages: π₯1 + π₯2 + π₯3 π₯2 + π₯3 + π₯4 (π₯πβ2 + π₯πβ1 + π₯π ) , ,..., 3 3 3 Try out your function; for example, try tmpFn( c(1:5,6:1) ). 5. Suppose x0 = 1 and x1 = 2 and π₯π = π₯πβ1 + 2 πππ π = 1,2, β¦ π₯ (π β 1) Write a function testLoop which takes the single argument n and returns the first n β 1 values of the sequence {xj}jβ₯0: that means the values of x0, x1, x2, . . . , xnβ2.
© Copyright 2025 Paperzz