# Computing Symbolic Integral with SymPy

**URL:** https://discourse.julialang.org/t/computing-symbolic-integral-with-sympy/95307
**Category:** General Usage
**Tags:** package
**Created:** [February 28, 2023, 5:02am UTC](https://discourse.julialang.org/t/computing-symbolic-integral-with-sympy/95307 "2023-02-28T05:02:45Z")
**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: [February 28, 2023, 5:02am UTC](https://discourse.julialang.org/t/computing-symbolic-integral-with-sympy/95307/1 "2023-02-28T05:02:45Z")

</div>

Hi all,

I just want to know why the solution in the manual for number 17 and 18 are different with the one I computed with Julia?

![Capture d’écran_2023-02-28_11-59-29](https://global.discourse-cdn.com/julialang/original/3X/9/e/9e688919b4fcde9105bd279698a02aaa60159761.png)

```julia
using SymPy
@syms x, v, z, t

v1(v) = (6v+9)/(3v^2 + 9v)
v2(z) = z/(2z^2 + 8)
v3(x) = (2*log(x))/x
v4(x) = -1/(x*log(x)^2)
v5(x) = (x^4)/(2x^5 + pi)
v6(t) = (t+1)/(2t^2 + 4t + 3)
v7(x) = (x^2)/(x-1)
v8(x) = (x^2 + x)/(2x - 1)
v9(x) = (x^4)/(x + 4)
v10(x) = (x^3 + x^2)/(x + 2)

V1 = integrate((v1(v)), (v))
V2 = integrate((v2(z)), (z))
V3 = integrate((v3(x)), (x))
V4 = integrate((v4(x)), (x))
V5 = integrate((v5(x)), (x, 0, 3))
V6 = integrate((v6(t)), (t, 0, 1))
V7 = integrate((v7(x)), (x))
V8 = integrate((v8(x)), (x))
V9 = integrate((v9(x)), (x))
V10 = integrate((v10(x)), (x))

println("Computing symbolic integral and definite integral")
println("a. ", V1)
println("b. ", V2)
println("c. ", V3)
println("d. ", V4)
print("e. ", V5)
println(" = ", V5.evalf())
print("f. ", V6)
println(" = ", V6.evalf())
println("g. ", V7)
println("h. ", V8)
println("i. ", V9)
println("j. ", V10)

```

why the integral of SymPy does not have `+ C` ?

---

<div class="post-metadata">

### Author: ![Paulo\_Jabardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulo_jabardo/32/3196_2.png) [@Paulo\_Jabardo](https://discourse.julialang.org/u/Paulo_Jabardo)
#### Post date: [February 28, 2023, 12:22pm UTC](https://discourse.julialang.org/t/computing-symbolic-integral-with-sympy/95307/2 "2023-02-28T12:22:08Z")

</div>

> [@Freya\_the\_Goddess](#):
>
> why the integral of SymPy does not have `+ C` ?

Why would it be necessary? The C just indicates the generic solution. Maxima and Axiom don’t return C.

---

<div class="post-metadata">

### Author: ![tom-plaa](https://avatars.discourse-cdn.com/v4/letter/t/d26b3c/32.png) [@tom-plaa](https://discourse.julialang.org/u/tom-plaa)
#### Post date: [February 28, 2023, 12:36pm UTC](https://discourse.julialang.org/t/computing-symbolic-integral-with-sympy/95307/3 "2023-02-28T12:36:33Z")

</div>

What @Paulo_Jabardo said, it’s a basic fact about integration that any integral is defined up to a constant. If you differentiate that constant you get zero, so you can have any C and it will still give you the integrand after differentiation. I believe some Computer Algebra Systems (Maxima is an example) would just assume the users know that and define it as C=0.  
In the real world, for some problems (in Physics, for example) the constant C actually matters because of boundary conditions, it’s common when solving PDE’s for fields through methods like assuming a function f(x,y,z) is of the form f(x,y,z) = X(x)Y(y)Z(z). In essence, you leave that C in the solution as a parameter and then define it based on your boundary conditions.
