Re: How does Solve works ??
- To: mathgroup at smc.vnet.net
- Subject: [mg80211] Re: How does Solve works ??
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Wed, 15 Aug 2007 04:09:00 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <f9s3j1$abs$1@smc.vnet.net>
Ravinder K Banyal wrote: > Hi, > I am just a beginner in Mathematica. > I have two simple equations as follows: > e1=n^2-k^2; > e2=2 n*k; > If I solve for n and k, I should get > n = (e1 + (e1^2 + e2^2)^1/2)^1/2 * sqrt(1/2) > k = (-e1 + (e1^2 + e2^2)^1/2)^1/2 * sqrt(1/2) > However when I use mathematica (ver 5.1) to solve the above equations I > do not get the intended results. > Solve[e1 -n^2+k^2 = = 0, e2-2n*k = = 0, {n,k}] > None of the four roots generated by mathematica matches with above results. First, we solve the system of two equations in two variables. In[1]:= eqns = {e1 == n^2 - k^2, e2 == 2 n*k}; sols = Solve[eqns, {n, k}] Out[2]= {{n -> (-((e1 Sqrt[-e1 - Sqrt[e1^2 + e2^2]])/Sqrt[2]) + ( Sqrt[e1^2 + e2^2] Sqrt[-e1 - Sqrt[e1^2 + e2^2]])/Sqrt[2])/e2, k -> -(Sqrt[-e1 - Sqrt[e1^2 + e2^2]]/Sqrt[2])}, {n -> ( Sqrt[2] e1 Sqrt[-e1 - Sqrt[e1^2 + e2^2]] - Sqrt[2] Sqrt[e1^2 + e2^2] Sqrt[-e1 - Sqrt[e1^2 + e2^2]])/(2 e2), k -> Sqrt[-e1 - Sqrt[e1^2 + e2^2]]/Sqrt[2]}, {n -> ( e1 Sqrt[-(e1/2) + 1/2 Sqrt[e1^2 + e2^2]] + Sqrt[e1^2 + e2^2] Sqrt[-(e1/2) + 1/2 Sqrt[e1^2 + e2^2]])/e2, k -> Sqrt[-(e1/2) + 1/2 Sqrt[ e1^2 + e2^2]]}, {n -> (-Sqrt[2] e1 Sqrt[-e1 + Sqrt[ e1^2 + e2^2]] - Sqrt[2] Sqrt[e1^2 + e2^2] Sqrt[-e1 + Sqrt[e1^2 + e2^2]])/(2 e2), k -> -Sqrt[-(e1/2) + 1/2 Sqrt[e1^2 + e2^2]]}} We check that the solutions returned by Mathematica are correct. In[3]:= eqns /. sols // Simplify Out[3]= {{True, True}, {True, True}, {True, True}, {True, True}} However, it seems that the solutions obtained by hand (at least as posted in the newsgroup) are incorrect (even after having added some required parentheses and written the square roots in Mathematica syntax). In[4]:= eqns /. {n -> (e1 + (e1^2 + e2^2)^(1/2))^(1/2)*Sqrt[1/2], k -> (-e1 + (e1^2 + e2^2)^(1/2))^(1/2)*Sqrt[1/2]} // Simplify Out[4]= {True, Sqrt[-e1 + Sqrt[e1^2 + e2^2]] Sqrt[e1 + Sqrt[e1^2 + e2^2]] == e2} Note that Mathematica does not necessarily return the set of solutions in the form you would find by hand (the internal algorithms have usually nothing to do with the ones used by human beings). You can check that they are equivalent by using function such as *Simplify*. -- Jean-Marc