[GiNaC-list] Substitution troubles
Jeremy Jay
dinkumator at gmail.com
Tue Feb 24 16:07:12 CET 2009
It's not "intuitive" because I can see a plain single "1" when i print
the poly, and I can call subs(1==q) on the poly with no errors, but
when I print the poly again it is unchanged.
If I were to print your first example as written, I would not see a "4"
in the output and I would not expect anything to be substituted. If I
wanted to make sure I got the 4, I would have to call expand or whatever
appropriately, before the substitution.
In the second example I would expect it to come out to (x^2+A*x+A). I
see 4s and I'm substituting As in their place. If I don't want the 4x
changed I'll have to do some extra work myself, but I don't expect GiNaC
to differentiate between the 4s I see.
I think any of these cases are very "intuitive" for any programmer with
any experience with any pattern matching. A substitution is just that, a
substitution, and it is not "well-defined" mathematically and I don't
really see any reason for it to be as rigorous as you imply. If someone
wants to do silly things like replace 4s with As, let him!
Alexei made his point, yes, but I don't see how it is "correct." He said
that the semantics of a simple substitution rely upon the internal
representation of the polynomial -- although there is no documentation
on this point anywhere on the website. This make it non-intuitive.
If you have a reference for a rigorous mathematical definition of
substitution on numbers feel free to send it to me to correct me.
Jeremy
On Tue 24 Feb 2009 - 01:59PM, Vladimir V. Kisil wrote:
> >>>>> On Tue, 24 Feb 2009 08:50:46 -0500, Jeremy Jay <dinkumator at gmail.com> said:
> JJ> Hmm I guess it makes sense in that regard, but it is certainly
> JJ> non-intuitive.
>
> Please consider two expressions:
>
> ((x+2)^2).subs(4==A) and
> (x^2+4x+4).subs(4==A).
>
> What are "intuitive" answers? Thus even if you are not referring to
> "internal representation" this is the only way to make subs()
> mathematically correct.
>
> I think Alexei made his point absolutely correct.
>
> Best wishes,
> Vladimir
> --
> Vladimir V. Kisil email: kisilv at maths.leeds.ac.uk
> -- www: http://maths.leeds.ac.uk/~kisilv/
More information about the GiNaC-list
mailing list