# Symbolics: simplifying an equation whose RHS is zero

I’m using the `Symbolics` package. Suppose I’ve got an expression in several real variables, let’s call it `expr`, and I equate it with zero, e.g. `expr ~ false`. I’d like some simple automatic simplifications of that equation. For example:

1. Eliminate negation: `-subexpr ~ false``subexpr ~ false`
2. Eliminate constant coefficients: `2*subexpr ~ false``subexpr ~ false`
3. Eliminate constant exponents: `subexpr^2 ~ false``subexpr ~ false`

Is there an easy way to achieve this?

What about the following slightly more complex cases?

1. Eliminate common negation: `-x - y ~ false``x + y ~ false`
2. Eliminate common constant coefficients: `6*x + 9*y ~ false``2*x + 3*y ~ false`
3. Eliminate common constant exponents: `x^6 * y^9 ~ false``x^2 * y^3 ~ false`

Why is zero equivalent to `false`? Are you working with Boolean algebra?

There is the `simplify` function that uses some predefined rewriting rules, but I’m not sure it handles Boolean variables (I guess not). If you are just using “standard” algebra, then it might suit your needs.

If not, you might be looking for defining your own term rewriting rules
https://symbolicutils.juliasymbolics.org/rewrite/

1 Like

Already tried that, it doesn’t seem to use the RHS for simplifying the LHS:

``````julia> using Symbolics

julia> @variables x
1-element Vector{Num}:
x

julia> simplify(-x ~ 0)
-x ~ 0

julia> simplify(2x ~ 0)
2x ~ 0

julia> simplify(x^3 ~ 0)
x^3 ~ 0
``````

No, my variables are real, `false` is just a constant.

Thanks, for the link, I’ll have to check it out sometime, although now I’m already done with what I was doing.

1 Like

Ah yeah, looks like `simplify` only considers a term, not equations. Would be interesting to know if there is a way to simplify the whole equation though…

1 Like