Re: Using FindRoot with an equation that includes Maximize
- To: mathgroup at smc.vnet.net
- Subject: [mg63792] Re: Using FindRoot with an equation that includes Maximize
- From: "Charles Ashley" <cka2 at adelphia.net>
- Date: Sat, 14 Jan 2006 02:32:59 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
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 == Part[Maximize[{w1a[M1, m2], 0 <= M1 <= 50}, M1],1], w2p == Part[Maximize[{w2a[M2, m1], 0 <= M2 <= 50}, 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-->4.5,m2-->4.5), I need Maximize (in equation 1) to take the value of m2-->4.5, determine that given this value of m2, the maximum value of the function w1a occurs when M1-->12 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-->4, m2-->4} but FindRoot can'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 <= M1 <= 10}, M1],1], 3*m1 + m2 == Part[Maximize[{2*m1*M2 - M2^2, 1 <= M2 <= 10}, M2],1]}, {{m1, 4}, {m2, 4}}] I get three error messages. The first two say that the objective functions in Maximize contain non-constant expressions of m2 and m1, respectively. The third error message basically says FindRoot:: function value is not a list of numbers. 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 a numeric values for the rhs. I've confirmed that the Part[Maximize.]] 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..etc.]] but nothing seems to work. I would really appreciate your insights on this. 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, Charles Ashley cka2 at adelphia.net