Skip to content

Appreciate any help for solving my equations system #25780

Answered by oscarbenjamin
brucelit asked this question in Q&A
Discussion options

You must be logged in to vote

This is just a system of 5 linear equations for 5 unknowns. You can use solve to solve the equations and then extract the part x1 that you want:

In [9]: x1, x2, x3, x4, x5 = symbols('x1:6')

In [10]: r1, r2, r3, r4, r5 = symbols('rho1:6')

In [11]: eqs = [
    ...:     Eq(x5, 1),
    ...:     Eq(x4, x3),
    ...:     Eq(x3, r2*x2 + r4*x4),
    ...:     Eq(x2, r3*x3 + r5*x5),
    ...:     Eq(x1, r1*x2),
    ...: ]

In [12]: sols = solve(eqs, [x1, x2, x3, x4, x5], dict=True)

In [14]: sols
Out[14]: 
⎡⎧    ρ₁⋅ρ₄⋅ρ- ρ₁⋅ρρ₄⋅ρ- ρ-ρ₂⋅ρ-ρ₂⋅ρ₅            ⎫⎤
⎢⎨x₁: ────────────────, x₂: ──────────────, x₃: ──────────────, x₄: ──────────────, x₅: 1⎬⎥
⎣⎩     ρ₂⋅ρ

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@brucelit
Comment options

Comment options

You must be logged in to vote
1 reply
@brucelit
Comment options

Answer selected by brucelit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants