Re: Wrong Answer
- To: mathgroup at smc.vnet.net
- Subject: [mg130644] Re: Wrong Answer
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Sun, 28 Apr 2013 01:01:40 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <20130427030938.151746A1A@smc.vnet.net>
$Version "9.0 for Mac OS X x86 (64-bit) (January 24, 2013)" p = (px + t vx)^4 + (py + t vy)^4 == 1; r = {px -> 0.5, py -> 0.5, vx -> 0.5, vy -> 0.5} // Rationalize; sol1 = NSolve[p /. r, t] {{t -> -2.68179}, {t -> -1. - 1.68179 I}, {t -> -1. + 1.68179 I}, {t -> 0.681793}} Solve works if you use the replacement rules prior to solving sol2 = Solve[p /. r, t] {{t -> -1 - 2^(3/4)}, {t -> -1 - I*2^(3/4)}, {t -> -1 + I*2^(3/4)}, {t -> -1 + 2^(3/4)}} These are the exact values of the approximate results sol1[[All, 1, -1]] == sol2[[All, 1, -1]] True Solve does appear to have a problem if you substitute equal real values into the general solution sol3 = Solve[p, t] /. {px -> a, py -> a, vx -> a, vy -> a} // Simplify[#, Element[a, Reals]] & {{t -> -1}, {t -> -1}, {t -> -1}, {t -> -1}} p /. r /. sol3 {False, False, False, False} However, for unequal values r = {px -> RandomReal[{0, 1}, WorkingPrecision -> 25], py -> RandomReal[{0, 1}, WorkingPrecision -> 25], vx -> RandomReal[{0, 1}, WorkingPrecision -> 25], vy -> RandomReal[{0, 1}, WorkingPrecision -> 25]}; sol4 = NSolve[p /. r, t]; p /. r /. sol4 {True, True, True, True} sol5 = Solve[p /. r, t]; p /. r /. sol5 {True, True, True, True} sol6 = Solve[p, t] /. r // Sort; p /. r /. sol6 {True, True, True, True} sol4[[All, 1, -1]] == sol5[[All, 1, -1]] == sol6[[All, 1, -1]] True Bob Hanlon On Fri, Apr 26, 2013 at 11:09 PM, christopher arthur < chris.arthur1 at gmail.com> wrote: > Hello, > > I've discovered that Solve[] gives me the wrong answer for some > polynomial equations. For example, consider the following equation, > which should have exactly one positive, real answer for t. > > p:=(px + t vx)^4 + (py + t vy)^4==1 > r:={px->0.5,py->0.5,vx->0.5,vy->0.5} > NSolve[p/.r,t] > > NSolve gives the right answers if I substitute for px,py,vx and vy > before solving. On the other hand, if I use Solve[] this way: > > Solve[p,t]/.r > > I get a different answer, and it's not correct. > Does Solve[] just malfunction with quartic polynomials or is there > something else happening? > > Chris > > mathematica 5.2 > > Solve[p] > >
- References:
- Wrong Answer
- From: christopher arthur <chris.arthur1@gmail.com>
- Wrong Answer