# I think a bug in Symbolics package, but not sure

**URL:** <https://discourse.julialang.org/t/i-think-a-bug-in-symbolics-package-but-not-sure/135521>\
**Category:** General Usage\
**Created:** [February 7, 2026, 5:01am UTC](https://discourse.julialang.org/t/i-think-a-bug-in-symbolics-package-but-not-sure/135521 "2026-02-07T05:01:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ejolson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ejolson/32/24077_2.png) [@ejolson](https://discourse.julialang.org/u/ejolson)\
**Post date:** [February 7, 2026, 5:01am UTC](https://discourse.julialang.org/t/i-think-a-bug-in-symbolics-package-but-not-sure/135521/1 "2026-02-07T05:01:10Z")

</div>

I try the code

```julia-auto
using Symbolics
D(f,x)=expand_derivatives(Differential(x)(f))
@variables H,S,r1
K1=10000.0; K2=6000.0;
a1=0.5; a2=0.5; r2=0.25;
dHdt(H,S)=r1*H*(1-(a1*S+H)/K1)
dSdt(H,S)=r2*S*(1-(S+a2*H)/K2)
f(H,S)=dHdt(H,S)+dSdt(H,S)

dfdH=expand(D(f(H,S),H))
dfdS=expand(D(f(H,S),S))
Asym=-[D(dfdH,H) D(dfdH,S);D(dfdS,H) D(dfdS,S)]
bsym=[substitute(dfdH,[H=>0,S=>0]),
      substitute(dfdS,[H=>0,S=>0])]
Xsym=Asym\bsym
substitute(Xsym[1],r1=>0.10)
simplify(Xsym[1])

```

and the last two evaluations return

```julia-auto
julia> substitute(Xsym[1],r1=>0.10)
1876.3029881862406

julia> simplify(Xsym[1])
0

```

This looks like a bug to me because the substitute clearly indicates Xsym[1] is nonzero while simplify simplifies it to zero. The answer 1876.3… is correct. Is it possible I’m just using the simplify function incorrectly. What is simplify supposed to do?

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [February 7, 2026, 8:51am UTC](https://discourse.julialang.org/t/i-think-a-bug-in-symbolics-package-but-not-sure/135521/2 "2026-02-07T08:51:43Z")

</div>

I’m pretty sure something has gone wrong with `simplify`. I simplified by hand to the following expression assigned `y`, and not only is simplification to 0 more obviously unlikely, `simplify` affects it differently.

```julia-auto
julia> y = ((8.333333333333333e-5 - 0.25 * 5e-5)*r1 - 0.25 * 2.0833e-5)/(8.333333333333333e-5 * 0.0002 * r1 -(2.0833333333333333e-5 + 5e-5 * r1)^2)
(-5.20825e-6 + 7.083333333333332e-5r1) / (1.6666666666666667e-8r1 - ((2.0833333333333333e-5 + 5.0e-5r1)^2))

julia> simplify(y)
1 / (0.00020328723875432528 - 3.529411764705883e-5r1)

```

To justify `y` being “equal” to `Xsym[1]`, I substituted some values for `r1` for comparison. With the exception of the `Num(0)/Num(0) === Num(1)` issue of `Xsym[1]`, the values of `y` are close enough that the difference is probably caused by floating point precision and my manual entry of floating point literals for `y`. `simplify(y)` however is really off.

```julia-auto
julia> substitute.([Xsym[1] y simplify(y)], [r1=>x for x in 0.0:0.1:1.0])
11×3 Matrix{Num}:
       1 11999.8 4919.15
  1876.3 1876.39 5006.06
 3759.84 3759.87 5096.1
 4316.95 4316.97 5189.44
 4625.64 4625.66 5286.26
  4846.8 4846.81 5386.76
 5028.56 5028.57 5491.16
 5190.48 5190.49 5599.69
 5342.08 5342.09 5712.59
 5488.64 5488.65 5830.14
 5633.38 5633.39 5952.62

```

---

<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 7, 2026, 9:55am UTC](https://discourse.julialang.org/t/i-think-a-bug-in-symbolics-package-but-not-sure/135521/3 "2026-02-07T09:55:29Z")

</div>

Open an issue please.
