MathGroup Archive 2011

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

Search the Archive

Re: Capture values that Min(imize)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117762] Re: Capture values that Min(imize)
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Thu, 31 Mar 2011 03:58:51 -0500 (EST)

Since Sqrt is Listable this can be writen slightly more compactly.

L = 14.95; cList = {2.2, 3.2, 6.9, 7.9};

err[f_, c_] := (f - 1/(2 Pi Sqrt[L c*10^-6]))/f

Table[{f, cList[[Ordering[Abs[err[f, cList]], 1]]]}, {f, 15, 30}] ==
 
 Table[{f, cList[[Ordering[Abs[err[f, #]] & /@ cList, 1]]]}, {f, 
   Range[15, 30]}]

True


Bob Hanlon

---- Heike Gramberg <heike.gramberg at gmail.com> wrote: 

=============
I don't know if this is slicker, but what about

Table[{f, cList[[Ordering[Abs[err[f, #]] & /@ cList, 1]]]}, {f, Range[15, 30]}]

Heike

On 29 Mar 2011, at 12:50, 1.156 wrote:

> Hi, I finally found a way to get a list of c values from cList which
> minimize the err at each freq, f as below:
>
> L=14.95;cList={2.2, 3.2, 6.9, 7.9};
>
> err[f_,c_]:=(f-1/(2Pi Sqrt[L c*10^-6]))/f
>
> Table[{f,Select[cList,(Abs[err[f,#]]==Min[Abs[err[f,#]]&/@cList])&]},{f,15,30}]
>
> This works but looks horrible. Surely there's a slicker way to Minimize
> on a list and retain the value that achieved the minimum. I did try to
> stuff Reap/Sow in various places but everything I did threw error
> messages. Thanks for any pointers, Rob
>



  • Prev by Date: Re: Series holding the final sum
  • Next by Date: Re: Sum of powers of multiplied terms
  • Previous by thread: Re: Capture values that Min(imize)
  • Next by thread: About C[i]