How to represent 5*π symbolically in Julia

Viewed 275

Related to a previous question: I am using Julia Symbolics package and would like to represent 5*pi symbolically. I tried the following to no avail:

using Symbolics
5 * Symbolics.pi      # expanded to 15.707963267948966
Num(5) * Symbolics.pi # expanded to 15.707963267948966

@variables x
Symbolics.pi * x # Gives πx, so it works with variables

Desired result, a symbolic expression using Symbolics.pi and the constant that are not numerically calculated on the spot but are kept as a product of 5 and π and show up as 5π, using Symbolics.pi.

1 Answers

Try:

x = Symbolics.pi * Num(5)
print(x)

Here x should be evaluated, hence pi should be promoted.

Related