Re: How to get the output of Minimize function in x = a format

• To: mathgroup at smc.vnet.net
• Subject: [mg68534] Re: How to get the output of Minimize function in x = a format
• Date: Wed, 9 Aug 2006 04:18:56 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```On 8/8/06 at 6:28 AM, erkuts at gmail.com (erkutsonmez) wrote:

>Say that,I have the following minimization problem

>Minimize[x^2 - 3x + 6, x]

>which gives me the x value that minimizes the expression in the
>format of

>{x -> 3\2}.

This can be done as follows:

In[7]:=
x=(x/.Last@Minimize[x^2-3x,x]);
x

Out[8]=
3/2

But it is worth noting there are advantages to keeping the solution in the form returned by Minimize.

Once x is assigned a value, any future expression with x in it will have x evaluated to that value. If you were to do another minimization problem following this assignment, it would not work unless you either cleared the value of x or used the Minimize function inside a Block, i.e.,

In[9]:=
Minimize[2 x^2+3,x]

returns an error message and

Out[9]=
Minimize[15/2, 3/2]

And when the solution is in the form {x->3/2}, any expression with x can be evaluated with x=3/2 by simply using ReplaceAll (/.) I.e.

In[10]:=
Clear[x];
sol=Last@Minimize[x^2-3 x,x];
2 x^2+3/.sol

Out[12]=
15/2

In[13]:=
1/x/.sol

Out[13]=
2/3
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: Multiplying Elements of arrays: Inner product
• Next by Date: Re: MemberQ
• Previous by thread: Re: How to get the output of Minimize function in x = a format
• Next by thread: OT arbitrary dimension array for math