On Wed, Jan 19, 2011 at 10:16 AM, kcrisman <[email protected]> wrote:
>
>
> On Jan 19, 8:24 am, ancienthart <[email protected]> wrote:
>> Attempting to use this on my matrix, I end up with the following results (D
>> is my matrix):
>
>>
>> I personally wish that sage simplify functions worked as follows:
>>
>> simplify_rational and simplify_trig work as currently implemented.
>> simplify was renamed simplify_basic
>> Simplify was replaced with a new method/function that try/excepted the
>> algorithms in simplify_full, simplify_trig, simplify_rational then
>> simplify_basic, returning the first that succeeded.
>> I understand the need to provide functions that control the level of detail
>> used when simplifying complex problems.
>> However I'd assume that most basic/mid-level users just want the
>> expression/equation/object simplified with as little fiddly-ness as
>> possible. Currently I tend to call simplify_full on most problems - I.e.
>> simplify_full is my practical default rather than simplify.
>
> I feel like there is a ticket out there to refactor a lot of this kind
> of stuff (simplify, expand, factor, etc.).  Since there is a lot of
> disagreement on what exactly is the best course of action, we have
> thus far continued our current scheme.  I think that this is not the
> worst of the proposals I've heard.
>
> More important is the option to apply a lot of things to a matrix.
> Simon's got the right idea (lambda functions) for what you want to
> do.  But we should make this easier.  My guess is that even the
> 'magic' decorator for turning methods into functions wouldn't help
> here, and that is too bad.  Maybe matrices need some way for that to
> happen - but I have no idea how one would implement something general
> like that, esp. if one couldn't tell ahead of time whether all the
> elements would have the method.

sage: A = random_matrix(SR, 3) - x; A
[    -x     -2     -2]
[     2 -x - 1     -2]
[    -1     -2 -x + 1]
sage: A.apply_map(type(x).simplify_full)
[    -x     -2     -2]
[     2 -x - 1     -2]
[    -1     -2 -x + 1]

sage: A = matrix(3, 3, [(1+x)^k for k in range(9)]); A
[        1     x + 1 (x + 1)^2]
[(x + 1)^3 (x + 1)^4 (x + 1)^5]
[(x + 1)^6 (x + 1)^7 (x + 1)^8]
sage: type(x)
<type 'sage.symbolic.expression.Expression'>
sage: A.apply_map(Expression.expand)
[                                                                 1
                                                          x + 1
                                              x^2 + 2*x + 1]
[                                             x^3 + 3*x^2 + 3*x + 1
                                  x^4 + 4*x^3 + 6*x^2 + 4*x + 1
                    x^5 + 5*x^4 + 10*x^3 + 10*x^2 + 5*x + 1]
[                  x^6 + 6*x^5 + 15*x^4 + 20*x^3 + 15*x^2 + 6*x + 1
      x^7 + 7*x^6 + 21*x^5 + 35*x^4 + 35*x^3 + 21*x^2 + 7*x + 1 x^8 +
8*x^7 + 28*x^6 + 56*x^5 + 70*x^4 + 56*x^3 + 28*x^2 + 8*x + 1]


Also, +1 to renaming apply_map to map. The top-level map is a Python
function, perhaps we could re-purpose it if the first argument has a
map method?

- Robert

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to