Symbolically solving a system of equations... "Matrix is not square" error

I’m trying to find Requ(ivalent) for a circuit in terms of the 5 resistors in the circuit.

I’ve written out the equations for the circuit as follows:

using Symbolics
@variables i1 i2 i3 i4 i5 iIn;
equ1= iIn ~ i1 + i4
equ2 = iIn ~ i3 + i5
equ3 = i3 ~ i2 + i4
equ4 = i1 ~ i2 + i5
equ5 = i1 - i5 ~ i3 - i4
@variables R1 R2 R3 R4 R5 Requ
@variables Vin
equ6 = Vin ~ R1*i1 + R2*i2 + R3 * i3
equ7 = Vin ~ i4*R4 + i3*R3
equ8 = Vin ~ R1*i1 + R5 * i5
equ9 = Requ ~ Vin/iIn
equations = [equ1, equ2, equ3, equ4, equ5, equ6, equ7, equ8, equ9]
solution = Symbolics.solve_for(equations, Requ )

I get a “DimensionMismatch: matrix is not square: dimensions are (9, 1)” error.

What am I doing wrong ?

What’s the full error message? Likely this needs using Nemo and it will have said that?

I added using Nemo. No change in the output.

Stack trace

Here is what happened, the most recent locations are first:

    checksquare @ LinearAlgebra.jl:302
    UpperTriangular @ triangular.jl:22
    UpperTriangular @ triangular.jl:28
    ldiv!(A::LinearAlgebra.LU{Symbolics.Num, Matrix{Symbolics.Num}, Vector{Int64}}, B::Vector{Symbolics.Num}) @ lu.jl:503
    ldiv(F::LinearAlgebra.LU{Symbolics.Num, Matrix{Symbolics.Num}, Vector{Int64}}, B::Vector{Symbolics.Num}) @ LinearAlgebra.jl:674
    \ @ LinearAlgebra.jl:649
    _solve(A::Matrix{Symbolics.Num}, b::Vector{Symbolics.Num}, do_simplify::Bool) @ linear_algebra.jl:127
    symbolic_linear_solve(eq::Vector{Symbolics.Equation}, var::Vector{Symbolics.Num}; simplify::Bool, check::Bool) @ linear_algebra.jl:109
    symbolic_linear_solve @ linear_algebra.jl:101
    symbolic_linear_solve(eq::Vector{Symbolics.Equation}, var::Symbolics.Num; x::@Kwargs{simplify::Bool, check::Bool}) @ linear_algebra.jl:121
    symbolic_linear_solve @ linear_algebra.jl:121
    #solve_for#389 @ linear_algebra.jl:72
    solve_for(eq::Vector{Symbolics.Equation}, var::Symbolics.Num) @ linear_algebra.jl:70
    This cell: line 1

    solution = Symbolics.solve_for(equations, Requ )

I’m wondering what it would report if I didn’t have enough equations for the number of variables.

Open an issue on the Symbolics.jl repo.

So I’ve set up the problem correctly ?

I reported it.

I believe so.