Ask Your Question
0

conditions among the variables

asked 2019-11-19 06:55:04 -0600

Suppose I am defining some variables in sagemath. How can I give conditions among the variables such that the condition is applied in the future calculations?

Thank You.

edit retag flag offensive close merge delete

Comments

1

This can be done (with some effort) in many cases, depending on the type of condition. Are the conditions linear equations, polynomial equations, trigonometric equations? An example would be great.

rburing gravatar imagerburing ( 2019-11-19 10:31:51 -0600 )edit

Yes, please give an example of the kind of problem you would like to solve. You can do things like assume(x > 0) or assume(x, 'complex') but whether or not that has any effect depends on what you're trying to do.

Iguananaut gravatar imageIguananaut ( 2019-11-20 11:25:49 -0600 )edit
1

Suppose I have variables a,b,c,d,e and I have a polynomial with these five variables.. I want to simplify the polynomial using the condition that a+b = d+e.

user789 gravatar imageuser789 ( 2019-11-26 21:22:48 -0600 )edit

@user789 if that's all, then just substitute e.g. $e=a+b-d$ into your polynomial.

rburing gravatar imagerburing ( 2019-11-27 02:13:32 -0600 )edit

i want sage to do that for me!

user789 gravatar imageuser789 ( 2019-11-27 02:58:30 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2019-11-27 05:43:59 -0600

Iguananaut gravatar image

i want sage to do that for me!

Okay then let Sage do it for you:

sage: var('a, b, c, d, e')
(a, b, c, d, e)
sage: P = a*d + b*c + d^2 + d*e
sage: P.subs(e=(a + b - d)).expand()
b*c + 2*a*d + b*d

This is exactly what you want: It simplified the expression given that a + b = d + e.

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

1 follower

Stats

Asked: 2019-11-19 06:55:04 -0600

Seen: 49 times

Last updated: Nov 27