As a maple user I can say that sage is difficult to use if you just
going to do some simple math. The main reason is - I used to deal with
symbolic computation. So what's wrong with symbolic in Sage?

To do some complex symbolic computation I usually need symbolic
variables, functions, regular numbers, strings, vectors, matrices and
of course collections to store all this data. Also I need simple way
to check what is that I deal with. Is it collection or may be sum, or
just a logarithmic function? And of course I need some unified way to
get parts of expression I deal with.

But what I get when I use sage? I always need to check is expression
belong to some type (python or sage) and then depends on what it was I
can use some specific methods.

e.g. if I have symbolic expression expr=diff(f,x)+x+1 I can call
operator() method and then I'm able to compare is it operator.add or
not by writing expr.operator() == operator.add
but if expr=diff(f,x) I can't compare it in such way, I should use
instanceof() to check if expr.operator() it is instance of
FDerivativeOperator.
What is worst if I have just a number 1 or set of smth I cant even
call operator method cause they don't have one.

Sounds really bad especially for those who use sage for first time.
But even for programmers I think it is bad approach to deal with
symbolical expression in their algorithms.

So.. I decided to make life easier and to make wraps around everything
I need to make my math. So In this approach everything - integers,
floats, rationals, lists, tuples, functions, derivatives, symbolic
vars, vectors, matrices, and so on treats as symbolical expression.
Which means I can do following operations with them:

1. get their symbolic type mtype(expr)
    sage: x=var('x')
    sage: eq=x+1
    sage: stype(eq)
    '+.relation'

    sage: x=var('x')
    sage: eq=2*x
    sage: stype(eq)
    '*.relation'

    sage: x=var('x')
    sage: f=function('f',x)
    sage: expr=[1, x, f]
    sage: mtype(expr)
    'list.collection'
    sage: map(mtype, expr)
    ['integer.number', 'symbolic.variable', 'symbolic.function']

2. check if their symbolic type is belongs to some group of types
mtype(expr,'_relations _.4.vector ")
    sage: x=var('x')
    sage: eq=x+1
    sage: mtype(eq,'_+')
    True

    sage: x=var('x')
    sage: eq=x+1
    sage: mtype(eq,'+')
    False

    sage: x=var('x')
    sage: eq=x+1
    sage: mtype(eq,'+.relation')
    True

    sage: x=var('x')
    sage: eq=2*x
    sage: mtype(eq,'_+')
    False

    sage: x=var('x')
    sage: eq=2*x
    sage: mtype(eq,'*')
    True

    sage: a,b=var('a b')
    sage: mtype(a>=b,'>=.relation')
    True
    sage: mtype(a>=b,'>.relation')
    False
    sage: mtype(a>=b,'==.relation')
    False
    sage: mtype(a>=b,'_=')
    True
    sage: mtype(a>=b,'_>')
    True
    sage: mtype(a>=b,'_>.')
    False
    sage: mtype(a>=b,'_>=.')
    True

3. get list of operands ops(expr)
    sage: a=var('a')
    sage: t=1,2,a
    sage: ops(t)
    [1, 2, a]

    sage: x=var('x')
    sage: y=function('y',x)
    sage: eq=diff(y,x)+y+x+1
    sage: ops(eq)
    [D[0](y)(x), y(x), x, 1]

    sage: x,t=var('x t')
    sage: y=function('y',x,t)
    sage: eq=diff(y,x,t,t)
    sage: q=ops(eq)
    sage: q
    [y(x, t), x, t, t]
    sage: qq=ops(q,1)
    sage: qq
    y(x,t)
    sage: ops(qq)
    [x, t]

    sage: x=var('x')
    sage: ops(x)
    []

    sage: ops(1)
    []

4. calculate number of operands nops(expr)
    sage: a=var('a')
    sage: t=1,2,a
    sage: nops(t)
    3

    sage: x=var('x')
    sage: y=function('y',x)
    sage: eq=diff(y,x)+y+x+1
    sage: nops(eq)
    4

5.get operator op(expr)
and be sure that op(expr)(ops(expr)) - expr ==0
    sage: x,t=var(x,t)
    sage: f=function('f',x,t)
    sage: f
    f(x,t)
    sage: ops(f)
    [x,t]
    sage: op(f)(op(f))
    f(x,t)
    sage: op(f)(ops(f)) - f
    0

6. get subexpressions of expression by given types indets(expr,
'_.vector')
    sage: x,a,b,c,t=var('x,a,b,c,t')
    sage: y=function('y',t,x)
    sage: eq=a*(diff(y,t,x))^2+b*diff(y,x)+3+x+ln(x+1)+c*x
    sage: indets(eq,'diff')
    set([D[0, 1](y)(t, x), D[1](y)(t, x)])
    sage: indets(eq,'_function')
    set([log(x + 1), y(t, x)])
    sage: indets(eq,'_function diff')
    set([D[0, 1](y)(t, x), D[1](y)(t, x), log(x + 1), y(t, x)])

    sage: x,a,b,c,t=var('x,a,b,c,t')
    sage: g=function('g',x)
    sage: f=function('f',t,x)
    sage: eq=a*x+3+b*sin(x)+ln(f+x)+tan(1/x)+g+exp(c+t)
    sage: eq
    a*x + b*sin(x) + e^(c + t) + log(x + f(t, x)) + tan(1/x) + g(x) +
3
    sage: indets(eq,'_function')
    set([sin(x), log(x + f(t, x)), f(t, x), g(x), tan(1/x), e^(c +
t)])
    sage: indets(eq,'_standard.function')
    set([sin(x), tan(1/x), log(x + f(t, x)), e^(c + t)])
    sage: indets(eq,'_trig.standard.function')
    set([sin(x), tan(1/x)])
    sage: indets(eq,'_trig')
    set([sin(x), tan(1/x)])
    sage: indets(eq,'_logarithmic.standard.function')
    set([log(x + f(t, x)), e^(c + t)])
    sage: indets(eq,'_logarithmic')
    set([log(x + f(t, x)), e^(c + t)])
    sage: indets(eq,'log.logarithmic.standard.function')
    set([log(x + f(t, x))])
    sage: indets(eq,'_log')
    set([log(x + f(t, x)), e^(c + t)])
    sage: indets(eq,'symbolic.function')
    set([f(t, x), g(x)])
    sage: indets(eq,'symbolic.variable')
    set([c, t, a, x, b])
    sage: indets(eq,'_symbolic')
    set([f(t, x), g(x), b, c, t, a, x])

    sage: eq=log(x+1)+dilog(x+3)
    sage: indets(eq,'_log')
    set([dilog(x + 3), log(x + 1)])
    sage: indets(eq,'log.logarithmic.standard.function')
    set([log(x + 1)])

    sage: x=var('x')
    sage: eq=(x+1)^2+ln(x+1)+3+x
    sage:indets(eq,'_+')
    set([x+1,(x+1)^2+ln(x+1)+3+x])

    sage: eq=x + log((x + 5)/7) + 5
    sage: eq
    x + log(1/7*x + 5/7) + 5
    sage: indets(eq,'rational.number')
    set([5/7, 1/7])
    sage: indets(eq,'integer.number')
    set([5])
    sage: indets(eq,'_number')
    set([5/7, 5, 1/7])


Actually all this work is done. But as I new to sage and have not so
much time it is more like good skeleton for further work in this
direction.

I will add code to trac as soon as possible.

P.S.: fill free to contact me if you are interested in or just for
feedback.

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

To unsubscribe from this group, send email to 
sage-devel+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to