ArbNumerics.jl | questions regarding use

Hello,

WSL 2 | Ubuntu 22.04.4
Julia 1.10.2
ArbNumerics 1.5.0

My first go at using extended precision in Julia. Ball arithmetic as implemented in the package ArbNumerics.jl is the method that I would like to use.

To try and learn how to use ArbNumerics, I wrote a short program
that first computes a symbolics Taylor-Maclaurin series expansion pf exp(x^2) followed by numeric substitution: first in standard Float64, then using ArbNumerics.

However, I am clearly missing something in my understanding of ArbNumerics implementation as the two results are the same - no improvement in precision.

The code:

# test_ArbNumerics.jl

using ArbNumerics
using Printf
using Symbolics

# Taylor-Maclaurin series: standard Float64
function Taylor_Maclaurin_series(
            f::Num,
            Dx::Differential,
            x::Num,
            n::Int64)::Num

    f_series = 1

    f_term = [f, Num(0)]

    for i in range(1, n)
        f_term[2] = expand_derivatives(Dx(f_term[1]))
                       
        f_series += 
            Symbolics.value(substitute(f_term[2], Dict(x => 0))) / (factorial(BigInt(i))) * x^i
    
        f_term[1] = f_term[2]
    end

    return f_series
end

# Taylor-Maclaurin series: ArbNumerics
function Taylor_Maclaurin_series_ArbNumerics(
            f::Num,
            Dx::Differential,
            x::Num,
            n::Int64)::Num

    f_series = ArbReal("1")

    f_term = [f, Num(0)]

    for i in range(1, n)
    f_term[2] = expand_derivatives(Dx(f_term[1]))
                
    f_series += 
        Symbolics.value(substitute(f_term[2], Dict(x => ArbReal("0")))) / ArbReal(factorial(BigInt(i))) * x^i

    f_term[1] = f_term[2]
    end

    return f_series
end

function main()
    @variables x

    # Test function
    f = exp(x^2)

    # Derivative
    Dx = Differential(x)

    # Taylor Maclaurin series expansion of test function
    # Expansion order: n
    n = 30
    
    #
    # Standard Float64
    #
    xt = 1.1

    f_TMs = Taylor_Maclaurin_series(
            f,
            Dx,
            x,
            n)

    println("f_TMs: ", f_TMs, "\n")

    f_TMs_nm = Symbolics.value(substitute(f_TMs, Dict(x => 1.0)))

    @printf "f_TMs_nm: %.16g \n"  f_TMs_nm
    @printf "exp(1.0)  %.16g \n" exp(1.0)
    println("e:        2.7182818284590452353602874713527 \n")

    f_TMs_nm = Symbolics.value(substitute(f_TMs, Dict(x => xt)))

    @printf "f_TMs_nm: %.16g \n"  f_TMs_nm
    @printf "exp(%g) %.16g \n\n" xt^2 exp(xt^2)

    #
    # ArbNumerics test version
    #
    setworkingprecision(ArbReal, bits=128)

    xt = ArbReal("1.1")

    f_TMs = Taylor_Maclaurin_series_ArbNumerics(
            f,
            Dx,
            x,
            n)

    f_TMs_am = Symbolics.value(substitute(f_TMs, Dict(x => ArbReal("1.0"))))

    println("typeof(f_TMs_am): ", typeof(f_TMs_am), "\n")

    @printf "f_TMs_am: %.32g \n"  f_TMs_am
    @printf "exp(1.0)  %.32g \n" ArbNumerics.exp(ArbReal("1.0"))
    println("e:        2.7182818284590452353602874713527 \n")

    f_TMs_am = Symbolics.value(substitute(f_TMs, Dict(x => ArbReal(string(xt)))))

    @printf "f_TMs_am: %.32g \n"  f_TMs_am
    @printf "exp(%g) %.32g \n\n" xt^2 ArbNumerics.exp(xt^2)
end

begin
    main()
end

which gives the output

julia> include("test_ArbNumerics.jl")
f_TMs: 1.0 + x^2 + 0.5(x^4) + 0.1666666666666666666666666666666666666666666666666666666666666666666666666666674(x^6) + 0.04166666666666666666666666666666666666666666666666666666666666666666666666666685(x^8) + 0.008333333333333333333333333333333333333333333333333333333333333333333333333333396(x^10) + 0.001388888888888888888888888888888888888888888888888888888888888888888888888888883(x^12) + 0.0001984126984126984126984126984126984126984126984126984126984126984126984126984127(x^14) + 2.480158730158730158730158730158730158730158730158730158730158730158730158730159e-05(x^16) + 2.755731922398589065255731922398589065255731922398589065255731922398589065255725e-06(x^18) + 2.755731922398589065255731922398589065255731922398589065255731922398589065255716e-07(x^20) + 2.505210838544171877505210838544171877505210838544171877505210838544171877505204e-08(x^22) + 2.087675698786809897921009032120143231254342365453476564587675698786809897921014e-09(x^24) + 1.605904383682161459939237717015494793272571050348828126605904383682161459939241e-10(x^26) + 1.147074559772972471385169797868210566623265035963448661861360274058686757099453e-11(x^28) - 2.675932660178072500588950046965145797228427372556499266212877509367465857313922e-16(x^30) - 1.672457912611295312868093779353216123267767107847812041383048443354666160821201e-17(x^32)

f_TMs_nm: 2.718281828458229 
exp(1.0)  2.718281828459045 
e:        2.7182818284590452353602874713527 

f_TMs_nm: 3.353484652534589 
exp(1.21) 3.353484652549025 

typeof(f_TMs_am): ArbReal{128}

f_TMs_am: 2.7182818284582292989171037334017 
exp(1.0)  2.7182818284590450907955982984276 
e:        2.7182818284590452353602874713527 

f_TMs_am: 3.3534846525345884948876573616872 
exp(1.21) 3.3534846525490236146538336470257