0
$\begingroup$

Sometimes Reduce produces output where multiple variables are all assigned to each-other for example:

a == b && a == d

How can I assign this correctly to a new expression? For example

a*b - a*d /. ToRules[a == b && a == d]
(*b^2 - b d*)

Should be 0

A Longer example

Simplify[{a*b - a*d, a*b*d, r*s*w + b*s}, Assumptions -> {w == 0 & a == b && a == d}]
(*{(b - d) d, a b d, s (b + r w)}*)
$\endgroup$
5
  • 5
    $\begingroup$ Could you use Simplify[a b - a d, Assumptions -> a == b && a == d]? ​ $\endgroup$ Commented Dec 9, 2021 at 3:13
  • $\begingroup$ This works. It is much slower on longer equations vs. replacing $\endgroup$ Commented Dec 9, 2021 at 17:56
  • 2
    $\begingroup$ It looks like you want to ReplaceAll $b$ and $d$ with $a$, like this a*b - a*d /. (Reverse /@ ToRules[a == b && a == d]). $\endgroup$ Commented Dec 9, 2021 at 18:44
  • $\begingroup$ Simplify with assumptions doesn't work on this longer example: Simplify[{a*b - a*d, a*b*d, r*s*w + b*s}, Assumptions -> {w == 0 & a == b && a == d}] Outputs: (*{(b - d) d, a b d, s (b + r w)}*) Additionally If I have a list of equations, how can I ensure that when simplifying with assumptions each equation gets put in terms of the same variables? $\endgroup$ Commented Dec 11, 2021 at 0:59
  • 1
    $\begingroup$ a typo in the second example: w == 0 & should be w == 0 && $\endgroup$ Commented Jan 10, 2022 at 13:36

2 Answers 2

1
$\begingroup$
Reduce[y == a*b - a*d && a == b && a == d, y]

b == d && a == d && y == 0

ToRules[%] // KeyTake[y]

<|y -> 0|>

$\endgroup$
0
$\begingroup$

One possible way. In the second example, ommit this variable in Solve, which should remain finally.

asum1 = a == b && a == d;

sol1 = First@Solve[asum1]
a*b - a*d /. sol1
(*   0   *)

asum2 = w == 0 && a == b && a == d;

sol11 = Solve[asum2]
{a*b - a*d, a*b*d, r*s*w + b*s} /. sol11
(*   {{0, d^3, d s}}   *)

sol12 = Solve[asum2, {b, d, w}]
{a*b - a*d, a*b*d, r*s*w + b*s} /. sol12
(*   {{0, a^3, a s}}   *)

sol13 = Solve[asum2, {a, b, w}]
{a*b - a*d, a*b*d, r*s*w + b*s} /. sol13
(*   {{0, d^3, d s}}   *)

sol14 = Solve[asum2, {a, d, w}]
{a*b - a*d, a*b*d, r*s*w + b*s} /. sol14
(*   {{0, b^3, b s}}   *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.