# Symbolic .+ fails when substitute with fold=true

**URL:** <https://discourse.julialang.org/t/symbolic-fails-when-substitute-with-fold-true/125687>\
**Category:** General Usage\
**Created:** [February 8, 2025, 3:36pm UTC](https://discourse.julialang.org/t/symbolic-fails-when-substitute-with-fold-true/125687 "2025-02-08T15:36:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobbesU](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robbesu/32/212459_2.png) [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Post date:** [February 8, 2025, 3:36pm UTC](https://discourse.julialang.org/t/symbolic-fails-when-substitute-with-fold-true/125687/1 "2025-02-08T15:36:40Z")

</div>

When `substitute`ing a symbolic equation, I get `.+` throwing an error when used on its own with `fold=true`.  
Example below: All equations work apart from a1b, which fails with

```julia
MethodError: no method matching +(::Vector{Float64}, ::Float64)
For element-wise addition, use broadcasting with dot syntax: array .+ scalar
The function `+` exists, but no method is defined for this combination of argument types.

```

And oddly, f3 which also contains `.+` but preceded with a `.*` does work!

If this is intended behaviour, could somebody explain the rationale for me?

```julia
a0 = [1., 2.25, 3.]
b0 = 1.

@variables a b  

f1 = 2a .+ b
f2 = 2a .* b
f3 = 2a .* b .+ a

a1b = substitute( f1, Dict([a=>a0, b=>b0]); fold=true)  
# >>> this fails

a1a = substitute( f1, Dict([a=>a0, b=>b0]); fold=false)  
# this works# 1 + 2[1.0, 2.25, 3.0]	

a2a = substitute( f2, Dict([a=>a0, b=>b0]); fold=false)  
# this works # [2.0, 4.5, 6.0][Base.OneTo(3)]

a2b = substitute( f2, Dict([a=>a0, b=>b0]); fold=true)   
# this works # [2.0, 4.5, 6.0][Base.OneTo(3)]

a3a = substitute( f3, Dict([a=>a0, b=>b0]); fold=false)  
# this works # [1.0, 2.25, 3.0] + 2[1.0, 2.25, 3.0]*1

a3b = substitute( f3, Dict([a=>a0, b=>b0]); fold=true)   
# this works # [3.0, 6.75, 9.0][Base.OneTo(3)]
		

```

---

<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:** [February 8, 2025, 4:07pm UTC](https://discourse.julialang.org/t/symbolic-fails-when-substitute-with-fold-true/125687/2 "2025-02-08T16:07:26Z")

</div>

Open an issue

---

<div class="post-metadata">

**Author:** ![RobbesU](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robbesu/32/212459_2.png) [@RobbesU](https://discourse.julialang.org/u/RobbesU)\
**Post date:** [February 10, 2025, 8:57am UTC](https://discourse.julialang.org/t/symbolic-fails-when-substitute-with-fold-true/125687/3 "2025-02-10T08:57:49Z")

</div>

issue opened: [.+ operator fails when substitute() with fold=true · Issue #1433 · JuliaSymbolics/Symbolics.jl · GitHub](https://github.com/JuliaSymbolics/Symbolics.jl/issues/1433)
