# Symbolic sqrt(2) and sin(pi)

**URL:** <https://discourse.julialang.org/t/symbolic-sqrt-2-and-sin-pi/58633>\
**Category:** Specific Domains\
**Tags:** symbolic\
**Created:** [April 4, 2021, 7:03pm UTC](https://discourse.julialang.org/t/symbolic-sqrt-2-and-sin-pi/58633 "2021-04-04T19:03:25Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [April 5, 2021, 12:31pm UTC](https://discourse.julialang.org/t/symbolic-sqrt-2-and-sin-pi/58633/7 "2021-04-05T12:31:46Z")

</div>

> [@CAS Best Practices](https://discourse.julialang.org/t/cas-best-practices/58092/75):
>
> If you want it exact, don’t ask for the Float64 result?
> 
> ```julia
> julia> ex = Term(sqrt,[big(2)])
> sqrt(2)
> 
> julia> eval(toexpr(ex))
> 1.414213562373095048801688724209698078569671875376948073176679737990732478462102
> 
> ```
> 
> It just follows Julia’s semantics.

To expand on this, if you only want up to a given number of digits, you can use e.g. ArbNumerics and it will just compose:

```julia
julia> using Symbolics: Term, toexpr                         
                                                             
julia> using ArbNumerics                                     
                                                             
julia> ex = Term(sqrt, [ArbFloat(2; digits=60)])             
sqrt(2.0)                                                    
                                                             
julia> eval(Symbolics.toexpr(ex))                            
1.41421356237309504880168872420969807856967187537694807317668
                                                          
julia> ex = Term(sqrt, [ArbFloat(2; digits=31)])             
sqrt(2.0)                                                    
                                                             
julia> eval(Symbolics.toexpr(ex))                            
1.41421356237309504880168872421                              

```

That’s the power julia enables here - as far as I’m aware, Symbolics.jl does not have any code specific to ArbNumerics.jl, yet it just works with custom types that have functions like `sqrt` defined on them.

---

_[View the full topic](https://discourse.julialang.org/t/symbolic-sqrt-2-and-sin-pi/58633)._
