       Re: Re: Solve / NSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg95378] Re: [mg95348] Re: Solve / NSolve
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Sat, 17 Jan 2009 05:27:59 -0500 (EST)
• References: <gkgouo\$3sg\$1@smc.vnet.net> <200901161109.GAA14111@smc.vnet.net>

```Actually, the problem in your original example has virtually nothing
to do with the difference between NSolve and Solve. In fact, NSolve is
not used in your example at all. The reason is that when you call
NSolve with equations involving parameters all it does is to refer
your equations to Solve and then apply N. Just compare:

Solve[{f[1, 2, 1/2, 4/5, t], df[1, 2, 1/2, 4/5, t]}, {x, y}] // N

with

NSolve[{f[1, 2, 1/2, 4/5, t], df[1, 2, 1/2, 4/5, t]}, {x, y}]

where f is the function in your original post. You will see that you
get essentially the same answer arranged in a somewhat different way.
So the difference between your final answers derives from the order in
which N and and Power Expand Simplify are applied. In the first case
you perform algebraic operations first and apply N last, in the second
case you apply N before algebraic operations. The second approach is
definitely not the thing to do, since once you expression is no longer
exact algebraic transformations cannot be performed exactly.

In your second case there are no parameters and Solve and NSolve use
different algorithms. Solve rationalizes the equations and uses exact
GroebnerBasis, NSolve uses numerical Groebner basis. The first
approach is faster in this case but the second approach shoudl be more
reliable in cases involving numerical instability.

Andrzej Kozlowski

On 16 Jan 2009, at 12:09, SigmundV wrote:

> Thanks to Andrzej and Jean-Marc for the discussion on the differences
> between Solve and NSolve. Have any of you tried to run the code i
> provided (including the missing function definition which I provided
> later)? I'm aware that Solve and NSolve do not use the same algorithm
> to solve an equation, but it does not seem "logical" to me that they
> don't give the same solution to the same system of algebraic
> equations. What could be the reason for this? I'm also concerned witht
> he speed. Solve is much faster than NSolve for my problem. How come?
> In addition to the code I provided earlier, I just tried with another
> example of a system of two algebraic equations:
>
> {1.1 x^2 + y^2 == 1.0, x + 1.1 y == 0.0}
> Solve[%, {x, y}] // Timing
> NSolve[%%, {x, y}] // Timing
>
> When evaluating this cell you'll see that Solve is substantially
> faster than NSolve, but they yield the same solution. However, in my
> first example they do not yield the same solution in all cases.
>
> Hopefully some of you can shed some light on all this. It could also
> be me comparing apples and oranges. Let me hear your thoughts on all
> this.
>
> Kind regards,
> Sigmund
>

```

• Prev by Date: Re: Re: Mathematica and Access
• Next by Date: Re: Which editor do you use for math articles
• Previous by thread: Re: Solve / NSolve
• Next by thread: Re: Re: Solve / NSolve