



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
mathematics 123 linear algebra mathematics
Typology: Exercises
1 / 6
This page cannot be seen from the preview
Don't miss anything!




One of the main strengths of MATLAB is that it provides an excellent tool for working with large matrices. This week’s lab class introduces some useful MATLAB commands for doing this. You will see how MATLAB is used for solving systems of linear equations.
Exercise 1: Row Reduction
The most basic command for doing row operations is the reduced row echelon form function:
R=rref(A)
The result is the reduced row echelon form of the matrix A.
(a)
Use the rref command to calculate the reduced row-echelon form of the following matrix.
rref(B)=
Notice that MATLAB has absolutely no difficulty dealing with awkward decimals, unlike humans. In real world applications, you are more than likely to get ugly numbers, and also very large matrices, so software like MATLAB can be an immense time saver.
(b)
Solve the following system of equations, with the help of the rref command:
4 x 1 + 4 x 2 − 4 x 3 − 2 x 4 + 5 x 5 = − 5 − x 1 − 5 x 2 + 9 x 3 − 2 x 4 − 5 x 5 = 14 12 x 1 + 12 x 3 + 13 x 4 + 9 x 5 = − 1 − 7 x 1 − 7 x 3 + 11 x 4 + 14 x 5 = − 14
Answer:
x 1 x 2 x 3 x 4 x 5
Hint: MATLAB has already done some of the work for us in part (a), but you must do the rest by hand.
Exercise 2: Chocolate!
A chef makes three kinds of dessert: Truffles, Torrone and Fudge. Each is made from the same three ingredients, Dark, Plain and White chocolate, though in different amounts. Truffles use 75g of each kind; Torrone uses 50g of Dark, 170g of Plain and 240g of White; and Fudge uses 150g Dark, 80g Plain and 10g White.
The chef has 650g of Dark, 560g of Plain and 420g of White chocolate remaining at the end of the year. She wants to use all of the remaining chocolate.
How many of each type of dessert should she make to use up all remaining chocolate?
Step 1: Define variables
Complete the statements below to define some variables.
Let x = ................................................................................................................................
y = ................................................................................................................................
z = ................................................................................................................................
Step 2: A system of equations
Write down a system of equations describing the problem.
Step 3: Convert to a matrix
Express your system of equations as an augmented matrix M :
Enter the matrix M into MATLAB.
Step 4: Solve
Use MATLAB to row reduce the matrix M.
The RREF of M is
Step 5: Interpret
How many of each dessert should the chef make?
Truffles: (^) .................................... Torrone: (^) .................................... Fudge: (^) ....................................
Let’s check our answer by plotting the points and the polynomial.
The command for plotting a set of points in MATLAB is scatter
Enter the command »help scatter and read about the syntax of the scatter command.
The scatter command requires the x -co-ordinates and the y -co-ordinates of the points to plot to be in separate matrices.
Enter the x -co-ordinates of the points P 1 to P 4 into a row matrix: »xvalues = [-3 -1 1 2] Now enter the y -co-ordinates into a row matrix called yvalues. Finally, run the command »scatter(xvalues,yvalues)
A plot of the points will appear in a graphics window. Check that it looks like the plot on the previous page.
To plot the polynomial, we can use MATLAB’s fplot command.
Run the commands »hold on »fplot( @ (x)ax∧3+bx∧2+c*x+d,[-4,4])
(The fplot command might produce some warning messages, but you can ignore them this time.)
The hold on command tells MATLAB that we want to draw the second plot on the same axes as the first plot, ie, we want the two plots displayed together.
The fplot command plots the polynomial. The first parameter is the function to plot; the @ (x) tells MATLAB that we are talking about a function of x. The second parameter specifies the range for x : in our case, − 4 ≤ x ≤ 4.
Does your cubic pass through the four points?
Exercise 4: An Economics Model
Industry 3: Energy
Industry 2: Agriculture
e 2 ,
e 2 , 3 e 3 , 2
e 3 , 3
e 1 , 3
e 3 , 1
e 2 , 1
Industry 1 :^ e^1 ,^2 Manufacturing
e 1 , 1
The techniques of linear algebra are core techniques used in modelling economic systems. In this exercise we look at a simple economic model based on the work of Nobel Laureate Wassily Leontief.
Consider an economy (e.g., for a country or region) consisting of 3 industries: manufacturing ( I 1 ), agriculture ( I 2 ) and energy ( I 3 ). Each industry produces one type of product. To produce its product, each industry consumes some of the products pro- duced by the other industries, including itself (for instance, a farm needs to keep aside some of the grain it produces to plant next year).
We will assume that the economy is closed - no products are ex- ported or imported - and that the total amount of each product produced annually is fixed. Let
ej,k = the proportion of the total annual production of industry Ik which is used by industry Ij.
For example, if e 2 , 3 = 0_._ 6 then 60% of the total energy produced annually is used in agriculture.
Let pj = the total value (in $) of the annual production of industry Ij.
Then the cost to industry Ij of its annual production will be
total cost = ej, 1 p 1 + ej, 2 p 2 + ej, 3 p 3
If the industry is to recoup its costs then the total price it charges for its annual production, pj , must equal the production costs: pj = ej, 1 p 1 + ej, 2 p 2 + ej, 3 p 3_._
This must hold for all industries, so we have a system of equations:
e 1 , 1 p 1 + e 1 , 2 p 2 + e 1 , 3 p 3 = p 1 e 2 , 1 p 1 + e 2 , 2 p 2 + e 2 , 3 p 3 = p 2 e 3 , 1 p 1 + e 3 , 2 p 2 + e 3 , 3 p 3 = p 3
Suppose that e 1 , 1 = 0_._ 2 e 1 , 2 = 0_._ 1 e 1 , 3 = 0_._ 2 e 2 , 1 = 0_._ 4 e 2 , 2 = 0_._ 5 e 2 , 3 = 0_._ 6 e 3 , 1 = 0_._ 4 e 3 , 2 = 0_._ 4 e 3 , 3 = 0_._ 2
Can we find prices pj for each industry to charge so that all industries recoup their costs?
What variables do we need to solve for? (^) ....................................................................
Write down a homogeneous system of equations describing the problem.