Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is what i have before this question clc; clear all n=30; A1=diag(linspace(-2,-2,n)); A2=diag(linspace(1,1,n-1),1); A3=diag(linspace(1,1,n-1),-1); A=A1+A2+A3 t=transpose(linspace(0,pi,n)) b=cos(5*t)+0.5*sin(7*t) X=A file=fopen('A1.dat','w'); for i=1:n for j=1:n fprintf(file,'%f

This is what i have before this question

clc;

clear all

n=30;

A1=diag(linspace(-2,-2,n));

A2=diag(linspace(1,1,n-1),1);

A3=diag(linspace(1,1,n-1),-1);

A=A1+A2+A3

t=transpose(linspace(0,pi,n))

b=cos(5*t)+0.5*sin(7*t)

X=A

file=fopen('A1.dat','w');

for i=1:n

for j=1:n

fprintf(file,'%f ',A(i,j));

end

fprintf(file,' ');

end

fclose(file);

file=fopen('A2.dat','w');

for i=1:n

fprintf(file,'%f ',b(i));

fprintf(file,' ');

end

fclose(file);

file=fopen('A3.dat','w');

for i=1:n

fprintf(file,'%f ',X(i));

fprintf(file,' ');

end

fclose(file);

image text in transcribed

Jacobi Iteration Jacobi iteration can be written succinctly as starting with an initial guess xo, and calculating iterates according to the formula Here A- D +T, with D a diagonal matrix whose entries match the diagonal entries of A, and T containing all remaining entries of A We can write the Jacobi iteration even more succinctly by defining so that Problem 2 (Scorelator) Lear nang goal: Use the diag, or triu and tril commands. Learnng goal: Implement the Jacob iterative method for solving Arb. Define the matrices D and T in MATLAB. Look up and use the diag command to define D. Use DT. and b to define M and g for this problem Implement Jacobi iteration to solve the problem A-b. Use an initial guess of all zeros and iterate for 400 iterations. Save the 2-norm of the error of each iterate, ITtrue- Tiacobi Note: In this homework I am not counting the initial guess as an iterate. Save the final iterate to file as A4.dat. Save the errors of the iterates to file as A5.dat. , to a save vector. jacobi ll2

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_2

Step: 3

blur-text-image_3

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions