Ask Your Question
2

Checking if expressions are equivalent, using certain equations

asked 2021-10-24 02:35:45 +0200

fT3g0 gravatar image

Let's say I have a bunch of formulas, and want to check if 2 expressions are the same, using those formulas:

Example:

F=m*a
W=F*s
m=rho*V

Now I would want to use something like full_simplify() on an expression like W-rho*V*a*s, to check that W and rho*V*a*s are indeed equivalent. I would like to be able to tell Sage which equations are allowed to be used for this simplification process

edit retag flag offensive close merge delete

Comments

1

So polynomial equations/formulas?

rburing gravatar imagerburing ( 2021-10-24 18:43:32 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-10-24 19:11:20 +0200

cav_rt gravatar image

You can define your expressions as proper equations and use .subs()

var('rho V s a F m W')
eq_F = F == m*a 
eq_W = W == F*s
eq_m = m == rho*V
eq = W-rho*V*a*s

Thus

eq.subs(eq_W).subs(eq_F).subs(eq_m)

returns 0.

edit flag offensive delete link more

Comments

Thank you! One more question: I have to do the substitutions manually here. If it gets more complicated, I would like to do something like: apply any of the following equations (so try out different orders,...) and check if it is true.

fT3g0 gravatar imagefT3g0 ( 2021-10-24 21:20:51 +0200 )edit

I don't know if there is something like this implemented in sage, but you can create a list of equations and try every order. The following seems a little odd but it works

equations = [eq_F, eq_W, eq_m]
ordered_equations = Arrangements(equations, len(equations)).list()
expressions = [eq.subs(k[0]).subs(k[1]).subs(k[2]).full_simplify() for k in ordered_equations]

You can check if any of the expressions is equals to zero by

0 in expressions

which in this case returns True.

cav_rt gravatar imagecav_rt ( 2021-10-25 07:22:56 +0200 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2021-10-24 02:33:02 +0200

Seen: 70 times

Last updated: Oct 24 '21