Re: Using FindRoot with an equation that includes Maximize
- To: mathgroup at smc.vnet.net
- Subject: [mg63778] Re: Using FindRoot with an equation that includes Maximize
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Sat, 14 Jan 2006 02:32:21 -0500 (EST)
- References: <dq7uo4$40d$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, can you be so kind to explain what in > FindRoot[{m1+3*m2==Part[Maximize[{2*m2*M1-M1^2,1=C2=A3M1=C2=A310},M1],1],3*m1+m2==Part[Maximize[{2*m1*M2-M2^2,1=C2=A3M2=C2=A310},M2],1]},{{m1,4},{m2,4}}] mean 1=C2=A3M1=C2=A310 is it Equal[] ?? and it is better to write a function myfun[m1_?NumericQ,m2_?NumericQ]:= {m1+3*m2==Part[Maximize[{2*m2*M1-M1^2,1=C2=A3M1=C2=A310},M1],1],3*m1+m2==Part[Maximize[{2*m1*M2-M2^2,1=C2=A3M2=C2=A310},M2],1]} ] that restrict the m1 and m2 variable to numbers. Regards Jens > > Hi Everyone, > > I'm trying to use FindRoot to solve a system of two equations, > where the rhs of each incorporates a Maximize function. Here is the > actual input: > > FindRoot[{w1p=C5=A0Part[Maximize[{w1a[M1,m2],0=C2=A3M1=C2=A350},M1],1],w2p=C5=A0Part[Maximize[{w2a[M2,m1],0=C2=A3M2=C2=A350},M2],1]},{{m1,4.5},{m2,4.5}}] > > The lhs of the first equation (w1p) is an algebraic expression of two > variables (m1,m2), The rhs of the first equation includes a > transcendental function (the function w1a includes several exponential > terms) of two variables (M1,m2), hence the use of FindRoot rather than > Solve. Similarly, the lhs of the second equation (w2p) is an algebraic > expression of two variables (m1,m2) while the rhs includes a > transcendental function of the variables (M2,m1). > > To solve this for (m1,m2) I need FindRoot to feed its potential solution > set into the Maximize functions (m2 into the rhs of the first equation > and m1 into the rhs of the second equation). For example, if FindRoot > were to try the solution set (m1=C3=A04.5,m2=C3=A04.5), I need Maximize > (in equation 1) to take the value of m2=C3=A04.5, determine that given > this value of m2, the maximum value of the function w1a occurs when > M1=C3=A012 and that the maximum value is 220. Part then extracts this > maximum value of 220 and uses it as the value of the rhs. For my > particular problem I've confirmed that there is a unique > solution set, which I found by repeatedly graphing the equations with > greater precision to zero in on the intersection. But I need to be able > to find the solution in a more automated way because this is input to > another set of equations. > > I've also come up with a very simple, purely algebraic example > of the same problem to confirm that it isn't something unique to > my equations (see below). This example generates the same error > messages as my actual problem. A solution set for this is {m1=C3=A04, > m2=C3=A04} but FindRoot doesn't solve it because it > doesn't appear to pass its potential solutions to the Maximize > functions (at least that's my interpretation of the first two > error messages). > > FindRoot[{m1+3*m2==Part[Maximize[{2*m2*M1-M1^2,1=C2=A3M1=C2=A310},M1],1],3*m1+m2==Part[Maximize[{2*m1*M2-M2^2,1=C2=A3M2=C2=A310},M2],1]},{{m1,4},{m2,4}}] > > I think the third error message is the result of the first two. If > FindRoot isn't passing the potential solutions for {m1,m2} to > the Maximize functions then they aren't able to derive maximum > numeric values and Part isn't able to extract these numeric > values. I've confirmed that the Part[Maximize=E2=80=A6]] > section of this produces the output in the correct form if the values of > m1 and m2 are fixed. I've tried defining the rhs as an > expression rather than a function, and also tried defining the entire > rhs as a function[m2_]:= Part[Maximize=E2=80=A6.etc.]], but neither > approach worked. > > I would really appreciate your insights on this, whether correcting my > syntax or suggesting an alternative approach to the problem. > I've invested over three years of effort developing these > equations. I got as far as I could by hand and with Excel, and finally > took the Mathematica plunge about three weeks ago. It's a steep > learning curve but very rewarding. > > Thanks and happy new year to everyone, > > Charles Ashley > > cka2 at adelphia.net >