# Symbolic algebra elaboration?

**URL:** https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414
**Category:** General Usage
**Tags:** packages
**Created:** [February 10, 2020, 2:25pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414 "2020-02-10T14:25:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Darione](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/darione/32/12160_2.png) [@Darione](https://discourse.julialang.org/u/Darione)
#### Post date: [February 10, 2020, 2:25pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/1 "2020-02-10T14:25:32Z")

</div>

Hi all …

My daughter is in the first scientific high school, here in Italy. Yesterday, we were to see the expansion of (x+y)^7 with tartaglia triangle method … very nice … but I’d like to use Julia to do other symbolic algebric expansions …

So, what package i could use in Julia?

Thank you very much for help.

---

<div class="post-metadata">

### Author: ![phelipe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phelipe/32/14643_2.png) [@phelipe](https://discourse.julialang.org/u/phelipe)
#### Post date: [February 10, 2020, 2:43pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/2 "2020-02-10T14:43:36Z")

</div>

You can use [SymEngine.jl](https://github.com/symengine/SymEngine.jl/)

```julia
julia> using SymEngine

julia> @vars x,y
(x, y)

julia> expand((x+y)^7 )
7*x*y^6 + 21*x^2*y^5 + 35*x^3*y^4 + 35*x^4*y^3 + 21*x^5*y^2 + 7*x^6*y + x^7 + y^7

```

---

<div class="post-metadata">

### Author: ![Darione](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/darione/32/12160_2.png) [@Darione](https://discourse.julialang.org/u/Darione)
#### Post date: [February 10, 2020, 3:07pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/3 "2020-02-10T15:07:25Z")

</div>

Thank you very much, it works perfectly …  
but i have another question. How can i print the result, this one …

```julia
julia> expand( ( a * b^2 + a^2 * b) ^ 7 )
a^7*b^14 + 7*a^8*b^13 + 21*a^9*b^12 + 35*a^10*b^11 + 35*a^11*b^10 + 21*a^12*b^9 + 7*a^13*b^8 + a^14*b^7

```

… in a better graphically pretty print … as if the professor had written it on the blackboard ?

Many thanks.

---

<div class="post-metadata">

### Author: ![dawbarton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dawbarton/32/215461_2.png) [@dawbarton](https://discourse.julialang.org/u/dawbarton)
#### Post date: [February 10, 2020, 4:18pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/4 "2020-02-10T16:18:11Z")

</div>

If you are using Jupyter you can try [Latexify](https://github.com/korsbo/Latexify.jl):

```julia
julia> using Latexify

julia> latexify(expand( ( a * b^2 + a^2 * b) ^ 7 ))
L"$a^{7} \cdot b^{14} + 7 \cdot a^{8} \cdot b^{13} + 21 \cdot a^{9} \cdot b^{12} + 35 \cdot a^{10} \cdot b^{11} + 35 \cdot a^{11} \cdot b^{10} + 21 \cdot a^{12} \cdot b^{9} + 7 \cdot a^{13} \cdot b^{8} + a^{14} \cdot b^{7}$"

```

(Jupyter should render it nicely, at least according to the docs!)

---

<div class="post-metadata">

### Author: ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)
#### Post date: [February 10, 2020, 4:57pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/5 "2020-02-10T16:57:16Z")

</div>

Another package you can use is my [Reduce.jl](https://github.com/chakravala/Reduce.jl) package for this:

```nohighlight
julia> using Reduce; expand(:((x+y)^7))
:(x ^ 7 + 7 * x ^ 6 * y + 21 * x ^ 5 * y ^ 2 + 35 * x ^ 4 * y ^ 3 + 35 * x ^ 3 * y ^ 4 + 21 * x ^ 2 * y ^ 5 + 7 * x * y ^ 6 + y ^ 7)

```

It allows you to symbolically manipulate Julia `Expr` objects directly.

---

<div class="post-metadata">

### Author: ![jlapeyre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlapeyre/32/4514_2.png) [@jlapeyre](https://discourse.julialang.org/u/jlapeyre)
#### Post date: [February 10, 2020, 8:53pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/6 "2020-02-10T20:53:39Z")

</div>

[Symata.jl](https://github.com/jlapeyre/Symata.jl) will do this as well

 ![symata](https://global.discourse-cdn.com/julialang/original/3X/9/d/9dccf22645896f4e32efbc9bc88dcb2a11ee0c2a.png)

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [February 10, 2020, 9:08pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/7 "2020-02-10T21:08:47Z")

</div>

I had never been able to find the documentation for SymEngine… is it the same as SymPy at user level?

---

<div class="post-metadata">

### Author: ![phelipe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phelipe/32/14643_2.png) [@phelipe](https://discourse.julialang.org/u/phelipe)
#### Post date: [February 12, 2020, 3:49pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/8 "2020-02-12T15:49:07Z")

</div>

The documentation is [README.md](https://github.com/symengine/SymEngine.jl/blob/master/README.md)

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [February 12, 2020, 4:04pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/9 "2020-02-12T16:04:28Z")

</div>

Well, it seems way, way shorter than the [SymPy.jl one](https://github.com/JuliaPy/SymPy.jl/blob/master/examples/tutorial.md) (not to speak of the original [SymPy one](https://docs.sympy.org/latest/index.html))… for example there is no limits nor solve described, no way to specify the domain of the variables… is it because at the moment the functionality of SymEngine is constrained to the functions in the readme, or because a more exhaustive documentation has not yet been wrote (or maybe there is no need if it is the same as SymPy.jl)

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [February 12, 2020, 4:11pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/10 "2020-02-12T16:11:41Z")

</div>

Sorry, I think I can answer myself looking at the code, I don’t see indeed much more than what reported in the README… my next question is then if the common features of a CAS are still missing at the level of the SymEngine library, or “simply” need to be implemented in the SymEngine.jl wrapper…

---

<div class="post-metadata">

### Author: ![phelipe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phelipe/32/14643_2.png) [@phelipe](https://discourse.julialang.org/u/phelipe)
#### Post date: [February 12, 2020, 4:17pm UTC](https://discourse.julialang.org/t/symbolic-algebra-elaboration/34414/11 "2020-02-12T16:17:05Z")

</div>

For me, all I need is explained in the README.md, I don’t know if all functions of SymEngine (C++) were implemented 😕 .
