Can you say at the beginning of a script in Mathematica that you want all the quantities to be positive (and real)? So that in all calculations, only the real values of these quantities will be considered (by calculations and by plotting) I want to do this because I want to optimize a free energy by finding the best length quantities. But then I will find answers with negative or imaginary length quantities.Also when I make a 3Dplot of the free energy as a function of two of these quantities, Mathematica plot the imaginary values.
Update:
An example is:
R1 is defined as followed:
R1[a_,l_] =
1/3 (-((l π OppC[α]^2)/VolS[α]) + (2^(1/3) l^2 π^2 OppC[α]^4)/(VolS[α] (-2 l^3 π^3 OppC[α]^6 +
27 v VolS[α]^2 + 3 Sqrt[3]Sqrt[-4 l^3 π^3 v OppC[α]^6 VolS[α]^2 +
27 v^2 VolS[α]^4])^(1/3)) + 1/(2^(1/3)VolS[α]) (-2 l^3 π^3 OppC[α]^6 +
27 v VolS[α]^2 + 3 Sqrt[3]Sqrt[-4 l^3 π^3 v OppC[α]^6 VolS[α]^2 + 27 v^2 VolS[α]^4])^(1/3));
Then I want to Plot R1:
Plot3D[R1[α, l], {α, 0, 0.5*π}, {l, 0, 10}].
But by plotting, also imaginary values of R1 are plotted. What do I have to do that Mathematica does not plot these values?
Assuming[]? – J. M.'s missing motivation May 22 '13 at 14:51Assumingdoes, but I may be mistaken. – Mr.Wizard May 22 '13 at 15:04$Assumptionsmay be better. – Sjoerd C. de Vries May 22 '13 at 15:35RealOnly.m, you'll see the message: "The RealOnly package is obsolete. Use instead functionality provided by Reduce[equations, variables, Reals] and by Assuming, Refine, and similar functions." – murray May 22 '13 at 22:00CubeRootshould be used instead of#^(1/3)&so to speak. – Jacob Akkerboom Jan 19 '14 at 23:51