fiedl
fiedl

Reputation: 6147

SymPy: Solve several equations and display result in terms of specific variables

How can I tell sympy.solve in which variables to express the solution?

For example, I would like

from sympy import *
a, b, c = symbols("a b c")
solve([
    Eq(a, b),
    Eq(b, c)
], a)
# => {a: b}

to return {a: c} rather than {a: b}, i.e. to express the solution in terms of [c], but to eliminate [b] from the solution.

Upvotes: 0

Views: 317

Answers (1)

smichr
smichr

Reputation: 19135

This is an unimplemented feature that has been described here

If you use the two functions defined there you will be able to do this:

a, b, c = symbols("a b c")
focus([
    Eq(a, b),
    Eq(b, c)
], a, b)
# => {a: c, b: c}

Upvotes: 1

Related Questions