4
$\begingroup$

I am trying to solve a linear system of four equations with Mathematica. My variables are a1,a2, a1prime, a2prime. I use the code shown below:

eq1 = (kx*  i + (0.5*k0*(Xmexx*ky - Xmexy*kx)) + (0.5*
    h1*(Xmmxx*kx + Xmmxy*ky)))*
a1 + ((-i*kx) + (0.5*k0*(Xmexx*ky - Xmexy*kx)) - (0.5*
    h2*(Xmmxx*kx + Xmmxy*ky)))*
a2 + ((ky*h1/k1) + (0.5*i*
    k0*(h1/k1)*(Xmexx*kx + Xmexy*ky)) - (0.5*i*
    k1*(Xmmxx*ky - Xmmxy*kx)))*
a1prime + ((ky*h2/k2) - (0.5*i*
    k0*(h2/k2)*(Xmexx*kx + Xmexy*ky)) - (0.5*i*
    k2*(Xmmxx*ky - Xmmxy*kx)))*
a2prime == (-kx*i) - (0.5 k0*(Xmexx*ky - Xmexy*kx)) + (0.5*
 h1*(Xmmxx*kx - Xmmxy*ky))

eq2 = ((i*ky) + (0.5*k0*(Xmeyx*ky - Xmeyy*kx)) + (0.5*
    h1*(Xmmyx*kx + Xmmyy*ky)))*
a1 + ((-i*ky) + (0.5*k0*(Xmeyx*ky - Xmeyy*kx)) - (0.5*
    h2*(Xmmyx*kx + Xmmxy*ky)))*
a2 + ((-kx*h1/k1) + (0.5*i*
    k0*(h1/k1)*(Xmeyx*kx + Xmeyy*ky)) - (0.5*i*
    k1*(Xmmyx*ky - Xmmyy*kx)))*
a1prime + ((-kx*h2/k2) - (0.5*i*
    k0*(h2/k2)*(Xmeyx*kx + Xmeyy*ky)) - (0.5*i*
    k2*(Xmmyx*ky - Xmmyy*kx)))*
a2prime == ((-ky*i) - (0.5 k0*(Xmeyx*ky - Xmeyy*kx)) + (0.5*
  h1*(Xmmyx*kx - Xmmyy*ky)))

eq3 = ((i*ky) + (0.5*k0*(Xmeyx*ky - Xmeyy*kx)) + (0.5*
    h1*(Xmmyx*kx + Xmmyy*ky)))*
a1 + ((-i*ky*h2/(w*mu0)) - (0.5*w*
    eps0*(Xeexx*ky - Xeexy*kx)) + (0.5*h2*Sqrt[
    eps0/mu0] (Xemxx*kx + Xemxy*ky)))*
a2 + ((kx*k1/(w*mu0)) - (0.5*i*w*
    eps0*(h1/k1) (Xeexx*kx + Xeexy*ky)) + (0.5*i*k1*Sqrt[
    eps0/mu0] (Xemxx*ky - Xemxy*kx)))*
a1prime + ((-kx*k2/(w*mu0)) + (0.5*i*w*
    eps0*(h2/k2) (Xeexx*kx + Xeexy*ky)) + (0.5*i*k2*Sqrt[
    eps0/mu0] (Xemxx*ky - Xemxy*kx)))*
a2prime == ((-i*ky*h1/(w*mu0)) + (0.5*w*
  eps0*(Xeexx*ky - Xeexy*kx)) - (0.5*h1*Sqrt[
  eps0/mu0] (Xemxx*kx + Xemxy*ky)))

eq4 = ((i*kx*h1/(w*mu0)) - (0.5*w*eps0*(Xeeyx*ky - Xeeyy*kx)) - (0.5*
    h1*Sqrt[eps0/mu0] (Xemyx*kx + Xemyy*ky)))*
a1 + ((i*kx*h2/(w*mu0)) - (0.5*w*
    eps0*(Xeeyx*ky - Xeeyy*kx)) + (0.5*h2*Sqrt[
    eps0/mu0] (Xemyx*kx + Xemyy*ky)))*
a2 + ((ky*k1/(w*mu0)) - (0.5*i*w*
    eps0*(h1/k1) (Xeeyx*kx + Xeeyy*ky)) + (0.5*i*k1*Sqrt[
    eps0/mu0] (Xemyx*ky - Xemyy*kx)))*
a1prime + ((-ky*k2/(w*mu0)) + (0.5*i*w*
    eps0*(h2/k2) (Xeeyx*kx + Xeeyy*ky)) + (0.5*i*k2*Sqrt[
    eps0/mu0] (Xemyx*ky - Xemyy*kx)))*
a2prime == ((i*kx*h1/(w*mu0)) + (0.5*w*
  eps0*(Xeeyx*ky - Xeeyy*kx)) - (0.5*h1*Sqrt[
  eps0/mu0] (Xemyx*kx + Xemyy*ky)))

Solve[eq1 && eq2 && eq3 && eq4, {a1, a2, a1prime, 
a2prime}] // simplify;

By this code, I've got extremely complicated results. To simplify the results, i want to apply the substitutions below, but i don't know how to do that. Could anyone help me how to do that?

k = w Sqrt[mu0*eps0]

k1 = k

k2 = k

kt = Sqrt[kx^2 + ky^2]

h1 = Sqrt[k^2 - kt^2]

h2 = Sqrt[k^2 - kt^2]

h1 = k1z
h2 = k1z

k0 = w Sqrt[mu0*eps0]


Xeeyy = Xeexx
Xeexy = 0
Xeeyx = 0

Xemyy = Xemxx
Xemxy = 0
Xemyx = 0

Xmmyy = Xmmxx
Xmmxy = 0
Xmmyx = 0

Xmeyy = Xmexx
Xmexy = 0
Xmeyx = 0

I really appreciate your comments.

$\endgroup$
1
  • 1
    $\begingroup$ Bottom line is, you are inverting a 4x4 matrix and multiplying it by a vector in order to get your variables. Try running matrix = Array[mm, {4, 4}] to create and arbitrary matrix and then run Inverse@matrix and take a look at it. Complicated! Now replace each of mm[ , ] with one of your complicated terms. $\endgroup$
    – MikeY
    Mar 14 '20 at 21:59
6
$\begingroup$

First of all, it's FullSimplify. Now, If you want to substitute a value you need to use ReplaceAll. I have done something similar to what you want: If you need to replace those variables you can make a replacing list as:

    params1 = {k1 -> k, k2 -> k, kt -> Sqrt[kx^2 + ky^2], 
              h1 -> Sqrt[k^2 - kt^2], h2 -> Sqrt[k^2 - kt^2], Xeeyy -> Xeexx, 
              Xeexy -> 0, Xeeyx -> 0, Xemyy -> Xemxx, Xemxy -> 0, Xemyx -> 0, 
              Xmmyy -> Xmmxx, Xmmxy -> 0, Xmmyx -> 0, Xmeyy -> Xmexx, Xmexy -> 0, 
              Xmeyx -> 0};

Also another set,

    params2 = {k -> w Sqrt[mu0*eps0], h1 -> k1z, h2 -> k1z, 
               k0 -> w Sqrt[mu0*eps0]};

Now you can either replace them before solving or after solving:

        eqns = {eq1, eq2, eq3, eq4} /. params1 /. params2;
        Solve[eqns, {a1, a2, a1prime, a2prime}]

or,

        Res = Solve[eq1 && eq2 && eq3 && eq4, {a1, a2, a1prime, a2prime}]/.params1/.params2.

Further simplification might be done by FullSimplify or Reduce. Also, I see you have two different values of h1? while substituting, you need to decide what your output variables should be.

$\endgroup$
3
$\begingroup$

Replace simplify by Simplify.

To begin with, make sure that all coefficients have numerical values before launching Solve so that the solution will also be numerical.

Then try again by clearing some numerical value and you will get symbolic solutions, but do you need that?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.