Unfortunately, relational assumptions have not yet been implemented,
though they have been planned for a long time (see
http://code.google.com/p/sympy/issues/detail?id=1047).  I don't know
how dynamic of assumptions you want to be able to put on theta.  If
you just want to be able to assume that cos is positive, you might be
able to substitute it with a positive symbol and then back substitute
once the square root is reduced.

Aaron Meurer

On Thu, Aug 11, 2011 at 5:25 PM, Alan Bromborsky <[email protected]> wrote:
> On 08/11/2011 07:04 PM, Tomo Lazovich wrote:
>
> I just tried this in isympy and as long as you specify both real and
> positive, it seems to work:
>
> In [1]: r = Symbol('r', real=True, positive=True)
>
> In [2]: sqrt(r*r)
> Out[2]: r
>
> In [3]: r = Symbol('r', real=True)
>
> In [4]: sqrt(r*r)
> Out[4]: │r│
>
>
> On Thu, Aug 11, 2011 at 6:01 PM, Alan Bromborsky <[email protected]>
> wrote:
>>
>> I have a symbol r which should be assumed real and greater than zero.
>>  What I want is for sqrt(r*r) to evaluate to r.  Can this be currently done
>> in sympy.  I am trying to clean up some old code that has a lot of hacks in
>> it (curvilinear coordinates).
>>
>> --
>> 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.
>>
>
> --
> 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.
>
> That worked fine.  Now for another similar and more difficult problem.
> Evaluate sqrt(r**2*cos(theta)**2)  where -pi/2<theta<pi/2.  This should
> evaluate to r*cos(theta).   Are symbol assumptions flexible enough yet to
> handle this case (again curvilinear coordinates)?
>
> --
> 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.
>

-- 
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