MathGroup Archive 2011

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

Search the Archive

Re: Picking certain values from an array of solutions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118002] Re: Picking certain values from an array of solutions
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Fri, 8 Apr 2011 04:13:51 -0400 (EDT)

final = {{}, {{F1 -> 0.935295, F2 -> 0.147373}}, {{F1 -> 0.547316,
      F2 -> 0.147209}}, {{F1 -> 0.418004,
      F2 -> 0.14704}}, {{F1 -> 0.353359,
      F2 -> 0.146866}}, {{F1 -> 0.314582, F2 -> 0.146685}}};
cases = Cases[final, x : Rule[_, _] :> x, 3]
First@SortBy[cases, Last]

{F1 -> 0.935295, F2 -> 0.147373, F1 -> 0.547316, F2 -> 0.147209,
  F1 -> 0.418004, F2 -> 0.14704, F1 -> 0.353359, F2 -> 0.146866,
  F1 -> 0.314582, F2 -> 0.146685}

F2 -> 0.146685

or (faster for long lists):

cases[[Ordering[cases[[All, -1]], 1]]]

{F2 -> 0.146685}

Bobby

On Thu, 07 Apr 2011 07:06:40 -0500, Bob Hanlon <hanlonr at cox.net> wrote:

>
> final = {{}, {{F1 -> 0.935295, F2 -> 0.147373}}, {{F1 -> 0.547316,
>      F2 -> 0.147209}}, {{F1 -> 0.418004,
>      F2 -> 0.14704}}, {{F1 -> 0.353359,
>      F2 -> 0.146866}}, {{F1 -> 0.314582, F2 -> 0.146685}}};
>
> Module[{t = Flatten[final]}, Select[t, #[[2]] == Min[t[[All, 2]]] &]]
>
> {F2 -> 0.146685}
>
>
> Bob Hanlon
>
> ---- Anna Kaladze <anna.kaladze at gmail.com> wrote:
>
> =============
> Hi All,
>
> I have solved a system of 2 equations for different values of a specific
> paramater, entering each of those equations, and I get the answer in the
> following form:
>
>
> final =  
> {{},{{F1=AE0.935295,F2=AE0.147373}},{{F1=AE0.547316,F2=AE0.147209}},{{F1=AE
> 0.418004,F2=AE0.14704}},{{F1=AE0.353359,F2=AE0.146866}},{{F1=AE0.314582,F2  
> =AE
> 0.146685}}}
>
> where F1 and F2 are the variables I was solving for.
>
> Now I need to get the minimum value F1/F2 takes in "final". That is, I  
> need
> the lowest number occuring in "final" to be returned and its associated
> variable, be it F1 or F2. Obviously, for the above tuple the answer
> is F2=0.146685, but I do not know what code to use to get the minimum for
> any tuple like that.
>
> Thanks a lot.
>
> Anna.
>
>
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: Coefficents of terms in an expression containing the matching string
  • Next by Date: Re: Coefficents of terms in an expression containing the matching string
  • Previous by thread: Re: Picking certain values from an array of solutions
  • Next by thread: Shadow problem of a variable defined in a function context inside different packages