Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: minmum of a function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg75126] Re: minmum of a function
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 18 Apr 2007 04:57:15 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <f014ar$8qr$1@smc.vnet.net>

skruege at gwdg.de wrote:
> Thank you for your help concerning the minimum of a function.
> 
> I have another little problem, I cannot solve:
> 
> At one point in my simulation I put
> 
> t1 := Table[amp[a], {a, 0.1, 0.3, 0.1}]
> Evaluate[t1]
> 
> and I get out
> 
> {{0.270697, {0.909768 (p -> -0.15708)}}[0.1], {0.270697, {0.837837 (p ->
> -0.314159)}}[0.2], {0.653976, {0.782008 (p -> -0.471239)}}[0.3]}
> 
> Now, for t1[[1,1]]
> 
> I get out
> 
> [0,1]
> 
> and not 0.270697 as I hoped.
> 
> Apparently {0.270697, {0.909768 (p -> -0.15708)}} is not an element of the
> list.
> 
> Ist it possible to read out the first numbers of the different {}-brackets
> (0.270697, 0.270697 and 0.653976) anyway?
> 
> Sven Krueger

Hi Sven,

(Head /@ t1)[[All,1]]

will do it.

Now the question is: Are you sure that the format of the list t1 is 
really the one you want? As defined (or returned by amp[a]), t1 is a 
list of expressions with _head_ of the form {aNumber, {anotherNumber * 
aRule}}. Therefore, the elements that Part sees by default are 0.1, 0.2, 
etc.

In[1]:=
t1 = {{0.270697, {0.909768*(p -> -0.15708)}}[0.1],
     {0.270697, {0.837837*(p -> -0.314159)}}[0.2],
     {0.653976, {0.782008*(p -> -0.471239)}}[0.3]};

In[2]:=
t1[[1]]

Out[2]=
{0.270697, {0.909768*(p -> -0.15708)}}[0.1]

In[3]:=
Head[t1[[1]]]

Out[3]=
{0.270697, {0.909768*(p -> -0.15708)}}

In[4]:=
Head[t1[[1]]][[1]]

Out[4]=
0.270697

In[5]:=
(Head /@ t1)[[All,1]]

Out[5]=
{0.270697, 0.270697, 0.653976}

You may prefer to check your function amp[] and fix it so it will return 
its results as a list of values.

Regards,
Jean-Marc


  • Prev by Date: Re: neat way to program minimum of sum
  • Next by Date: Re: ImplicitPlot errors
  • Previous by thread: minmum of a function
  • Next by thread: Re: Re: minmum of a function