MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Odd ordering of results?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99564] Re: [mg99527] Odd ordering of results?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 8 May 2009 00:14:41 -0400 (EDT)
  • References: <200905071035.GAA19398@smc.vnet.net>

On 7 May 2009, at 19:35, AES wrote:

> I'm evaluating an optical interferometer problem in which an input  
> wave
> e1 produces internal, reflected and transmitted waves e2 thru e7 that
> are connected by the linear equations
>
>   waveEqns = {e1 == 1, e2 == rho12 e1 + t42 e4, e3 == rho43 e4 + t13  
> e1,
>       e4 == gL e6, e5 == gL e3, e6 == rho56 e5, e7 == t57 e5};
>
> where the rho_nm and t_nm are reflection and transmission coefficients
> and the input wave amplitude is arbitrarily set to e1==1; and then
> solving these using
>
>  waveSolns = Solve[waveEqns, {e2, e3, e4, e5, e6, e7}]
>
> and getting a set of rules en-><stuff> for e2 thru e7 which are  
> ordered
> in the sequence
>
>   Out[] = {{e2  e7  e3  e6  e5  e4 }}
>
> with the "stuff" stripped out for brevity.
>
> What puzzles me -- not a problem, just curious -- is the _order_ in
> which these rules appear.
>
> Even more puzzling:  If I take out the leading "e1==1," statement in
> waveEqns I get the same results, except each "stuff" becomes
> "e1*same_stuff" -- and the set of rules produced by waveSolns is now  
> in
> the different order
>
>   Out[] = {{e2  e7  e3  e4  e5  e6 }}
>
> Odd . . .  (seems like the natural thing would be to order the list on
> the left side of the en-><stuff> terms, getting e2 to e7 in either  
> case)
>

Not really strange. How would you do it by hand? Presumably you would  
use variable elimination and to do that you would have to order them  
in some way, right? And once you ordered them and performed  
eliminations, the solutions would come out in a certain order, right?  
And, then, it would be natural, I think, to return them in the order  
in which they are obtained. If you prefer to get them in the original  
order you can use the option Sort -> False,

Solve[{e1 == 1, e2 == rho12 e1 + t42 e4, e3 == rho43 e4 + t13 e1, e4  
== gL e6,
    e5 == gL e3, e6 == rho56 e5, e7 == t57 e5}, {e1, e2, e3, e4, e5,  
e6, e7},
  Sort -> False]

  but that means that the order of elimination will not be the one  
that Solve would choose itself and the computation might become  
considerably slower (but it might not too). Alternatively, you can  
simply apply Sort to the final answer

Sort /@ Solve[{e1 == 1, e2 == rho12 e1 + t42 e4, e3 == rho43 e4 + t13  
e1,
    e4 == gL e6, e5 == gL e3, e6 == rho56 e5, e7 == t57 e5}, {e1, e2,  
e3, e4,
    e5, e6, e7}]

Andrzej Kozlowski


  • Prev by Date: Re: copy and paste to other programs
  • Next by Date: Re: two graph problems in Adjacency types
  • Previous by thread: Re: Odd ordering of results?
  • Next by thread: Re: Odd ordering of results?