# Working with Julia Symbolics

Using Symbolics, wanting Julia to determine that \lfloor\, 10 \sqrt{3} \,\rfloor = 17, and print 17 instead of floor(10sqrt(3))

julia> x = 10 * Symbolics.Term(sqrt,)
10sqrt(3)

julia> y = floor(x)
floor(10sqrt(3))


Also, for x, wanting to print 10 √3 instead of 10sqrt(3) .

Also, I’d like to mimic …

if sqrt(3) < sqrt(2) print("true") else print("false") end

… with …

if Symbolics.Term(sqrt,) < Symbolics.Term(sqrt,) print("true") else print("false") end

However, I’m getting …

TypeError: non-boolean (SymbolicUtils.BasicSymbolic{Bool}) used in boolean context

Again, any insight would be much-appreciated.

That’s an expression not a value.

Again, if you want a value, then don’t use symbolics.

The point of symbolics is to allow for construction of lazy expressions. If you just run floor(10sqrt(3)) then you get 17.

I guess the real question is, what are you trying to do?

I’m trying to use Dirichlet’s Approximation Theorem to find integers a and b such that 1 \le a \le 10 and | a \sqrt{3} - b | \lt \frac{1}{10} . I’d like to express, for example, that when j = 3 and k = 7

• a = k - j = 7 - 3 = 4
• b = \lfloor k \sqrt{3} \rfloor - \lfloor j \sqrt{3} \rfloor = \lfloor 7 \sqrt{3} \rfloor - \lfloor 3 \sqrt{3} \rfloor = 12 - 5 = 7
• | a \sqrt{3} - b | = | 4 \sqrt{3} - 7 | \lt \frac{1}{10} .

I’d like to use Julia to do the calculations symbolically, rather than use floating-point approximations such as \sqrt{3} \approx 1.73205 .