2
$\begingroup$

Broadly, I am looking for a solution numerically using FindRoot, but the output seems to be be quite sensitive to the initial guesses for one variable in particular, so I am running the function over multiple starting values. I then want to weed out the solutions that have certain elements (e.g., x1, x2, but not not x3) that are below zero. Finally, of those solutions that are left, I'd like to choose the solution which maximizes the value of another function.

My code flows like this: f[kguess_] := FindRoot[{ 9 eqns}, {{x1,xint},{x2,x2int}, etc}, MaxIterations ->100000, PrecisionGoal->\[Infinity]];
sol = f[#]&/@{0,1,10,100,1000,10000};
ham /. sol (*this is the function I would want the highest value of, once the solutions that have certain negative values have been removed*)

Initially, I was thinking to grab indexes for the solutions that match my non-negativity conditions and then to run those through the 'ham' function, but it looked like Select (which seemed to be the only list element finding function that allows a test) doesn't give the position. Any suggestions for other Mathematica tools to try would be much appreciated!

$\endgroup$
  • $\begingroup$ Greetings! Make the most of Mma.SE and take the tour now. Help us to help you, write an excellent question. Edit if improvable, show due diligence, give brief context, include minimal working examples of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans May 18 '17 at 15:44
  • $\begingroup$ this might be helpful for the first part of the job (finding all the roots). $\endgroup$ – yohbs May 18 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.