The sympy.solvers.solveset.linear_eq_to_matrix is probably what you are 
needing:

```python
    >>> eqns = [c*x + z - 1 - c, y + z, x - y]
    >>> A, b = linear_eq_to_matrix(eqns, [x, y, z])
    >>> A
    Matrix([
    [c,  0, 1],
    [0,  1, 1],
    [1, -1, 0]])
    >>> b
    Matrix([
    [c + 1],
    [    0],
    [    0]])
```

On Tuesday, May 11, 2021 at 12:54:49 PM UTC-5 [email protected] wrote:

> Got adain interested in a book LINEAR ALGEBRA  with APLICATIONS, very nice 
> book, very early there are exercises to show the corresponding matrix of 
> coeffients. Trivial, if one types by reading the ckeeficients to bild the 
> riws Matrix needs. But now my question : How to generate thebmatrix by a 
> def ....
> ok lhs and rhs of an Eq is easy, using args too .  But what dimyoundo if 
> there are equations with differen numbers of say x_i. Missing unknows have 
> to create an 0 at the needed row.index. 
> I translated an equation (lhs) with srepr with regular expression , 
> replacing  Symbol ('x1) to 1 etc .
>
> Questions , how would you trans form e.g  x1 + x3 - 2*x5   To
> 1 0 1 0 -2 ?
>
>  Ok, I extract x1 x3 and x5 ==>!knowing now x2 and x4 is missing, knowing 
> the 0 at  index 1 and 3 (zero order of Python) ... 
>   
> Have to learn to give code examples here ... Pictutes ? 
> Newbie in this groep
>
> Ideas and help very much apteciated  😉 , by the way i am an 祖父 is grandpa 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b913c303-f3d6-4d97-9d8c-e249158c343fn%40googlegroups.com.

Reply via email to