Search code examples
juliasymbolic-math

Sqrt of constant representation in Julia Symbolics


I am looking for a way to represent a symbolic expression such as sqrt(3)*x so as to avoid sqrt(3) being calculated upfront.

Sample code:

using Symbolics
@variables x
y = sqrt(3)*x

Showing y, we can see that sqrt(3) has become a floating point.

Is there a mechanism to keep the sqrt in symbolic form?


Solution

  • is there a mechanism to keep the sqrt in symbolic form?

    julia> using Symbolics
    julia> @variables x
    (x,)
    julia> y = Symbolics.Term(sqrt,[3])*x
    
    x*sqrt(3)