Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11930 > unrolled thread
| Started by | Alex Krasnov <akrasnov@eecs.berkeley.edu> |
|---|---|
| First post | 2012-10-03 07:12 +0000 |
| Last post | 2012-10-04 03:39 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
issues with expression manipulation functions Alex Krasnov <akrasnov@eecs.berkeley.edu> - 2012-10-03 07:12 +0000
Re: issues with expression manipulation functions Daniel Lichtblau <danl@wolfram.com> - 2012-10-04 03:39 +0000
| From | Alex Krasnov <akrasnov@eecs.berkeley.edu> |
|---|---|
| Date | 2012-10-03 07:12 +0000 |
| Subject | issues with expression manipulation functions |
| Message-ID | <k4gohn$39e$1@smc.vnet.net> |
In the process of learning Mathematica, I discovered several items of
unusual behavior. I would appreciate any clarification.
(0) Several expression manipulation functions behave correctly with
HoldComplete subexpressions but not with Hold subexpressions. Example:
In: Together[1/x+HoldComplete[1]/x]
Out: (1 + HoldComplete[1])/x
In: Together[1/x+Hold[1]/x]
Out: x^(-1) + Hold[1]/x
Another example:
In: Factor[3+3*HoldComplete[x]+HoldComplete[x]^2, Extension -> {Sqrt[3], I}]
Out: ((-3*I + Sqrt[3] - (2*I)*HoldComplete[x])*(3*I + Sqrt[3] + (2*I)*HoldComplete[x]))/4
In: Factor[3+3*Hold[x]+Hold[x]^2, Extension -> {Sqrt[3], I}]
Out: (kernel crash)
Although the last example is clearly a bug, is there some difference in
behavior between HoldComplete and Hold that generally accounts for these
issues? The documentation mentions differences with respect to Sequence,
Unevaluated, Evaluate, and upvalues. Without knowing the internals of the
expression manipulation functions, I fail to see how any of these are
relevant here.
(1) FactorTerms behaves incorrectly if the independent form is more
complex than a symbol and not contained in the expression. Example:
In: FactorTerms[x, x^2]
Out: Sqrt[x]
In my understanding, FactorTerms should always return an equivalent
expression. Is this a bug or some sort of undocumented behavior? Does
FactorTerms require the independent form to be a symbol?
I am using Mathematica 8.0.4 on Windows.
Alex
[toc] | [next] | [standalone]
| From | Daniel Lichtblau <danl@wolfram.com> |
|---|---|
| Date | 2012-10-04 03:39 +0000 |
| Message-ID | <k4j0e2$7mo$1@smc.vnet.net> |
| In reply to | #11930 |
On Oct 3, 2:14 am, Alex Krasnov <akras...@eecs.berkeley.edu> wrote:
> In the process of learning Mathematica, I discovered several items of
> unusual behavior. I would appreciate any clarification.
>
> (0) Several expression manipulation functions behave correctly with
> HoldComplete subexpressions but not with Hold subexpressions. Example:
>
> In: Together[1/x+HoldComplete[1]/x]
> Out: (1 + HoldComplete[1])/x
>
> In: Together[1/x+Hold[1]/x]
> Out: x^(-1) + Hold[1]/x
>
> Another example:
>
> In: Factor[3+3*HoldComplete[x]+HoldComplete[x]^2, Extension -> {Sqrt[3], I}]
> Out: ((-3*I + Sqrt[3] - (2*I)*HoldComplete[x])*(3*I + Sqrt[3] + (2*I)*HoldComplete[x]))/4
>
> In: Factor[3+3*Hold[x]+Hold[x]^2, Extension -> {Sqrt[3], I}]
> Out: (kernel crash)
That will get fixed. Thanks for the simple example.
> Although the last example is clearly a bug, is there some difference in
> behavior between HoldComplete and Hold that generally accounts for these
> issues? The documentation mentions differences with respect to Sequence,
> Unevaluated, Evaluate, and upvalues. Without knowing the internals of the
> expression manipulation functions, I fail to see how any of these are
> relevant here.
>
> (1) FactorTerms behaves incorrectly if the independent form is more
> complex than a symbol and not contained in the expression. Example:
>
> In: FactorTerms[x, x^2]
> Out: Sqrt[x]
>
> In my understanding, FactorTerms should always return an equivalent
> expression. Is this a bug or some sort of undocumented behavior? Does
> FactorTerms require the independent form to be a symbol?
Both. I'm putting in a provisional fix. Nevertheless, FactorTerms will
not
necessarily play nice with "variables" that are not bona fide
variables,
e.g. sums or products or powers.
> I am using Mathematica 8.0.4 on Windows.
>
> Alex
Regarding Hold vs. HoldComplete, you are correct that they get
treated differently. The reason is that several years ago the
handling of Hold inside expressions seen by Together, Factor,
and the like was changed. This was to correct for trouble caused
by infinite recursion, wherein Hold would get wrapped around an
expression and then be poorly handled by subsequent processing.
Here is an example.
f[1, x_] := PolynomialQ[1 - x, x];
f[n_Integer /; n > 0, x_] := Block[{m = n - 1}, f[m, x]]
f[255, x]
Anyway, it turns out that later changes may have sufficed to
address this elsewhere. We might try to remove the prior change
and see if any mayhem creeps back in.
Daniel Lichtblau
Wolfram Research
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web