Re: eliminate all the occurrences of "theta ->" and "lambda ->"

• To: mathgroup at smc.vnet.net
• Subject: [mg85596] Re: eliminate all the occurrences of "theta ->" and "lambda ->"
• From: Raj <rajanikanth at gmail.com>
• Date: Thu, 14 Feb 2008 06:28:48 -0500 (EST)
• References: <fp0m2u\$5v7\$1@smc.vnet.net>

On Feb 13, 11:11 pm, "Richard Hofler" <rhof... at bus.ucf.edu> wrote:
> Hello All,
>
> I'm relatively new to Mathematica. Here's my problem.
>
> I have this list that I generated from FindMaximum:
>
> results = {{-5933.0186,{q*4.5785,l*1.0231}},
>    {-5960.3876,{q*5.0002,l*1.0085}},
>    {-5929.7166,{q*3.9758,l*1.0951}},
> {-5929.4666,{q*3.9308,l*1.3277}},
> {-5933.7226,{q*4.7088,l*1.1294}},
> {-5928.0464,{q*3.6767,l*1.1019}}};
>
> How do I eliminate all the occurrences of "q*" and "l*"
> to transform it into this list?
>
> {{4.5785,1.0231},{5.0002,1.0085},{3.9758,1.0951},
> {3.9308,1.3277},{4.7088,1.1294},{3.6767,1.1019}}
>
> BTW, I can evaluate this function
>
> Take[Partition[Flatten[results],3],All,2;;3]
>
> to get to this point:
>
> {{q*4.5785,l*1.0231},{q*5.0002,l*1.0085},{q*3.9758,l*1.0951},{q*3.9308,l
> *1.3277},{q*4.7088,l*1.1294},{q*3.6767,l*1.1019}}
>
> \$Version
> 6.0 for Microsoft Windows (32-bit) (June 19, 2007)
>
> Thanks very much for any help that you may offer.
> Richard
>
> Richard Hofler
> Professor
> Department of Economics
> P.O. Box 161400
> University of Central Florida
> Orlando, FL 32816-1400
> 407-823-2606

Hope this helps:

In[1]:= results = {{-5933.0186,{q*4.5785,l*1.0231}},
{-5960.3876,{q*5.0002,l*1.0085}},
{-5929.7166,{q*3.9758,l*1.0951}},
{-5929.4666,{q*3.9308,l*1.3277}},
{-5933.7226,{q*4.7088,l*1.1294}},
{-5928.0464,
{q*3.6767,l*1.1019}}};

In[2]:= results

Out[2]= {{-5933.02, {4.5785 q, 1.0231 l}}, {-5960.39, {5.0002 q,
1.0085 l}},

>    {-5929.72, {3.9758 q, 1.0951 l}}, {-5929.47, {3.9308 q, 1.3277 l}},

>    {-5933.72, {4.7088 q, 1.1294 l}}, {-5928.05, {3.6767 q, 1.1019 l}}}

In[3]:= Rest/@results

Out[3]= {{{4.5785 q, 1.0231 l}}, {{5.0002 q, 1.0085 l}},

>    {{3.9758 q, 1.0951 l}}, {{3.9308 q, 1.3277 l}}, {{4.7088 q, 1.1294 l}},

>    {{3.6767 q, 1.1019 l}}}

In[4]:= Out[3]/.{q->1,l->1}

Out[4]= {{{4.5785, 1.0231}}, {{5.0002, 1.0085}}, {{3.9758, 1.0951}},

>    {{3.9308, 1.3277}}, {{4.7088, 1.1294}}, {{3.6767, 1.1019}}}

In[5]:= ?Flatten
Flatten[list] flattens out nested lists. Flatten[list, n]

flattens to level n. Flatten[list, n, h]

. Flatten[list, {{s  , s  , ...}, {s  , s  , ...}, ...}]
11   12          21   22
flattens list by combining all levels s
ij
to make each level i in the result.

In[6]:= Flatten[Out[4],2]

Out[6]= {4.5785, 1.0231, 5.0002, 1.0085, 3.9758, 1.0951, 3.9308,
1.3277,

>    4.7088, 1.1294, 3.6767, 1.1019}

In[7]:= Flatten[Out[4],3]

Out[7]= {4.5785, 1.0231, 5.0002, 1.0085, 3.9758, 1.0951, 3.9308,
1.3277,

>    4.7088, 1.1294, 3.6767, 1.1019}

In[8]:= Flatten[Out[4],1]

Out[8]= {{4.5785, 1.0231}, {5.0002, 1.0085}, {3.9758, 1.0951},

>    {3.9308, 1.3277}, {4.7088, 1.1294}, {3.6767, 1.1019}}

Cheers,

Raj

• Prev by Date: Re: Automatic Differentiation in Mathematica
• Next by Date: Equation reference
• Previous by thread: Re: eliminate all the occurrences of "theta ->" and "lambda ->"
• Next by thread: Re: eliminate all the occurrences of "theta ->" and "lambda ->"