Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
0

Defining a relationship between symbolic variables

asked 6 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 6 years ago

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)
Preview: (hide)
link

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: 6 years ago

Seen: 358 times

Last updated: Mar 04 '19