Re: Strange empty set of solutions
- To: mathgroup at smc.vnet.net
- Subject: [mg71843] Re: Strange empty set of solutions
- From: Peter Pein <petsie at dordos.net>
- Date: Fri, 1 Dec 2006 06:21:41 -0500 (EST)
- References: <ekh7pg$sgs$1@smc.vnet.net> <ekjfrf$d7h$1@smc.vnet.net> <ekmdn4$817$1@smc.vnet.net>
José Carlos Santos schrieb: > On 29-11-2006 8:19, Jens-Peer Kuska wrote: > >> and we can't read you mind and the memory of your computer >> so we must imagine a matrix M and write down > > Do you want an example? Here it is: > > M = {{4/5(c - 1), -2/Sqrt[5]s, 2/5(1 - c)}, > {2/5(1 - c), -1 + s/Sqrt[5], 4/5 + c/5}, > {-2s/Sqrt[5], -c, -1 + s/Sqrt[5]}} // N > > with c = Cos[Sqrt[5]] and s = Sin[Sqrt[5]]. > > If I type > > Solve[{M.{x, y, z} == {0, 0, 0}}, {x, y, z}] > > I get > > {{x -> 0. - 0.0438861 z, y -> 0. + 1. z}} > > but if I type > > Solve[{M.{x, y, z} == {0, 0, 0}, x^2 + y^2 + z^2 == 1}, {x, y, z}] > > then I get the empty set. Why is that? > > Best regards, > > Jose Carlos Santos > Hi, you know the exact values of M. Why do you calculate with inexact numbers? in the following examples is M the _exact_ matrix, nM the approximation with MachinePrecision (N[M]) and v is {x,y,z}. I guess, you are interested in approx. solutions: NSolve[{M . v == 0, v . v == 1}, v] {{x -> -0.031017241879657837, y -> 0.7067665564761036, z -> 0.7067665564761036}, {x -> 0.031017241879657837, y -> -0.7067665564761036, z -> -0.7067665564761036}} and this is, what you observed: NSolve[{nM . v == 0, v . v == 1}, v] {} but using Mathematicas special floating point routines, you get NSolve[{N[M, 10] . v == 0, v . v == 1}, v] {{x -> -0.0310172418796578372`5.994695378036643, y -> 0.7067665564761036423`5.9946953780366465, z -> 0.7067665564761036423`6.000786279312727}, {x -> 0.0310172418796578372`5.994695378036643, y -> -0.7067665564761036431`5.9946953780366465, z -> -0.7067665564761036431`6.000786279312727}} the easiest way (with small systems of equations) is: gb = GroebnerBasis[Flatten[{M . v, v . v - 1}], v]; NSolve[gb == 0, v] {{x -> -0.031017241879657837, y -> 0.7067665564761036, z -> 0.7067665564761036}, {x -> 0.031017241879657837, y -> -0.7067665564761036, z -> -0.7067665564761036}} which works with machine-precision numbers too: GroebnerBasis[Flatten[{nM . v, v . v - 1}], v] {-0.4995189653530894 + 1.*z^2, 1.*y - 1.*z, 1.*x + 0.0438861199577807*z} Solve[% == 0, v] {{x -> -0.03101724187965787, y -> 0.7067665564761035, z -> 0.7067665564761035}, {x -> 0.03101724187965787, y -> -0.7067665564761035, z -> -0.7067665564761035}} Peter