# How do I make dynamically named symbols?

**URL:** <https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [September 18, 2022, 9:41pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450 "2022-09-18T21:41:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AwesomeQuest](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/awesomequest/32/38910_2.png) [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Post date:** [September 18, 2022, 9:41pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450/1 "2022-09-18T21:41:19Z")

</div>

I’m making a function that calculates the equation for the error of a given symbolic equation.

```julia
using Symbolics
function findErrorFromSym(sym)
    vars = Symbolics.get_variables(sym)
    @variables varErrs[eachindex(vars)]
    Dvars = [expand_derivatives(Differential(i)(sym)) for i in vars]
    symErr = sqrt(sum((Dvars[i]*varErrs[i])^2 for i in eachindex(vars)))
    return symErr
end

```

But I’m currently just using an array of variables to store the error of each variable, but this is ugly and unintuitive when working with an equation with a’s b’s and c’s.

How can I make dynamically named symbols that just have “Err” on the end?

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 18, 2022, 10:13pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450/2 "2022-09-18T22:13:26Z")

</div>

```julia
julia> suffix_err(s::Union{Symbol,String}) = 
           Symbol(string(s,"Err"))
julia> suffix_err(:Sym)
:SymErr
julia> suffix_err("Str")
:StrErr

```

you could use “\_err” rather than “Err”

---

<div class="post-metadata">

**Author:** ![AwesomeQuest](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/awesomequest/32/38910_2.png) [@AwesomeQuest](https://discourse.julialang.org/u/AwesomeQuest)\
**Post date:** [September 18, 2022, 10:58pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450/3 "2022-09-18T22:58:54Z")

</div>

It seems I can’t pass that to @variables.  
If I try:

> @variables suffix\_err(:Sym)

It tries to make a variable suffix\_err that is a function of :Sym.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [September 18, 2022, 11:04pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450/4 "2022-09-18T23:04:02Z")

</div>

yes – I misread the post, answering how to make symbols for Julia rather than about working with Symbolics.jl.

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [September 18, 2022, 11:54pm UTC](https://discourse.julialang.org/t/how-do-i-make-dynamically-named-symbols/87450/5 "2022-09-18T23:54:50Z")

</div>

I think you can use the [`variable`](https://github.com/JuliaSymbolics/Symbolics.jl/blob/master/src/variable.jl#L470) function in this case.
