Ask Your Question
0

Defining a relationship between symbolic variables

asked 2019-03-03 06:04:25 +0100

anonymous user

Anonymous

How can I define a+b+c=1 in Sage after doing var('a','b','c')? How would I make sage remember this equation so that it substitutes that value when calculating (a+b+c)².expand() for example?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-03-04 01:27:52 +0100

Juanjo gravatar image

You can save the equation in a variable and apply it through the .subs method. Try, for example, the following code:

var("a,b,c")
eq = a+b+c==1
print (a^2 + 2*a*b + b^2 + 2*a*c + 2*b*c + c^2).factor().subs(eq)
print (1/a + 1/b + c/(a*b)).simplify_rational().subs(eq)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-03-03 06:04:25 +0100

Seen: 337 times

Last updated: Mar 04 '19