2

I'm trying to substitute some dependent variables into equations inside of a matrix, however $Replace[]$ and and $/.$ don't seem to work.

The equation in question is just a vector matrix of differential equations, which I eventually intend to solve.

 NTISE = 
   {
    {((-(Ωc2^2 - I*γ*Ωo1))*a[t] + Ωd2^2*b[t] +        2*I*Ωo1*Derivative[1][a][t])/Ωo1},
    {(Ωd2^2*a[t] + (Ωc2^2 + I*γ*Ωo1)*b[t] +           2*I*Ωo1*Derivative[1][b][t])/Ωo1},
    {((-Ωc2^2 + 2*Ωe^2 + I*γ*Ωo2)*c[t] + Ωd2^2*d[t] + 2*I*Ωo2*Derivative[1][c][t])/Ωo2},
    {(Ωd2^2*c[t] + (Ωc2^2 + 2*Ωe^2 + I*γ*Ωo2)*d[t] +  2*I*Ωo2*Derivative[1][d][t])/Ωo2}
   }

And the expressions I would like to substitute in are

ΔΩ1 = Ωc2^2/Ωo1
ΔΩ2 = Ωc2^2/Ωo2
ωd1 = Ωd2^2/Ωo1
ωd2 = Ωd2^2/Ωo2

These expressions should simplify the DEs above in order to get equations that can then be solved, however, I tried using

NTISE /.
 {  Ωc2^2/Ωo1 ->  ΔΩ1,
    Ωc2^2/Ωo2 ->  ΔΩ2,
    Ωd2^2/Ωo1 ->  ωd1,
    Ωd2^2/Ωo2 ->  ωd2}

To no avail, and furthermore attempted

Replace[NTISE,
  {  Ωc2^2/Ωo1 ->  ΔΩ1,
     Ωc2^2/Ωo2 ->  ΔΩ2,
     Ωd2^2/Ωo1 ->  ωd1,
     Ωd2^2/Ωo2 ->  ωd2}, Infinity]

And got the same equations out.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Brandon
  • 105
  • 8
  • You can kind of trick it by slightly rewriting the replacement expression and using it as a rule NTISE /. {\[CapitalOmega]c2^2 -> \[CapitalDelta]\[CapitalOmega]1, \ \[CapitalOmega]c2^2 -> \ \[CapitalDelta]\[CapitalOmega]2*\[CapitalOmega]o2, \ \[CapitalOmega]d2^2 -> \[Omega]d1*\[CapitalOmega]o1, \ \[CapitalOmega]d2^2 -> \[Omega]d2*\[CapitalOmega]o2} // Simplify – Jānis Šmits Jul 18 '18 at 19:22
  • Im sorry, I'm not familiar with this method, could you make it clearer for me? – Brandon Jul 18 '18 at 20:08
  • Specifically, I can't figure out the difference between what you wrote and what I tried – Brandon Jul 18 '18 at 20:15
  • I used rules to do the replacement e.g. a*b->c would replace instances of ab in the expression before the ReplaceAll which has a shorthand /.. Then I changed your replacement rules by multiplying both sides by the denominator. Instead of \[CapitalOmega]c2^2/\[CapitalOmega]o1 -> \[CapitalDelta]\ \[CapitalOmega]1 I wrote `[CapitalOmega]c2^2 ->
    [CapitalDelta][CapitalOmega]1
    [CapitalOmega]o1`
    – Jānis Šmits Jul 18 '18 at 20:19
  • So two questions. 1. the replaceall (/.) stays where it is in my expression? And 2. I just multiply by the denom and mathematica replaces the numerator symbol with my symbol*denom and it simplifies out to what I want it to? – Brandon Jul 18 '18 at 20:22
  • If NTISE is what you want to use your replacement on then NTISE/.{Your rules}//Simplify. The Simplify function should take care of ridding you of the denominator. – Jānis Šmits Jul 18 '18 at 20:26
  • I've tried this by doing NTISE /. { ([CapitalOmega]c2^2) ->
    [CapitalDelta][CapitalOmega]1[CapitalOmega]o1 , ([CapitalOmega]c2^2) -> [CapitalDelta][CapitalOmega]2
    [CapitalOmega]o2 , ([CapitalOmega]d2^2) -> [Omega]d1[CapitalOmega]o1, ([CapitalOmega]d2^2) -> [Omega]d2[CapitalOmega]o2} and it still doesn't give the right answer
    – Brandon Jul 18 '18 at 20:26
  • I am unsure what the right answer is, but it replaces all instances where \[CapitalOmega]c2^2 and other squared omegas occur and make the first two expressions somewhat simpler. – Jānis Šmits Jul 18 '18 at 20:31
  • Hmmm, perhaps we're using different mathematica editions - 11.2 here. By the right answer I meant one where the variables are substituted into the equations – Brandon Jul 18 '18 at 20:40
  • Possible duplicate of https://mathematica.stackexchange.com/q/3822/121 ? – Mr.Wizard Jul 18 '18 at 23:24

1 Answers1

2

By expanding NTISE the denominators are distributed among individual terms, so that ReplaceAll rules match the denominators once per rule.

Simplify[Expand[NTISE] /.
 {  Ωc2^2/Ωo1 -> ΔΩ1,
    Ωc2^2/Ωo2 -> ΔΩ2,
    Ωd2^2/Ωo1 -> ωd1,
    Ωd2^2/Ωo2 -> ωd2}]

returns:

{
   {I (γ + I ΔΩ1) a[t] + ωd1 b[t] + 2 I a'[t]},
   {ωd1 a[t] + (I γ + ΔΩ1) b[t] + 2 I b'[t]},
   {(I γ - ΔΩ2 + (2 Ωe^2)/Ωo2) c[t] + ωd2 d[t] + 2 I c'[t]},
   {ωd2 c[t] + (I γ + ΔΩ2 + (2 Ωe^2)/Ωo2) d[t] + 2 I d'[t]}
}

For example, looking at the first term of NTISE,

$$ \frac{-\left(\text{$\Omega $c2}^2 + i \gamma \text{$\Omega $o1}\right)a[t] + \text{$\Omega $d2}^2 b[t]+2 i \text{$\Omega $o1} a'[t]}{\text{$\Omega $o1}} $$

expanding the expression gives:

$$ i \gamma a[t]-\frac{\text{$\Omega $c2}^2 a[t]}{\text{$\Omega $o1}}+\frac{\text{$\Omega $d2}^2 b[t]}{\text{$\Omega $o1}} + 2 i a'[t] $$

which allows ReplaceAll to match the rules Ωc2^2/Ωo1 -> ΔΩ1 and Ωd2^2/Ωo1 -> ωd1.

creidhne
  • 5,055
  • 4
  • 20
  • 28