It is mathematically correct, just that it may not be the expected output format. SymPy makes (educated) guesses how to represent an expression and how to print it (not always the same guesses are used for the two cases).
Your expression is represented as (use the srepr function on the expression): Mul(Pow(Integer(2), Rational(1, 2)), Pow(pi, Rational(1, 2))) So the two solutions are to avoid splitting Pow(Mul(..., ...), ...) into Mul(Pow(..., ...), Pow(..., ...)) or let the printer look for expressions with the same exponent and print those together. A work-around, if you really want it to print in that exact way is to create the expression without automatic evaluation (which splits the expression) as: Pow(Mul(Integer(2), pi), Rational(1,2), evaluate=False) However, personally, I do not recommend this. The purpose of a CAS is to represent expressions "efficiently", so automatic evaluation is a good thing (try Add(Integer(1), Integer(-1), evaluate=False) ) in general. BR Oscar Den tors 8 aug. 2024 kl 12:20 skrev Rodrigo Koblitz < [email protected]>: > Hi everyone, > > I'm new to SymPy and I'm probably missing something basic. I'm trying to > create the probability density function of the normal distribution, but > I've run into a problem. When I try to create the sqrt(2*pi) part of the > function, Colab displays it as the square of 2 multiplied by the square of > pi, instead of the square root of their product. > > I would really appreciate it if someone could help me with this. > > Thanks! > init_printing(use_unicode=True) > result = sqrt(pi*2) > result > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/190de6eb-d75c-411e-a1e7-167a947242d9n%40googlegroups.com > <https://groups.google.com/d/msgid/sympy/190de6eb-d75c-411e-a1e7-167a947242d9n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAFjzj-%2BsEzwnq7E8L4oWatNogSTLybLYdu3YKHgdx3uRF4Wiuw%40mail.gmail.com.
