Symbolic sqrt(2) and sin(pi)

There’s still something I don’t get:

julia> using Symbolics: Term

julia> @variables x
(x,)

julia> expr1 = Term(sqrt, [big(2)])
sqrt(2)

julia> expr2 = expr1 + x
x + sqrt(2)

julia> expr3 = substitute(expr2, Dict([x => 0]))
1.414213562373095048801688724209698078569671875376948073176679737990732478462102

julia> typeof(expr1)
Term{Real,Nothing}

julia> typeof(expr3)
Num

What I expected to happen is that expr1 and expr3 would be the same but instead expr3 does not seem to be a symbolic object. You describe it as exact but the printed representation looks more like a high-precision approximation. In an exact representation I would expect to be able to query the object in some way to discover that it represents sqrt(2) symbolically but I don’t see a way to do that with expr3.

2 Likes