Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

My problem is :

Q[g_?NumberQ] :=NIntegrate[2*(1-Cos[A[b]])*b,{b,0,10}];

but when i put Solve[g^2-b^2*g^2*y^2-4*y^12+4*y^6==0,y,Reals][[2]])] , in the part of Reals [[2]] , i have to put some code that give to me a minimum positive real value ... so the Reals [[2]] will not give me that i want, i want to change the code for a new one, that gives only ONE root, that is real, minimum and positive ...

share|improve this question

closed as not a real question by belisarius, Ajasja, m_goldberg, Sjoerd C. de Vries, Jens Apr 27 '13 at 3:21

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

for any values of g and b i want to have just one root, that must be real, positive and have the minimum value –  Lucas G Leite F Pollito Apr 26 '13 at 17:35
And ... how do you know that your equation have any real root at all? –  belisarius Apr 26 '13 at 17:41
In the case of everything being real as @belisarius queried, which for order 12 polynomial is unlikely, you could look at Min and Sign. Also Select. An example of a way to find the minimum of only positive values in a list would be Min[Select[{1, 2, 3, -1, -4, 5}, # > 0 &]] –  fizzics Apr 26 '13 at 17:44
@belisarius , if dont have any real root , the output command gives nothing ... but this special problem always have at least 2 real roots , and i want only the positive and minimum ... do you know the syntax to put to get only the value that i want ? –  Lucas G Leite F Pollito Apr 26 '13 at 17:44
@fizzics , how can i put it in my syntax ? after y , i put what ? –  Lucas G Leite F Pollito Apr 26 '13 at 17:48

1 Answer 1

Easiest perhaps is to find them all and cull out the one you want. One way is as below. Since it is even in y I substitute y->Sqrt[y] to cut the degree in half and compensate in the result.

 minroot[g_?NumericQ, b_?NumericQ] := Module[{rts, y},
  rts = y /. Solve[g^2 - b^2*g^2*y - 4 y^6 + 4 y^3 == 0, y];
  rts = Select[rts, 
    With[{nval = N[#, 100]}, Im[nval] == 0 && nval > 0] &];

minroot[5, 22]

(* Out[105]= Sqrt[Root[-25 + 12100 #1 - 4 #1^3 + 4 #1^6 &, 2]] *)


(* Out[106]= 0.0454545454866 *)

--- edit ---

[I also repaired a pair of typos in minroot above.]

To extend for further usage in NIntegrate, one should be sure to have all parameters explicitly in function argument lists, and forced to be numeric.

aA[g_?NumberQ, b_?NumberQ] := 
 Pi - 2*b*g*
    1/Sqrt[g^2 - b^2*g^2*y^2 - 4*y^12 + 4*y^6], {y, 0, 
     minroot[g, b] - 0.00001}]

qQ[g_?NumberQ] := NIntegrate[2*(1 - Cos[aA[g, b]])*b, {b, 0, 10}]



(* Out[183]= 0.935599560073 *)

--- end edit ---

share|improve this answer
my program is ym=y/.Solve[g^2-b^2*g^2*y^2-4y^12+4y^6==0,y ,Reals][[2]]; [Chi]=[Pi]-2*b*g*(NIntegrate[1/Sqrt[g^2-b^2*g^2*y^2-4y^12+4y^6],{y,0,ym-0.0000‌​1}]) 1-Cos[[Chi]] so, ym now must be the minroot and positive real ... how can i change ? –  Lucas G Leite F Pollito Apr 26 '13 at 18:16
(1) When g and m are symboplic, your root is also symbolic. it is not real. (2) This will also be an issue for NIntegrate since it does not handle symbolic parameters. (3) I've no idea why you are extracting the second root. In particular, it need not give the smallest positive root. (4) To answer your question, one change you might consider would be to use the code I posted. –  Daniel Lichtblau Apr 26 '13 at 18:54
Hi Daniel, i edit my question can you help now ? –  Lucas G Leite F Pollito Apr 26 '13 at 19:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.