Question

In: Mechanical Engineering

% Consider the following system of equations: % -2a +5b + c + 3d + 4e...

% Consider the following system of equations:
% -2a +5b + c + 3d + 4e - f = 0
% 2a - b - 5c - 2d + 6e + 4f = 1
% -a + 6b - 4c - 5d + 3e - f = -6
% 4a + 3b - 6c - 5d - 2e - 2f = 10
% -3a + 6b + 4c + 2d - 6e + 4f = -6
% 2a + 4b + 4c + 4d + 5e - 4f = -2

% a)
% Define a symbolic variable for each of the equation and use symbolic
% capability to solve for each unknown. Convert your results to doubles.

% Answer

% b)
% Compare the amount of time it takes to solve the system of equations
% using left division and symbolic math by using the tic and toc function.

% Answer

Solutions

Expert Solution

a) Matlab Code:

clc;
clear;
tic
syms a b c d e f

%A*B=D
A=[-2,5,1,3,4,-1;2,-1,-5,-2,6,4;-1,6,-4,-5,3,-1;4,3,-6,-5,-2,-2;-3,6,4,2,-6,4;2,4,4,4,5,-4];   
D=[0;1;-6;10;-6;-2];
B=[a;b;c;d;e;f];
sol = solve(A*B==D,a,b,c,d,e,f);
double B;
B=[sol.a;sol.b;sol.c;sol.d;sol.e;sol.f]
timerVal = toc

Outbut:

b) above image shows

time taken for a) is 0.4679 sec,

using left division  method:

Matlab Code:

clc;
clear;
tic
A=[-2,5,1,3,4,-1;2,-1,-5,-2,6,4;-1,6,-4,-5,3,-1;4,3,-6,-5,-2,-2;-3,6,4,2,-6,4;2,4,4,4,5,-4];
D=[0;1;-6;10;-6;-2];

double X;
X = A\D
timerVal = toc

Output:

Time for left division is very small compared to first part

time = 5.8415e-04 sec,


Related Solutions

If possible, find A + B, A − B, 2A, and 2A − 5B. (If not...
If possible, find A + B, A − B, 2A, and 2A − 5B. (If not possible, enter IMPOSSIBLE.) A = 3 −1 1 2 4 3 ,    B = −1 1 −5 −4 3 −2 (a)    A + B (b)    A − B (c)    2A (d)    2A − 5B
Consider the following system of equations for all problems. The following system of equations is designed...
Consider the following system of equations for all problems. The following system of equations is designed to determine concentrations (the c’s in g/m3) in a series of coupled reactors as a function of the amount of mass input to each reactor (the right-hand sides in g/day). 8?1 − 4?2 − 2?3 = 2000 −3?1 + 18?2 − 6?3 = 1400 −4?1 − 2?2 + 12?3 = 3000 Calculate and interpret the condition number. Use the row-sum norm. Scale the coefficient...
Consider the following reaction at 283 K: 2A + B → C + D where rate...
Consider the following reaction at 283 K: 2A + B → C + D where rate = k[A][B]2. An experiment was performed where [A]o = 2.67 M and [B]o = 0.00241 M. A plot of 1/[B] vs. time has a slope of 10.01. What will the rate of this reaction be when [A] = [B] = 0.345 M?
1. Consider the following generic reaction: 2A + B + C -> 2D +3E From the...
1. Consider the following generic reaction: 2A + B + C -> 2D +3E From the following initial rate determinations, write the rate law for the reaction, determine the overall order for the reaction and calculate the rate constant, k. Initial rate [A] [B] [C] 1.27x10^-4 Ms^-1 0.0125M 0.0125M 0.0125M 2.56x10^-4 Ms^-1 0.0250M   0.0125M 0.0125M 1.27x10^-4 Ms^-1 0.0125M   0.0250M 0.0125M 5.06x10^-4 Ms^-1 0.0125M 0.0125M 0.0250M 2. Consider the following reaction and its rate law: 2N2O5 -> 4NO2 + O2; rate...
Consider an economy represented by the following expenditure equations (in $ trillion): Y = C +...
Consider an economy represented by the following expenditure equations (in $ trillion): Y = C + I + G + NX C = 2 + ⅔(Y – T) I = 6 – r G = 4, T =3, NX = -1 What is the equation for the IS curve, Y=f(r)? For the short run, consider the inflation rate fixed at π = 2. The Central Bank wants to target the real interest rate r = 2. What should be the...
Consider an economy represented by the following expenditure equations (in $ trillion): Y = C +...
Consider an economy represented by the following expenditure equations (in $ trillion): Y = C + I + G + NX C = 2 + ⅔(Y – T) I = 6 – r G = 4, T =3, NX = -1 For the short run, consider the inflation rate fixed at π = 2. The Central Bank wants to target the real interest rate r = 2. What should be the target for the nominal interest rate, i? What is...
Consider an economy described by the following equations: Y = C + I + G +...
Consider an economy described by the following equations: Y = C + I + G + NX Y = 8,100 G = 2,300 T = 2,100 C = 500 + 2/3 (Y – T) I = 900 – 50r NX = 1,500 – 250e r = r* = 8. a. (4 points) In this economy, solve for private saving, public saving, national saving, investment, the trade balance, and the equilibrium exchange rate. b. (3 points) Suppose now that G is...
2. Consider a Keynesian model of the economy with the following equations: C = 300 +...
2. Consider a Keynesian model of the economy with the following equations: C = 300 + 0.7Yd Transfer payments = 500 T = 0.1Y I = 300 G = 400 X = 150 M = 0.2Y (a) Calculate the equilibrium income level. (b) Government spending on goods and services increases by 50. Calculate the new equilibrium level of income. (1 mark) (c) If potential GDP is 2,750 what is the size of the output gap between potential and actual GDP...
Consider a general system of linear equations with m equations in n variables, called system I....
Consider a general system of linear equations with m equations in n variables, called system I. Let system II be the system obtained from system I by multiplying equation i by a nonzero real number c. Prove that system I and system II are equivalent.
Consider an economy described by the following equations: Y = C + I + G Y...
Consider an economy described by the following equations: Y = C + I + G Y = 5000 G = 1000 T = 1000 C = 250 + .75 (Y - T) I = 1000 - 50r a. In this economy, compute private saving, public saving, and national saving b. Find the equilibrium interest rate c. Now suppose that G rises to 1250. Compute private saving, public saving, and national saving d. Find the new equilibrium interest rate.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT