Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7680 > unrolled thread
| Started by | Andrzej Kozlowski <akoz@mimuw.edu.pl> |
|---|---|
| First post | 2012-01-09 08:19 +0000 |
| Last post | 2012-01-09 08:19 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Re: SortBy for multiple key sorts Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2012-01-09 08:19 +0000
| From | Andrzej Kozlowski <akoz@mimuw.edu.pl> |
|---|---|
| Date | 2012-01-09 08:19 +0000 |
| Subject | Re: Re: SortBy for multiple key sorts |
| Message-ID | <jee7v6$cso$1@smc.vnet.net> |
>
>
> Except that SortBy by default won't order irrationals except by the
depth of their trees, or something like that. The normal expectation is
that an irrational would be evaluated to machine precision, I would
think.
This has nothing at all to do with "irrationality" and everything with
being a symbolic expression. Consider, for example,
ls = {9, (1 + Sqrt[2])^2 + (1 - Sqrt[2])^2, 1}
All the elements of ls are rational (in fact integers) but:
Sort[ls]
{1, 9, (1 - Sqrt[2])^2 + (1 + Sqrt[2])^2}
Sort[ls, Less]
{1, (1 - Sqrt[2])^2 + (1 + Sqrt[2])^2, 9}
Sort[ls, Less]
{1, (1 - Sqrt[2])^2 + (1 + Sqrt[2])^2, 9}
I dare say, this is exactly as one would expect this to work, since in
principle Mathematica does not replace exact quantities by approximate
ones unless this is specifically requested by the user. Moreover, for
complicated enough numeric quantities (which may result in numerical
instability) machine arithmetic may not be reliable in determining the
order and you could easily end up with wrong expressions. It would
obviously be a very bad idea for Mathematica to use machine precision
arithmetic for such a purpose by default.
Andrzej Kozlowski
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web