# How to Use SymPy to calculate Definite Integrals with Symbols of Constant?

**URL:** <https://discourse.julialang.org/t/how-to-use-sympy-to-calculate-definite-integrals-with-symbols-of-constant/91673>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [December 15, 2022, 4:54am UTC](https://discourse.julialang.org/t/how-to-use-sympy-to-calculate-definite-integrals-with-symbols-of-constant/91673 "2022-12-15T04:54:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [December 15, 2022, 4:54am UTC](https://discourse.julialang.org/t/how-to-use-sympy-to-calculate-definite-integrals-with-symbols-of-constant/91673/1 "2022-12-15T04:54:41Z")

</div>

Hi all,

I am using SymPy to try calculate this

\int\_{A}^{B} ax+b \ dx

the function `f(x) = ax+b` where `a` and `b` are constant in symbolics.  
The integral is definite but, the interval of the integral is in symbolics too `A` and `B`.

I use this code, try them:

```julia
using SymPy

x, y, z = symbols("x y z")

A, B = symbols("A B")

integrate(ax+b, (x, A, B))

```

but it gets error:  
**LoadError: UndefVarError: ax not defined**

---

<div class="post-metadata">

**Author:** ![skleinbo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skleinbo/32/36080_2.png) [@skleinbo](https://discourse.julialang.org/u/skleinbo)\
**Post date:** [December 15, 2022, 6:45am UTC](https://discourse.julialang.org/t/how-to-use-sympy-to-calculate-definite-integrals-with-symbols-of-constant/91673/2 "2022-12-15T06:45:06Z")

</div>

1. You haven’t declared `a,b` as symbols
2. You need to write `a*x`. Leaving out the multiplication operator works only with numbers. Anything else would be ambiguous.

```julia
julia> integrate(a*x+b, (x, A, B))
   2 2        
  A ⋅a B ⋅a      
- ──── - A⋅b + ──── + B⋅b
   2 2        

```

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [December 15, 2022, 6:58am UTC](https://discourse.julialang.org/t/how-to-use-sympy-to-calculate-definite-integrals-with-symbols-of-constant/91673/3 "2022-12-15T06:58:21Z")

</div>

Alright it works now, but I have another further question for new topic about this.
