Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.9K Views
|
14 Replies
|
12 Total Likes
View groups...
Share
Share this post:

how to get exact solutions (error free solution)

Posted 11 years ago
Attachments:
POSTED BY: abhishek sharma
14 Replies
POSTED BY: abhishek sharma
POSTED BY: Daniel Lichtblau
POSTED BY: abhishek sharma

Your code exactly evaluates "nc" already: 77/51 is an exact rational number. It has no exact, finite decimal representation: 77/51 is the best you can have. If you want to see lots of digits, try something like N[nc,1000].

POSTED BY: John Doty

Consider an exact polynomial expression:

poly = -6 + 17 x - 32 x^2 + 26 x^3 - 20 x^4 + 14 x^5 - 8 x^6 + 3 x^7

Note that it contains no approximate numbers like 1.4: all of the coefficients are exact rational numbers (integers in this case). In Mathematica, any number containing a decimal point is an approximate number, not an exact number. You cannot expect exact results from approximate input.

Make an equation, solve it:

exact = Solve[poly == 0]
{{x -> 1/3 (1 - I Sqrt[2])}, {x -> 1/3 (1 + I Sqrt[2])}, {x -> 
   Root[-6 + 5 #1 - 4 #1^2 + 3 #1^3 - 2 #1^4 + #1^5 &, 1]}, {x -> 
   Root[-6 + 5 #1 - 4 #1^2 + 3 #1^3 - 2 #1^4 + #1^5 &, 2]}, {x -> 
   Root[-6 + 5 #1 - 4 #1^2 + 3 #1^3 - 2 #1^4 + #1^5 &, 3]}, {x -> 
   Root[-6 + 5 #1 - 4 #1^2 + 3 #1^3 - 2 #1^4 + #1^5 &, 4]}, {x -> 
   Root[-6 + 5 #1 - 4 #1^2 + 3 #1^3 - 2 #1^4 + #1^5 &, 5]}}

I get seven roots, all exact. Two are expressed as radicals, five have no such representation and are expressed using Root. These are the exact solutions, as we can verify:

Simplify[poly /. exact]
{0, 0, 0, 0, 0, 0, 0}

However, if I want numerical results:

approx = NSolve[poly == 0]
{{x -> -0.551685 - 1.25335 I}, {x -> -0.551685 + 1.25335 I}, {x -> 
   0.333333 - 0.471405 I}, {x -> 0.333333 + 0.471405 I}, {x -> 
   0.805786 - 1.2229 I}, {x -> 0.805786 + 1.2229 I}, {x -> 1.4918}}

The numerical solutions are necessarily approximate: exact numerical solutions of this equation are not possible. Most polynomial equations do not have exact numerical solutions: the solutions are irrational and thus have no finite numerical representation. Substituting the approximate solutions back into the original polynomial yields results that are approximately, but not exactly, zero:

poly /. approx
{1.84741*10^-13 + 1.91847*10^-13 I, 1.84741*10^-13 - 1.91847*10^-13 I,
  6.66134*10^-16 + 1.9984*10^-15 I, 
 6.66134*10^-16 - 1.9984*10^-15 I, -1.42109*10^-14 + 
  7.10543*10^-15 I, -1.42109*10^-14 - 
  7.10543*10^-15 I, -2.13163*10^-14}

And that is just as you should expect.

POSTED BY: John Doty

Thanks sir for your precious time.

POSTED BY: abhishek sharma

This is not making sense. You have an approximate set of values and plug them in to compute residuals. How can those residuals possibly be "exactly" zero?

This is a matter of numerical mathematics, not Mathematica.

POSTED BY: Daniel Lichtblau

Sincere thanks for your valuable time.

Here in attachments I am uploading my original problem. I hope Instructions in file attached are clear to understand.

Attachments:
POSTED BY: abhishek sharma
POSTED BY: John Doty
POSTED BY: John Doty

Try NSolve with higher than default WorkingPrecision. And be prepared to wait.

POSTED BY: Daniel Lichtblau

If your problem is complex, Solve will take a long time. That's unavoidable.

POSTED BY: Frank Kampas

yes it worked for this polynomial...

But in my real problem the polynomial in more complex... Neither "Solve" nor "NSolve" are working well for that...

kindly suggest some another method...

If u wish I can upload my orignal equation

POSTED BY: abhishek sharma

NSolve is a numerical algorithm. For exact results, use Solve.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard