Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is the problem I need help with: I need to write the answer in code form, b

ID: 3109821 • Letter: H

Question

Here is the problem I need help with:

I need to write the answer in code form, but not in full code. Somewhere about 3 to 9 lines of code. The answer I was able to come up with is this:

x[n] = b[n] / a[n];   

x[n-1] = (b[n-1] – c[n]*x[n]) / a[n-1];   

for (i = n-2; i > 0; i--){     

        x[i] = (b[i] – c[i+1]*x[i+1] – d[i+2]*x[i+2]) / a[i];   

        for (j = 1; i < n; i++)  

               a[i+1] = a[i+1] – (b[i]/a[i])*c[i+1]; //endfor

}//endfor

I'm not sure if this is the correct answer for this problem.

Write an et algorithm to soluko icient an n x n system On23 with nonzero dia aonals the form I n-3 A-2 n 2. te that A is non singular and that pinating YOU should first convert fo an Upper trt angular

Explanation / Answer

function u=Thomas_alg(a,b,c,f)

n=length(f);

b1(1)=b(1);
f1(1)=f(1);

for i=1:n
c1(i)=c(i);
end

for i=2:n
b1(i)=b(i)-(c1(i-1)*(a(i)/b1(i-1)));
end

for i=2:n
f1(i)=f(i)-(f1(i-1)*(a(i)/b1(i-1)));
end

u(n)=f1(n)/b1(n);

for i=n-1:-1:1
u(i)=(f1(i)-c1(i)*u(i+1))/b1(i);
end

end

%% Without function

a=[1 1 1 1 ]
b=[-2 -2 -2 -2 ]
c=[3 3 3 3]

f=[1 0 0 1]
n=length(f);

b1(1)=b(1);
f1(1)=f(1);

for i=1:n
c1(i)=c(i);
end

for i=2:n
b1(i)=b(i)-(c1(i-1)*(a(i)/b1(i-1)));
end

for i=2:n
f1(i)=f(i)-(f1(i-1)*(a(i)/b1(i-1)));
end

u(n)=f1(n)/b1(n);

for i=n-1:-1:1
u(i)=(f1(i)-c1(i)*u(i+1))/b1(i);
end
u

% reuslt

u =

2.0909 1.7273 0.4545 -0.2727