Re: FindMinimum within a specific interval
- To: mathgroup at smc.vnet.net
- Subject: [mg32651] Re: [mg32600] FindMinimum within a specific interval
- From: Brett Champion <brettc at wolfram.com>
- Date: Fri, 1 Feb 2002 16:10:53 -0500 (EST)
- References: <200201310645.BAA04291@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
At 1:45 AM -0500 1/31/02, Wassim T. Jalbout wrote: >Dear all, > >I have the following 3 simultaneous equations > >eq1 x + y + z - 1=0 >eq2 -65.96x - 55.87y + 132.19z=0 >eq3 174.23x + 148.29y - 380.11z=0 > >and I want to find the triplet (x,y,z) that best satisfies them within the >interval 0>x>1, >0>y>1 and 0>z>1. > >I realize, by using Solve, that the exact solution to simultaneous eqs 1 to >3 above, namely >(x=-3.6,y=4.5,z=0.1), lies outside the [0,1] interval for x and y and is >thus uninteresting to my work. > >So I thought of minimizing the following expression: >eq1^2+eq2^2+eq3^2 >within the interval 0 to 1 for (x,y,z) > >to do so I used FindMinimum as follows: > >FindMinimum [ (x + y + z - 1)^2 + (-65.96x - 55.87y + 132.19z)^2 + > > (174.23x + 148.29y - 380.11z)^2, {x, 0.1}, {y, 0.6}, > > {z,0.3}] > >where I can only specify starting points rather than fixed intervals for x, >y and z.(unfortunately). > >The result I get is: >{1.0107607*^-28, {x->-3.6, y->4.5, z->0.10}} >with x,y,z values still outside the 0,1 interval. > > >How to to find the x,y,z value between 0 and 1 that results in the smallest >value to my second degree expression written above? Is my approach wrong >alltogether? > Here is one way. We'll use the Boole function in Calculus, which returns 1 only when its argument is True, to create a hefty penalty outside the box. In[5]:= <<Calculus` In[6]:= FindMinimum[(x + y + z - 1)^2 + (-65.96x - 55.87y + 132.19z)^2 + (174.23x + 148.29y - 380.11z)^2 + 100*(1-Boole[0<=x<=1]) + 100*(1-Boole[0<=y<=1]) + 100*(1-Boole[0<=z<=1]), {x, .5, .6}, {y, .5, .6}, {z, .5, .6}, MaxIterations->100] -12 Out[6]= {0.894632, {x -> 9.25568 10 , y -> 0.0756025, z -> 0.0297652}} Brett --