# Symbolics.jl and struct

**URL:** <https://discourse.julialang.org/t/symbolics-jl-and-struct/86490>\
**Category:** Modelling & Simulations\
**Tags:** symbolics\
**Created:** [August 29, 2022, 9:59am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490 "2022-08-29T09:59:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty](https://avatars.discourse-cdn.com/v4/letter/q/4491bb/32.png) [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Post date:** [August 29, 2022, 9:59am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490/1 "2022-08-29T09:59:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 29, 2022, 10:41am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490/2 "2022-08-29T10:41:49Z")

</div>

That really depends on what you’re doing.

---

<div class="post-metadata">

**Author:** ![qwerty](https://avatars.discourse-cdn.com/v4/letter/q/4491bb/32.png) [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Post date:** [August 29, 2022, 10:52am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490/3 "2022-08-29T10:52:42Z")

</div>

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)

```julia
struct Taylor1Series 
    f::Num
    series::Num
    coeff::Array{Num}
    order::Int
    x₀::Number
    remainder::Num
end

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 29, 2022, 11:05am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490/4 "2022-08-29T11:05:56Z")

</div>

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.

---

<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:** [August 29, 2022, 11:08am UTC](https://discourse.julialang.org/t/symbolics-jl-and-struct/86490/5 "2022-08-29T11:08:44Z")

</div>

> [@qwerty](#):
>
> `coeff::Array{Num}`

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