MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NSolve problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59298] Re: [mg59283] NSolve problem
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Fri, 5 Aug 2005 01:21:26 -0400 (EDT)
  • References: <200508040608.CAA26496@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The message that you get tells you that the matrix is "badly  
condition", which means that using MachinePrecision reals is  
unreliable and you need to use high precision arithmetic. But, since  
your system is actually overdetermined (you have a spurious  
equation), even if you increase the precision your equations will  
become inconsistent, and you will get an empty set of solutions (but  
no message):



Solve[SetPrecision[{2*x + 3*y == 8 + I*7,
     3*x + y == 4.99999999999999 + 7*I,
     -2*I*x + (1 + 3*I)*y == 3 + 5*I}, 50]]


{}


There are a number of ways to deal with your problem. The most  
obvious one is to just use Solve with exact input and only afterwards  
apply N



N[Solve[{2*x + 3*y == 8 + I*7, 3*x + y == 5 + 7*I,
     -2*I*x + (1 + 3*I)*y == 3 + 5*I}],5]


{{x -> 1.0000 + 2.0000 I, y -> 2.0000 + 1.0000 I}}




Another approach is to simply drop one of the equations:


NSolve[Drop[{2*x + 3*y == 8 + I*7,
     3*x + y == 4.99999999999999 + 7*I,
     -2*I*x + (1 + 3*I)*y == 3 + 5*I}, -1]]


{{x -> 0.9999999999999958 + 2.*I,
    y -> 2.0000000000000027 + 1.*I}}

(Note that I used NSolve this time).


Another possibility, which you could use with a larger number of  
variables and equations is to first find a GroebnerBasis for your  
system and then solve the resulting new system:


NSolve[GroebnerBasis[{2*x + 3*y == 8 + I*7,
       3*x + y == 5 + 7*I, -2*I*x + (1 + 3*I)*y ==
        3 + 5*I} /. Equal -> Subtract, {x, y}] == 0,
   {x, y}]


{{x -> 1. + 2.*I, y -> 2. + 1.*I}}


Also, note that N[Solve[eqns]] and NSolve[eqns] use different  
algorithms and will not always return the same answer.

Also, if you really want 5 digits of precision you have to request it  
as above or as in:



N[Solve[GroebnerBasis[{2*x + 3*y == 8 + I*7,
        3*x + y == 5 + 7*I, -2*I*x + (1 + 3*I)*y ==
         3 + 5*I} /. Equal -> Subtract, {x, y}] == 0,
    {x, y}], 5]


{{y -> 2.0000 + 1.0000 I, x -> 1.0000 + 2.0000 I}}

Andrzej Kozlowski




On 4 Aug 2005, at 08:08, Enrique Zeleny wrote:

>
>
> Hi
> I f I try to solve these equations
>
> Solve[{2 x + 3 y == 8 + I 7,
>     3 x +  y == 5 + 7 I, -2 I x + (1 + 3 I) y == 3 + 5 I}]
>
> the result is
>
> {{x -> 1 + 2*I, y -> 2 + I}}
>
> but if I have
>
> Solve[{2 x + 3 y == 8 + I 7,
>     3 x +  y == 4.99999999999999 + 7 I, -2 I x + (1 + 3 I) y == 3 +  
> 5 I}]
>
> gives
>
> \!\(\*FormBox[
>   RowBox[{\(RowReduce::"luc"\), \(\(:\)\(\ \)\), "\<\"Result for \
> \\!\\(TraditionalForm\\`RowReduce\\) of badly conditioned matrix \
> \\!\\(TraditionalForm\\`\\((\[NoBreak] \\(\[LeftSkeleton] 1 \
> \[RightSkeleton]\\) \[NoBreak])\\)\\) may contain significant  
> numerical \
> errors. \\!\\(\\*ButtonBox[\\\"More\\\",
> ButtonStyle->\\\"RefGuideLinkText\\\
> \", ButtonFrame->None, ButtonData:>\\\"General::luc\\\"]\\)\"\>"}], \
> TraditionalForm]\)
>
>
> {}
>
>
> I need only an aproximate result, say 5 digits of precission, how  
> can I
> override the NSolve behavior?
>
>
> Thanks in advance
>
>


  • References:
  • Prev by Date: Re: pairs and subsets challenge
  • Next by Date: Re: New Style Sheet
  • Previous by thread: Re: NSolve problem
  • Next by thread: Re: NSolve problem