Wikipedia:Reference desk/Archives/Mathematics/2007 March 12
From Wikipedia, the free encyclopedia
Mathematics desk | ||
---|---|---|
< March 11 | << Feb | March | Apr >> | March 13 > |
Welcome to the Wikipedia Mathematics Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
Contents |
[edit] March 12
[edit] mathematica
In[13]:= Simplify[x^2==9,x>0]
Out[13]= x^2 == 9
In mathematica 5.2 , why does mathematica not output the answer " x == 3 "
211.28.238.164 05:01, 12 March 2007 (UTC)
- You misstate the request. What you want is
- Reduce[x^2 == 9 && x > 0]
- This does produce
- x == 3
- as you wish. --KSmrqT 05:36, 12 March 2007 (UTC)
-
- As to why, this is because Simplify simplifies sets of equations, not inequations. Reduce simplifies sets of inequations and equations.
-
-
- That's not really . Simplify works with inequalities just fine (try Simplify[2x>2]) but only uses a very limited set of tools. Also, it doesn't actually simplify a set of equations - it simplifies a single expression (which could be an equation) under a set of assumptions. FullSimplify is slower but gives better results - for example, FullSimplify[x^2==9, x>0] works. -- Meni Rosenfeld (talk) 20:02, 12 March 2007 (UTC)
-
-
-
-
- Mathematica is a large complicated beast, with many ways to approach the same problem. Simplification is known to be a tough problem for several reasons. One is that we have no universal definition of "simpler"; another is computational complexity. Both Simplify and FullSimplify use sets of heuristics — guesses at potentially helpful transformations — hoping to get somewhere. By contrast, Reduce uses the idea of cylindrical algebraic decomposition, which can be horrendously slow but effectively thorough. For example,
- Reduce[x^2 == 9]
- produces
- x == -3 || x == 3
- which not even FullSimplify will do. Another tool is Solve, and indeed
- Solve[x^2 == 9]
- produces
- {{x -> -3}, {x -> 3}}
- much like Reduce; however, we have no way to insist on the positive solution. Can we conclude that Reduce is the best tool? No; for consider that
- Reduce[z == Cos[x]^2 + Sin[x]^2]
- does nothing, producing
- z == Cos[x]^2 + Sin[x]^2
- in contrast to
- Simplify[z == Cos[x]^2 + Sin[x]^2]
- which produces
- z == 1
- as we would hope. Also, we may sometimes settle for FindInstance. Note: Obviously we are exploring trivial examples, as practice for the real challenges. --KSmrqT 23:40, 12 March 2007 (UTC)
- Is there a way to say
- Solve[x^2 == 9] // SelectPositive
- produces
- {{x -> 3}}
- 202.168.50.40 01:36, 13 March 2007 (UTC)
- Is there a way to say
- Mathematica is a large complicated beast, with many ways to approach the same problem. Simplification is known to be a tough problem for several reasons. One is that we have no universal definition of "simpler"; another is computational complexity. Both Simplify and FullSimplify use sets of heuristics — guesses at potentially helpful transformations — hoping to get somewhere. By contrast, Reduce uses the idea of cylindrical algebraic decomposition, which can be horrendously slow but effectively thorough. For example,
-
-
-
-
-
-
-
- Use Select with a suitable anonymous function, then apply it to the solution list. —The preceding unsigned comment was added by 129.78.64.102 (talk) 02:39, 13 March 2007 (UTC).
-
-
-
-
- Create a function called SelectPositive and then use it to filter the result of Solve
- In[1]:= SelectPositive[soln_]:= Select[ soln, Part[FullForm[#], 1, 1, 2] ≥ 0 & ]
- In[2]:= Solve[x^2 == 9, x] // SelectPositive
- Out[2]:= {{x->3}}
- 211.28.123.23 06:19, 13 March 2007 (UTC)
- This one is slightly better because it can handle complex numbers
- In[3]:= SelectPositive2[soln_] := Select[ soln, Function[X, Module[{val}, val = Part[FullForm[X], 1, 1, 2]; Abs[val] == val ]]]
- In[4]:= Solve[x^2 == 16, x] // SelectPositive2
- Out[4]:= {{x->4}}
- 211.28.123.23 07:25, 13 March 2007 (UTC)
-
-
- You can't consistently assign an ordering to the complexes.
- You dont need to assign an ordering, merely get a True / False response
- In[1]:= Abs[ 3+4I ] == ( 3+4I ) (* Abs[ 3 + 4i ] == 3 + 4i *)
- Out[1]= False
- In[2]:= Abs[-5] == -5
- Out[2]= False
- In[3]:= Abs[3] == 3
- Out[3]= True
- In[4]:= Abs[0] == 0
- Out[4]= True
- Call me old-fashioned, but I'm uncomfortable with zero being considered positive. Now might be the time to break out Element[x,Reals]. Also, this Select approach may force us to work finding many roots that we then discard; for some problems, not such a good idea. --KSmrqT 23:38, 13 March 2007 (UTC)
- If you prefer you can always change it to
- Abs[val] == val && Abs[val] > 0
- and filter out zero as well.
- 211.28.123.23 00:15, 14 March 2007 (UTC)
- You can't consistently assign an ordering to the complexes.
-
-
-
-
- Still, you need to have defined some sense of how a complex number is "positive" or not, and there are a few ways of doing this.
-
-