from symbolicmath import core


def solve_single_equality(equality, variable):
    expression = equality.replace("==","-(") + ")"
    c = eval(expression, {variable: 1j})
    return {variable: -c.real/c.imag}


def solve(system):
    variable = system._generator.gi_code.co_varnames[1:][0]
    return solve_single_equality(system._expression, variable)


def extract_coefficients(system):
    print(system._expression)
    # equalities = system._expression.split('|')
    # equality 

@@ -23,16 +23,118 @@
 rt core%0A
+import symbolicmath as sm%0A%0A%0Adef to_expression(equality):%0A    return equality.replace(%22==%22,%22-(%22) + %22)%22%0A
 %0A%0Adef so
@@ -195,41 +195,31 @@
 n = 
-equality.replace(%22==%22,%22-(%22) + %22)%22
+to_expression(equality)
 %0A   
@@ -440,16 +440,173 @@
 able)%0A%0A%0A
+def extract_independent_term(expression, varnames):%0A    for var in varnames:%0A        expression = expression.replace(var, '0')%0A    return eval(expression)%0A%0A%0A
 def extr
@@ -639,14 +639,21 @@
     
-print(
+equalities = 
 syst
@@ -670,71 +670,1071 @@
 sion
-)%0A    # equalities = system._expression.split('%7C')%0A    # equ
+.split('%7C')%0A    expression_list = %5Bto_expression(equality) for equality in equalities%5D%0A    varnames = system._generator.gi_code.co_varnames%5B1:%5D # variabe name list%0A%0A    # The below code make a identity matrix%0A    N = len(varnames)%0A    identity_matrix = %5C%0A        %5B%5B'1' if i == j else '0' for i in range(N)%5D for j in range(N)%5D%0A%0A    indepentent_terms = %5B%0A        extract_independent_term(e, varnames) for e in expression_list%5D%0A%0A    coeff_column_expr = %5B%5D%0A    for expression, independent_term in zip(expression_list, indepentent_terms):%0A        coeff_row_expr = %5B%5D%0A        for row in identity_matrix:%0A            coeff_expr = expression%0A            for value, name in zip(row, varnames):%0A                coeff_expr = coeff_expr.replace(name, value)%0A            coeff_row_expr.append(coeff_expr + '-%25s' %25 independent_term)%0A        coeff_row_expr.append('-%25s' %25 independent_term)%0A        coeff_column_expr.append(coeff_row_expr)%0A%0A    coefficient_matrix = %5B%0A        %5Bev
 al
+(
 it
-y %0A
+em) for item in row%5D%0A        for row in coeff_column_expr%5D%0A    return sm.Object(coefficient_matrix)

add to_expression helper function and the implementation of extract_coefficients() is done