This hasn't been implemented yet.  There was a lot of discussion on
parsing back during the GSoC selection period.  See
https://github.com/sympy/sympy/wiki/parsing.

Note also that there's some ambiguity depending on how smart you want
to be.  Should √a*b parse as sqrt(a)*b or sqrt(a*b)?  The same for
√ab.  I would expect √a*b to parse as sqrt(a)*b and √ab to parse as
sqrt(ab) (where ab is one Symbol named ab).

If you agree with that, then I think this can be done with a simple
regular expression.  If √ is followed by a (, just replace it with
"sqrt".  If it is followed by a chain of letters, numbers, or
underscores, replace it with sqrt and put parentheses around the
letters, numbers, and underscores.  Otherwise, it is a syntax error.
This can be done easily with a regular expression search and replace,
like

√\( -> sqrt\(
√([a-zA-Z0-9_]+) -> sqrt\(\1\)

And then after doing those replacements, if the string still contains
√, there is an error.

I didn't test this, so there may be a typo.  Also, depending on what
variant of regular expressions you use, you may have to swap
parentheses and escaped parentheses.

Aaron Meurer

Fri, May 11, 2012 at 7:56 AM, gsagrawal <[email protected]> wrote:
> By any chance if in a string i have unicode of symbols like square root and
> than expression , can sympy parse it ??
>
> I am trying this in following way
> . if expression is like  √(a+b)   its easy . i can jusr replace  √ with sqrt
> ..and this will work ,
> but in case like  √2 or  √a*b or  √ab or √a_1 or √23 or  √2+3 need to go for
> regex and than do the parsing.
>
> Just thinking if this is already implemented or any other/easy way to do
> this ?
>
> --
> 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