# Solving a set of equations using Symbolics.jl

**URL:** <https://discourse.julialang.org/t/solving-a-set-of-equations-using-symbolics-jl/113388>\
**Category:** General Usage\
**Created:** [April 23, 2024, 12:03pm UTC](https://discourse.julialang.org/t/solving-a-set-of-equations-using-symbolics-jl/113388 "2024-04-23T12:03:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skvibimigger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skvibimigger/32/206989_2.png) [@skvibimigger](https://discourse.julialang.org/u/skvibimigger)\
**Post date:** [April 23, 2024, 12:03pm UTC](https://discourse.julialang.org/t/solving-a-set-of-equations-using-symbolics-jl/113388/1 "2024-04-23T12:03:19Z")

</div>

Hello,  
How can I solve a system of equations to obtain the following coefficients a1, a2, a3 and a4 using the Symbolics.jl package.  
I know that it is possible using the SymPy package, but I am interesting in solving it using Symbolics.jl

I have made the following example:

> julia\> eq1  
> 4-element Vector{Num}:  
> a1 == 1  
> a2 == 0  
> (a1 + L_a2 + a3_(L^2) + a4\*(L^3)) == 0  
> (a2 + 2L_a3 + 3a4_(L^2)) == 0

I would like to solve the above system to obtain the expression for a1, a2, a3 and a4.

I know that the solution should be this:

> a1 =\> 1  
> a2 =\> 0  
> a3 =\> -3/L^2  
> a4 =\> 2/L^3

Is it possible to solve the system of equations so the coefficients are returned as a vector?

I hope that this post is okay!

---

<div class="post-metadata">

**Author:** ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)\
**Post date:** [April 23, 2024, 2:17pm UTC](https://discourse.julialang.org/t/solving-a-set-of-equations-using-symbolics-jl/113388/2 "2024-04-23T14:17:13Z")

</div>

```julia
using Symbolics

@variables a1 a2 a3 a4 L 

eqs = [a1 ~ 1,
a2 ~ 0,
(a1 + L*a2 + a3*(L^2) + a4*(L^3)) ~ 0,
(a2 + 2L*a3 + 3a4*(L^2)) ~ 0]

Symbolics.solve_for(eqs,[a1,a2,a3,a4]) .|> simplify

```
