On 03/07/2023 13:24, Oscar Benjamin wrote:
Another option is to call S with a string::
In [27]: s = '1 + x*(m + 1/2)/(2*m + 1) + x**2*(m + 1/2)*(m +
3/2)/(2*(2*m + 1)*(2*m + 2))'

In [28]: print(S(s))
x**2*(m + 1/2)*(m + 3/2)/((2*m + 2)*(4*m + 2)) + x*(m + 1/2)/(2*m + 1) + 1

--
Oscar

Thanks Oscar, that is a much more useful feature!


BTW, I couldn't see it mentioned in the documentation for S(), and I think it should definitely also be mentioned in the section of of the SymPy documentation that discusses the problem with Python evaluating expressions like 1/2 in an unhelpful way.

David

--
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/f06320d4-65df-1fba-4def-bd428d6bd407%40dbailey.co.uk.

Reply via email to