Hello,

using Sage 6.2 there is this behaviour:

sage: SR(2).power(3,hold=True)
2^3
sage: 3*SR(2).power(3,hold=True)
3*8

or 

sage: SR(2*x).power(3,hold=True)
(2*x)^3
sage: 4 * SR(2*x).power(3,hold=True)
4*(8*x^3)

which I don't know if it is expected.

Because we want  some expressions no to be calculated we are using inert 
functions like the one below.

Pedro

#=======================
# pow for "high school"
#=======================
def _POW_latex(fun,basev,expv):
    if basev==0 and expv!=0:
        return r'0'
    elif basev==1:
        return r'1'
    else:
        return r'%s^{%s}' % (latex(basev),latex(expv))    

bv,ev=SR.var('bv,ev')
POW_ = function('powb', bv, ev, print_latex_func=_POW_latex)

def powb(basev,expv):
    r"""powb is an alternative to ``^`` from Sage that preserves ^ in latex.

    See similar idea for logb.

    INPUT:

    - ``basev`` - the basis argument.

    - ``expv`` - the exponent value.

    OUTPUT:

    - an expression based on ``powb`` that is converted by latex() to a^b 
without calculating.

    Basic cases::

        sage: powb(0,1)
        0
        sage: powb(1,2)
        1
        sage: powb(2,3)
        powb(2, 3)
        sage: latex( powb(2,3) )
        2^{3}

    """
    if basev==0 and expv!=0:
        return 0
    elif basev==1:
        return 1
    else:
        return POW_(bv=basev,ev=expv)

#==================



On Wednesday, January 21, 2015 at 4:01:11 AM UTC, kcrisman wrote:
>
> as expected, this really is a bug in latex(): 
>>
>> sage: latex(120/factorial(5,hold=True)) 
>> \frac{120}{120} 
>> sage: str(120/factorial(5,hold=True)) 
>> '120/factorial(5)' 
>>
>>
> I agree, please feel free to cc: me on such a ticket.  Though it may need 
> digging into Pynac :( 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to