Skip to main content
deleted 268 characters in body
Source Link
Mark McClure
  • 32.6k
  • 3
  • 103
  • 163

As the responses show, there are a number of quick "probably real" tests. In general, the problem is undecidable, however. This is an easy corollary of Richardson's theorem, which says that it is impossible to decide if two real expressions $x$ and $y$ are equal. Assuming Richardson's theorem, note that $(x-y)i$ is real if and only if $x=y$.

As a more mundane example, that arises in common practice with Mathematica, consider the polynomial $p(x)=13x^3-13x-1$. It's easy to see that all three roots are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Given the undecidability, perhaps you might as well use some numerical evaluation, as in

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

This seems to work for all the examples on this page, although, we could certainly find examples where it fails.

As the responses show, there are a number of quick "probably real" tests. In general, the problem is undecidable, however. This is an easy corollary of Richardson's theorem, which says that it is impossible to decide if two real expressions $x$ and $y$ are equal. Assuming Richardson's theorem, note that $(x-y)i$ is real if and only if $x=y$.

As a more mundane example, that arises in common practice with Mathematica, consider the polynomial $p(x)=13x^3-13x-1$. It's easy to see that all three roots are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Given the undecidability, perhaps you might as well use some numerical evaluation, as in

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

This seems to work for all the examples on this page, although, we could certainly find examples where it fails.

As the responses show, there are a number of quick "probably real" tests. In general, the problem is undecidable, however. This is an easy corollary of Richardson's theorem, which says that it is impossible to decide if two real expressions $x$ and $y$ are equal. Assuming Richardson's theorem, note that $(x-y)i$ is real if and only if $x=y$.

As a more mundane example, that arises in common practice with Mathematica, consider the polynomial $p(x)=13x^3-13x-1$. It's easy to see that all three roots are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

added 449 characters in body
Source Link
Mark McClure
  • 32.6k
  • 3
  • 103
  • 163

As the responses show, there are a number of quick "probably real" tests. I'm sure that In general, the problem is undecidable, in generalhowever. This is an easy corollary of Richardson's theorem, thoughwhich says that it is impossible to decide if two real expressions $x$ and $y$ are equal. For Assuming Richardson's theorem, note that $(x-y)i$ is real if and only if $x=y$.

As a more mundane example, it'sthat arises in common practice with Mathematica, consider the polynomial $p(x)=13x^3-13x-1$. It's easy to see that all three of the roots of the polynomial $p(x)=13x^3-13x-1$ are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Not surprisinglyGiven the undecidability, perhaps you might as well use some numerical evaluation, as in

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

worksThis seems to work for theseall the examples but muston this page, although, we could certainly be fraught with its own problemsfind examples where it fails.

As the responses show, there are a number of quick "probably real" tests. I'm sure that the problem is undecidable, in general, though. For example, it's easy to see that all three of the roots of the polynomial $p(x)=13x^3-13x-1$ are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Not surprisingly,

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

works for these examples but must certainly be fraught with its own problems.

As the responses show, there are a number of quick "probably real" tests. In general, the problem is undecidable, however. This is an easy corollary of Richardson's theorem, which says that it is impossible to decide if two real expressions $x$ and $y$ are equal. Assuming Richardson's theorem, note that $(x-y)i$ is real if and only if $x=y$.

As a more mundane example, that arises in common practice with Mathematica, consider the polynomial $p(x)=13x^3-13x-1$. It's easy to see that all three roots are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Given the undecidability, perhaps you might as well use some numerical evaluation, as in

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

This seems to work for all the examples on this page, although, we could certainly find examples where it fails.

added 160 characters in body
Source Link
Mark McClure
  • 32.6k
  • 3
  • 103
  • 163

As the responses show, there are a number of quick "probably real" tests. I'm sure that the problem is undecidable, in general, though. For example, it's easy to see that all three of the roots of the polynomial $p(x)=13x^3-13x-1$ are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Not surprisingly,

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

works for these examples but must certainly be fraught with its own problems.

As the responses show, there are a number of quick "probably real" tests. I'm sure that the problem is undecidable, in general, though. For example, it's easy to see that all three of the roots of the polynomial $p(x)=13x^3-13x-1$ are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

As the responses show, there are a number of quick "probably real" tests. I'm sure that the problem is undecidable, in general, though. For example, it's easy to see that all three of the roots of the polynomial $p(x)=13x^3-13x-1$ are real (even if they don't look it), yet they don't pass any of the test here.

roots = x /. Solve[13 x^3 - 13 x - 1 == 0, x]
Internal`RealValuedNumericQ /@ roots

enter image description here

Not surprisingly,

realQ[x_] := Internal`RealValuedNumericQ[Chop[N[x]]]

works for these examples but must certainly be fraught with its own problems.

Source Link
Mark McClure
  • 32.6k
  • 3
  • 103
  • 163
Loading