FindRoot
- To: mathgroup at smc.vnet.net
- Subject: [mg111096] FindRoot
- From: Themis Matsoukas <tmatsoukas at me.com>
- Date: Tue, 20 Jul 2010 03:43:18 -0400 (EDT)
I have a cubic polynomial in z (ZEQ) that depends on a parameter p. The polynomial has three real roots when p is in the interval (p1, p2). I then define function F[X] to be the ratio of the Max-to-Min (real) roots of ZEQ when p has the value X. Of course, F[X] makes sense only when ZEQ has three real roots, which restricts p to be in the interval p1<p<p2. The problem: while F[X] is evaluated (and plotted) correctly, if I try to solve for, say F[X]=6, I get a wrong answer (the correct answer is X=0.4). I suspect the problem is that Mathematica does not restrict the evaluation of F[X] within the interval (p1,p2). If I don't want to write my own routine for the root, is there a way to restrict FindRoot to work only inside the interval (p1, p2)? ZEQ=-0.049973 p^2+(0.44137p-0.00873 p^2) z-z^2+z^3; {p1,p2}={0.133652,0.690323}; F[X_]:=( z123=Sort[z/.Solve[(ZEQ/.p->X)==0,z]]; z123[[3]]/z123[[2]] ); FindRoot[F[X]-6, {X, 0.40}] F[X/.%]-6 {X->0.586195-5.08604*10^-16 I} -3.40038 TableForm[Table[{X, F[X]-6}, {X, 0.38, 0.42, 0.01}]] 0.38 0.55303 0.39 0.266973 0.40 -0.00436745 0.41 -0.262155 0.42 -0.50744 Thanks Themis