On Sat, Jun 6, 2009 at 3:25 AM, smichr<[email protected]> wrote:
>
>
>
> On Jun 6, 12:36 pm, Ivannie <[email protected]> wrote:
>> Hello everyone,
>>
>>     Now I am doing something on trigsimp in simplify.py, I wonder how
>> can I get to know if a symbol a fraction?
>>
>
> Do you mean a symbol or do you mean an expression? I'm not sure a
> symbol (like x) can have a fraction attribute, but an expression like
> y=x/3 can be tested to see if it is a fraction or not by looking at
> the item in the 2nd position of the tuple that fraction(y) returns:
>
> ###
>>>> x=var('x')
>>>> y=x/3
>>>> fraction(y)
> (x, 3)
>>>> fraction(x)
> (x, 1)
> ###
>
> In the case that there is something in the denominator, the 2nd value
> in the tuple is not 1.

fraction() is probably the best things, but you can also access the
.args arguments directly:

In [5]: y = x/3

In [7]: y.args
Out[7]: (1/3, x)

a fraction happens whenever there is one argument in the Mul() that is
1/something.

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to