Q:

Why is MATLAB returning different results for the same linear system?

I have this 4x4 system

where the variables are Eor, Eot, Eo2r and Eo2t (i.e., Eo, d, n1, n2, n3, g2 and g3 are known complex numbers).
I'm interested in finding not the variables themselves but these other values:
p_tot = Eor/Eo;
t_tot = Eot/Eo;
p_1 = Eo2r/Eo;
t_1 = Eo2t/Eo;

I tried to solve this using  MATLAB, as doing it by hand would be rather tedious.
The values of the constants are these:
e0 = 8.854187817*10^(-12);
u0 = 4*pi*10^(-7);
n0 = sqrt(u0/e0);

f = 10^9;
w = 2*pi*f;
d = 0.3;
tg_p = 0.23;

g2 = w*sqrt(u0*e0*9)*sqrt(1-i*tg_p);
g3 = w*sqrt(u0*e0);

n1 = n0;
n2 = w*u0/g2;
n3 = n0;
Eo = 1;

When I solve the linear system with this script
syms Eor Eo2t Eo2r Eot

eq1 = Eo+Eor == Eo2t + Eo2r;
eq2 = Eo-Eor == (n1/n2)*(Eo2t-Eo2r);
eq3 = Eo2t*exp(-i*g2*d)+Eo2r*exp(i*g2*d) == Eot*exp(-i*g3*d);
eq4 = Eo2t*exp(-i*g2*d)-Eo2r*exp(i*g2*d) == (n2/n3)*Eot*exp(-i*g3*d);

[SEor, SEo2t, SEo2r, SEot] = solve([eq1,eq2,eq3,eq4] , [Eor, Eo2t, Eo2r, Eot]);
S = [SEor; SEo2t; SEo2r; SEot];

p_tot = double(SEor/Eo)
t_1 = double(SEo2t/Eo)
p_1 = double(SEo2r/Eo)
t_tot = double(SEot/Eo)

I get a completely different result from the one I get if I solve the system as Ax=b and then perform the MATLAB operation A\b:
A = [1  -1  -1  0;
     1  n1/n2 -n1/n2 0;
     0 exp(-j*g2*d) exp(j*g2*d) -exp(-j*g3*d);
     0 exp(-j*g2*d) -exp(j*g2*d) -exp(-j*g3*d)*(n3/n2)];

b = [-1;1;0;0];

S = A\b;

p_tot = S(1)/Eo
t_1 = S(2)/Eo
p_1 = S(3)/Eo
t_tot = S(4)/Eo

So the thing is that I'm getting two different results for the same problem using two different methods (which should be equivalent). 
The results I'm getting are these:
With the Ax = b method:
p_tot =

  -0.5109 + 0.0436i

t_1 =

   0.4924 + 0.0427i

p_1 =

  -0.0032 + 0.0009i

t_tot =
   0.0284 + 0.0011i

Directly solving the system:
p_tot =

  -0.5011 + 0.0406i

t_1 =

   0.4956 + 0.0415i

p_1 =

   0.0033 - 0.0009i

t_tot =

   0.0866 - 0.0066i

What am I doing wrong and which one is the actual solution?

A:

The problem is that in your A matrix, the value in the 4th row, 4th column doesn't reflect the system of equations you presented in your question.
Instead of (n3/n2) it should be (n2/n3).

