Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Develop a program which computes the current value of the vector {x} based on the following forward iteration: {x}(n+1) = [K] {x}(n), n = 0,1,2, ....

Develop a program which computes the current value of the vector {x}based on the following forward iteration: {x}(n+1) = [K] {x}(n), n = 0,1,2, ... ,8,9.In other words, the next vector {x} is equal to the product of [K] and the current vector {x}.Perform the matrix multiplication by using the function:void matrix_mult(double a[4][4], double b[4], double c[4], int rows);You should pass the matrix [K] and a vector {x} to matrix_mult() which will pass back a new vector {y} ).[K] is a constant 4x4 matrix defined by:double K[4][4] = { { 2., -4., 1., 0.},{ -4., 5., -2., 1.},{ 1., -2., 6., -3.},{ 0., 1., -3., 7.}};The initial components of the vector {x}(0) are specified by:double x[4] = { 1./3., 2./3., 1./3., pow(3.,0.5)/3.};First, print the value of the initial vector {x}(0) on the screen. Then, perform forward iteration 10 times (for n=0 to 9). Each time after new vector is computed from [K]{x}, normalize that vector byusing the function double unit_vec(double vec[4], int cols)which was discusseed in class (see Program w8-5.c; this functiontransforms a vector to a unit vector - of magnitude 1). For thematrix multiplication with the vector [K]{x}, see Program w8-3.c .Always use the normalized vector as the vector {x}(n) for the nextiteration. For each iteration, print the new vector, its length, and the normalized new vector in main().*//* Use the skeleton below to build your program *//* Insert the needed statements at ..... places */#include <stdio.h>#include <math.h>double unit_norm(double vec[4], int cols);void matrix_mult(double a[4][4], double b[4], double c[4], int rows);main(){ double K[4][4] = { { 2., -4., 1., 0.},{ -4., 5., -2., 1.},{ 1., -2., 6., -3.},{ 0., 1., -3., 7.}}; double y[4], x[4] = { 1./3., 2./3., 1./3., pow(3.,0.5)/3.};// Enter your C statements ..................................................}void matrix_mult(double a[4][4], double b[4], double c[4], int rows){....................................................return;}double unit_norm(double vec[4], int cols){double sum;// normalize a vector......................................................return sum;}/* Your output should look like:Initial vector:0.577350]New vector:3.708119]The length of this vector is: 4.551322Normalized new vector:0.814734]...New vector:6.293838]The length of this vector is: 10.974897Normalized new vector:0.573476]*/

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question