# How to extract the free term of a polynomial with symbolic coefficients?

**URL:** <https://discourse.julialang.org/t/how-to-extract-the-free-term-of-a-polynomial-with-symbolic-coefficients/132326>\
**Category:** Modelling & Simulations\
**Tags:** symbolics\
**Created:** [September 12, 2025, 7:56pm UTC](https://discourse.julialang.org/t/how-to-extract-the-free-term-of-a-polynomial-with-symbolic-coefficients/132326 "2025-09-12T19:56:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [September 12, 2025, 7:56pm UTC](https://discourse.julialang.org/t/how-to-extract-the-free-term-of-a-polynomial-with-symbolic-coefficients/132326/1 "2025-09-12T19:56:53Z")

</div>

Let’s say, I use Symbolics.jl to define a polynomial in `λ` with symbolic coefficients.

```julia-auto
using Symbolics
@variables λ p q

f = λ^3 + p*λ + q

```

**How do I get the free term of the polynomial with respect to `λ`?**  
I can use `Symbolics.coeff(f, λ^3)` and `Symbolics.coeff(f, λ)` to extract the coefficients of the first two terms, but `Symbolics.coeff(f, λ^0)` just returns `0`, although I want to get `q`.

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [September 12, 2025, 8:43pm UTC](https://discourse.julialang.org/t/how-to-extract-the-free-term-of-a-polynomial-with-symbolic-coefficients/132326/2 "2025-09-12T20:43:37Z")

</div>

Here is what I got:

```julia-auto
julia> sum(filter(t->Symbolics.degree(t,λ)==0,terms(f)))
q

```

Caveat: Not a Symbolics user.

---

<div class="post-metadata">

**Author:** ![jo-ap](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jo-ap/32/44449_2.png) [@jo-ap](https://discourse.julialang.org/u/jo-ap)\
**Post date:** [October 9, 2025, 7:37am UTC](https://discourse.julialang.org/t/how-to-extract-the-free-term-of-a-polynomial-with-symbolic-coefficients/132326/3 "2025-10-09T07:37:18Z")

</div>

A bit late, but you could simply use

```julia-auto
julia> substitute(f, λ => 0)
q

```

Side note: If you want to do more involved stuff with polynomials, maybe have a look at [Oscar.jl](https://docs.oscar-system.org/stable/).
