RE: Real valued parameters/variables
- To: mathgroup at smc.vnet.net
- Subject: [mg34104] RE: [mg34082] Real valued parameters/variables
- From: "Florian Jaccard" <jaccardf at eicn.ch>
- Date: Sat, 4 May 2002 04:28:22 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
One way is to load the package Miscellaneous`RealOnly` If you load it, you can for example plot y = x^(1/3) even for x<0, wich would not be as comfortable elsewere. If you solve an equation, the complex solutions are encountered. For example : In[2]:= <<Miscellaneous`RealOnly` In[3]:= Solve[x^3==-1,x] >From In[3]:= Nonreal::warning: Nonreal number encountered. Out[3]= {{x -> -1},{x -> Nonreal},{x -> Nonreal}} The problem is that it is not very practical if complex and real variables have to live in the same notebook. Some weeks ago, somebody presented the swichable realonly package : http://www.mathsource.com/Content/Enhancements/MathFunctions/0211-396 It can help avoid the problem related. If you prefere not to load the package but want to delete the complex solutions from a list of solutions, you can use for example a fonction like the following: In[1]:= realSolutions[règles_]:=DeleteCases[x/.règles,a_/;Im[a]!= 0] In[2]:= realSolutions[Solve[x^3==-1,x]] Out[2]= {-1} To tell Mathematica that something is real, you can proceed like this : If a parameter, lets say a, has to be real positive, you can use : Simplify[... , a>0] For example : In[6]:= Simplify[Integrate[Sqrt[(a^2 - x^2)],{x,-a,a}],a > 0] Out[6]= a^2*Pi/2 Or, if a has to be real : In[9]:= Simplify[Integrate[1/(x^a),{x,1,Infinity}],Element[a,Reals]] My response is not complete, but I hope it can already help a bit... Meilleures salutations Florian Jaccard EICN-HES e-mail : jaccardf at eicn.ch -----Message d'origine----- De : Jack [mailto:sosolala at hotmail.com] Envoyé : jeu., 2. mai 2002 08:49 À : mathgroup at smc.vnet.net Objet : [mg34082] Real valued parameters/variables Hello I would like to know if there is a possibility to tell Mathematica, that I am only interested in real valued solutions, respectively that some parameters and variables can only real valued. It would be comfortable if one could give this information at the beginning of a Mathematica notebook and at each command. Thanks for your help Jack