Question: question s: sonving a set on ninear equations ( In this question, you are supposed to use array structures. ) As industrial engineers, we often

question s: sonving a set on ninear equations
(In this question, you are supposed to use array structures.)
As industrial engineers, we often deal with a set of linear equations. Although there are
exact methods to solve them, they require too much computational effort. Therefore, some
approximation methods have been developed. This question addresses one of them and gives a
small example.
Suppose that you have the following set of linear equations:
a11x1+a12x2+dots+a1nxn=b1
a21x1+a22x2+dots+a2nxn=b2
an1x1+an2x2+dots+axn=bn
In this set aij's correspond to the coefficients of the variables xj's of the ithe equation, and
bi to the right-hand side constants, where i=1,dots,n and j=1,dots,n.
The linear equations are rewritten so that the first equation is solved for x1, the second for
x2 and so on. In other words, the followings are obtained:
x1=b1-a12x2-dots-a1nxna11
x2=b2-a21x1-dots-a2nxna22
vdots
xn=bn-an1x1-dots-an,n-1xn-1a
The method starts with an initial solution, say x(0)=(x1(0),x2(0),dots,xn(0)). One may take
any value to start (note that changing the initial solution only affects the number of iterations
needed to approximate the solution).
In each iteration, current value of x(i) is used to calculate the new solution x(i+1). For
example, x1(0),x2(0),dots,xn(0) are substituted in the equations given in (1), and the left-hand side
gives the new solution as x(1). Continuing in this manner, approximate the real solution.
Consider the numerical example below with the application of the iterative approximation
method.
5x1-2x2+3x3=-1
-3x1+9x2+x3=2
2x1-x2-7x3=3
When we rearrange the equations we get,
x1=-1+2x2-3x35
x2=2+3x1-x39
x3=-3+2x1-x27
Taking the initial solution as x(0)=(0,0,0), we get (x1(1),x2(1),x3(1))=(-15,29,-37) at the end
of the first iteration. With the obtained x(1), we continue the procedure. We substitute the
values in the formulations in (1) and get x(2) as (x1(2),x2(2),x3(2))=(46315,64315,-163315). The method
iterates until the stopping criterion is reached.
Your task is to write a MATLAB script that works on the following set of linear equations:
9x1+x2+x3+2x4=12
2x1+10x2+3x3-x4=18
3x1+4x2+11x3+x4=1
x1+2x2-x3+x4=7
with three different initial solutions:
x(0)=(x1(0),x2(0),x3(0),x4(0))=(0,0,0,0),
y(0)=(y1(0),y2(0),y3(0),y4(0))=(10,10,10,10),
z(0)=(z1(0),z2(0),z3(0),z4(0))=(1,1,1,1).
Take the stopping criterion as the error between the current and previous solution. In other
words, if you are at iteration k, the error is
Error =(x1k-x1k-1)2+(x2k-x2k-1)2+(x3k-x3k-1)2+(x4k-x4k-1)22
Continue until the error is less than the stopping criterion. In this homework, consider three
different stopping criteria as 10-2,10-4, and 10-6. Report your results as given in the output
format and comment on your results by putting your explanations as comment lines at the end
of your script.
question s: sonving a set on ninear equations (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!