Solving linear equations in Matlab

61 Views Asked by At

I am trying to solve the problem $Ac = b$ but I am having difficulty figuring out how to set it up. I thought multiplying by ${\rm e}$ would remove the $\ln$ but I guess I forgot my basic math. My attempt was:

EDU>> A = [2 1 3 -2; 4 3 1 -1; 1 1 1 1; 1 1 -1 -1];
EDU>> b = [exp(-6); exp(-2); exp(-5); exp(5)];

EDU>> c = A\b

c =

 -346.0869
  420.2969
   24.6946
  -98.8978

When re-entering the answers into a calculator manually it was obvious it was wrong even by just looking at the output. Any ideas? Thanks!!!!!!!!!!! enter image description here

1

There are 1 best solutions below

0
On

We are treating the problem as a system of linear equations of $\ln w,\ln x,\ln y$ and $\ln z$. You may test the code at Octave Online.

A = [2 1 3 -2; 4 3 1 -1; 1 1 1 1; 1 1 -1 -1];
b = [-6 -2 -5 5]';
c = A\b;
ans =

  -1
   1
  -3
  -2

exp(c)
ans =

   0.367879
   2.718282
   0.049787
   0.135335

Therefore, $(w,x,y,z) = (e^{-1},e,e^{-3},e^{-2})$.