 # Systems of Linear Equations &amp; Finance Problems in Matlab

## Transcribed Text

Question 2: System of linear equations Write your solutions in a script file, as you will need to reuse the code for the second part of the question. (a) Consider the system of linear equations, 312 823 45 321 321 321    xxx xxx xxx . Write this system in matrix form, Ax=b. First show whether there is a valid solution for this system (HINT: A has to be non-singular, so the determinant should be nonzero) then show that the system can be solved in the following ways: I. Find the solution using MATLAB left division command “\“. II. Find the solution by using the inverse of the coefficient matrix bAx 1  . III. Find the solution via the transposed system TTT Abx   in which  1   T T AA In this case we use the right division sign “/” (b) Each of the equations can be rearranged in the form x3=…… Do this and then plot each of the planes in a 3D plot. Add the point which forms the solution to these equations and use your plot to show that the solution is the point where all three planes intersect. (HINT: First create your x and y axes using a vector declaration. Then you will need to use the ‘meshgrid’ command to create two arrays. Calculate the z arrays for each of the three cases using the same X and X arrays, then use the ‘mesh’ command to create the plots.) (c) Now repeat the procedure in (a) and (b) for the following equations, 2  2x 10x 5 2 8 4 1 2 3 1 2 3 1 2 3   3     x x x x x  x  5x . Discuss your results using the 3D plots, as before. Question 3: Writing scripts to calculate yields from investments, or repayments on loans. Each part of this question requires you to write a new script, but if you declare variables carefully, you can reuse your code from previous steps, with some modifications. Write down the equations you need, the variables you will need to declare, etc. before you start. This will help A LOT! (a) You have £1000. Write an equation in Matlab to calculate how much you will have after 1 year. Now write a loop to calculate how much you will have if you invest it in a long term account for 10 years with an annual interest rate of 5%. Declare variables for the initial amount, final amount, interest rate, etc. so that it is easy to change them later. (b) Now consider a situation where the interest rate changes every year. Write a vector to show the interest rate in each year, using the following data: 5%, 4%, 4.5%, 3%, 2%, 2%, 1%, 1%, 2.5%, 2%. Modify the loop you have created in (a) to calculate the cash you will have after 10 years. (c) Now consider a related question. How long will it take for you to double your money? Write a script to see how many years you will need to wait to double your money. Show your results for 5% and 7% annual interest rates. (d) Now consider that you have a loan on your credit card of £1000. You make repayments every month of £50. The monthly interest rate is 3%. How long will it take you to pay back the loan? (e) Now consider that the interest rate from part (c) goes up to 5%. Run the script again. What happens? How should you improve the script in this case? (HINT: If you’re not sure what is happening, show the current loan amount on the screen after each step.)

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function main()
%a)
A=[1 1 5; 3 2 1; -2 1 -1];
b=[4;8;-3];

determinantA = det(A)
%1.
x1=A\b
%2.
x2=inv(A)*b
%3.
x3=(b'/A')'
%(b)
x=linspace(-5,5,50);
y=linspace(-5,5,50);
z=linspace(-5,5,50);
[X,Y]=meshgrid(x,y);
surf(X,Y,x1(3)*ones(size(X)));
hold on
surf(X,x1(2)*ones(size(X)),Y);
surf(x1(1)*ones(size(X)),X,Y);
hold off
xlabel('axis x');
ylabel('axis y');
zlabel('axis z');
title('Intersection 1');

str1='intersection point x';
text(x1(1),x1(2),x1(3),str1, 'FontSize',19);...
\$58.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available MATLAB for Mathematics Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.