# Learn to use Symbolics.jl

**URL:** <https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190>\
**Category:** General Usage\
**Tags:** question, symbolics\
**Created:** [November 3, 2024, 3:58am UTC](https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190 "2024-11-03T03:58:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pywugate](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pywugate/32/52011_2.png) [@pywugate](https://discourse.julialang.org/u/pywugate)\
**Post date:** [November 3, 2024, 3:58am UTC](https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190/1 "2024-11-03T03:58:56Z")

</div>

Hi , I want to use Symbolics.jl to solve `bo` and `b1` from 2 equations  
`b0 + b1 * x1 = y1`  
`b0 + b1 * x2 = y2`

I know in SymPy.jl it would be

```julia
using SymPy
@syms x[1:2] y[1:2] b[0:1]
eqns = [one.(x) x] * b .~ y
solve(eqns, b)

```

now i can build this

```julia
using Symbolics, Groebner, Nemo, LinearAlgebra
@variables x[1:2] y[1:2] b b0
eqs = [b0 + b * x[1] ~ y[1] 
       b0 + b * x[2] ~ y[2] ]
symbolic_solve(eqs, [b, b0])

```

Is it possible to build it with only 1 equation `eqns = [one.(x) x] * b .~ y` as in SymPy.jl ?

I tried

1. 

```julia
@variables x[1:2] y[1:2] b[0:1]
eqs = [b[0] + b[1] * x[1] ~ y[1] 
       b[0] + b[1] * x[2] ~ y[2] ]
symbolic_solve(eqs, b)

Warning: Solve can not solve this input currently

```

1. 

```julia
@variables x[1:2] y[1:2] b[0:1]
eqs = [ones(length(x)) x] * b .~ y

ERROR: DimensionMismatch: expected axes(b, 1) = Base.OneTo(2)

```

1. 

```julia
b = Symbolics.variables(:b, 0:1)
x = Symbolics.variables(:x, 1:2)
y = Symbolics.variables(:y, 1:2)

eqs = [[ones(length(x)) x] * b .~ y]
symbolic_solve(eqs, b)

ERROR: AssertionError: Invalid input

```

1. 

```julia
@variables x, y, b
p = [ones(length(x)) x] * b .~ y
f = build_function(eqs, [x, y, b], expression = Val{false}) 
symbolic_solve(f, b)

ERROR: AssertionError: Invalid input

```

How could I do it?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [November 3, 2024, 10:57am UTC](https://discourse.julialang.org/t/learn-to-use-symbolics-jl/122190/2 "2024-11-03T10:57:29Z")

</div>

If you do the same thing as SymPy it seems to work fine:

```julia
using Symbolics, Groebner, Nemo, LinearAlgebra
@variables x[1:2] y[1:2] b[1:2]
eqs = collect([one.(x) x] * b .~ y)
symbolic_solve(eqs, collect(b))

```

```julia
1-element Vector{Any}:
 Dict{Num, Any}(b[2] => (y[1] - y[2]) / (x[1] - x[2]), b[1] => (x[1]*y[2] - x[2]*y[1]) / (x[1] - x[2]))

```
