How to simplify a symbolic equation, but still keep the denominator

2 visualizaciones (últimos 30 días)
Hi,
Here is a simplified equation for my problem: I would like to cancle "b" only at both side .(Euqation is in the code, "eqn1")
syms x y a b
eqn1 = b*(x/a + 1) == b*y/a; % This is the equation, I would like to cancel "b" at both side, and still keep "a" as denominator.
S=simplify(eqn1)
Results are:
S =
y == a + x | b == 0 % I want to get "(x/a+1)==y/a" instead.
Question: How can I enforce a rule to "simplify" command, so I can keep "a" as denominator, namely, I want to get : "(x/a+1)==y/a" ?

Respuesta aceptada

David Goodmanson
David Goodmanson el 30 de Mayo de 2020
Hi LZ
syms x y a b
eqn1 = b*(x/a + 1) == b*y/a; % This is the equation, I would like to cancel "b" at both side, and still keep "a" as denominator.
lhs = factor(b*(x/a + 1))
rhs = factor(b*y/a)
lhs(find(lhs==b)) = [];
rhs(find(rhs==b)) = [];
eqn2 = prod(lhs) == prod(rhs)
  2 comentarios
Lu Zhao
Lu Zhao el 31 de Mayo de 2020
Thank you so much. It works and I learned a lot. I really appreciate your help.
David Goodmanson
David Goodmanson el 1 de Jun. de 2020
You're welcome, and I learned something as well. I had no idea if the product function would work, but it did.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by