Solving a set of equations using Symbolics.jl

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 + La2 + a3(L^2) + a4*(L^3)) == 0
(a2 + 2La3 + 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!

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
1 Like