Symbolics.jl and struct

Should I create structs when using Symbolics.jl or is it better not to use structs and always work with purely symbolic expressions?
For example, if I wanted to create my functions for calculating the truncated Taylor series, is it better to create structs and work with them or is it better to create an expression and define all the rules to handle the various cases, including the management of BigOs? What are the best practices with Symbolics.jl? Thank you.

1 Like

That really depends on what you’re doing.

1 Like

Do you think I should define a struct like this to handle a truncated Taylor series? What do you think about it?(I am not an experienced programmer)

struct Taylor1Series 
    f::Num
    series::Num
    coeff::Array{Num}
    order::Int
    xâ‚€::Number
    remainder::Num
end

Yeah, that’s a reasonable representation. Then start to define operations on that, etc. That’s a nice way to build out code rather than keeping things as tuples.

1 Like

You’ll probably want to have this as a Vector{Num} instead - just Array can also be a multidimensional array (it’s fine if you want that, but just written like that can lead to type instabilities and subsequent drop in performance).

1 Like