Message Boards Message Boards

1
|
5462 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

An interesting property of AlgebraicNumber

Posted 9 years ago

Consider the following expression:

thing = ((1 + I Sqrt[3]) (1/10 (9 + I Sqrt[2319]))^(1/3))/(
  2 3^(2/3)) + (1 - I Sqrt[3])/(3/10 (9 + I Sqrt[2319]))^(1/3) + 
  Sin[1]

It's actually a real constant, as you can get Mathematica to verify if you ask with enough "pretty please":

FullSimplify[Element[thing, Reals]]
(* True *)

However, it grows the common imaginary fungus when you try to get a numeric value:

thing // N
(* 0.941979 - 1.11022*10^-16 I *)

Root objects behave better as algebraic numbers than radical expressions do, and the troublesome part of thing is the algebraic part. So, one idea I tried yesterday was defining a function that turns radical expressions to Root objects:

mkAlgebraic[x_] := AlgebraicNumber[x, {0, 1}]

I was thinking of it as a TransformationFunction for Simplify, but then I found that AlgebraicNumber recognizes and gracefully excludes non-algebraic parts of expressions!

mkAlgebraic[thing]
(* Root[1 - 10 #1 + 5 #1^3 &, 2] + Sin[1] *)

This is better behaved in numerical evaluation:

mkAlgebraic[thing] // N
(* 0.941979 *)

I wonder if this is more reliable than // N // Chop.

POSTED BY: John Doty
2 Replies

How about something like the following?

FullSimplify[Re[thing]]
% // N
FullSimplify[Im[thing]]

(* Root[1 - 10 #1 + 5 #1^3 &, 2] + Sin[1] *)

(* 0.941979 *)

(* 0 *)

POSTED BY: Gerard Kopcsay

FullSimplify works, but it is much slower:

Timing[mkAlgebraic[thing]]
(* {0.052406, Root[1 - 10 #1 + 5 #1^3 &, 2] + Sin[1]} *)
Timing[FullSimplify[Re[thing]] + FullSimplify[Im[thing]]]
(* {3.76156, Root[1 - 10 #1 + 5 #1^3 &, 2] + Sin[1]} *)
POSTED BY: John Doty
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract