Symbolic sqrt(2) and sin(pi)

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> 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.

7 Likes