3
$\begingroup$

Is there anyway to treat two variable, that are a result of expansion, as one?

To use Solve[] I can do

Clear[x, z, y, eq]
eq = Expand[x (z + y)] /. x z -> xz
Solve[eq == 0, xz]

Is there anyway to solve directly like

Clear[x, z, y, eq]
eq = Expand[x (z + y)]
Solve[eq == 0, x z]
$\endgroup$
  • $\begingroup$ What about /. x -> z? Notice that x z is a multiplication. $\endgroup$ – Kuba Jul 7 '17 at 8:28
  • $\begingroup$ @Kuba not sure, what you're getting at. Perhaps one could streamline OP's workaround somewhat like Solve[equations /. x -> xz/z, xz] /. xz -> x z taking out the not always reliable Expand $\endgroup$ – LLlAMnYP Jul 7 '17 at 8:31
  • $\begingroup$ @LLlAMnYP I understood that OP does not want to define a relation but to consider x and z the same variable, therefore I suggested that. Then one can solve for z as there is only z for z or x. $\endgroup$ – Kuba Jul 7 '17 at 8:35
  • 1
    $\begingroup$ see: mathematica.stackexchange.com/a/3825/5478 $\endgroup$ – Kuba Jul 7 '17 at 8:48
  • 1
    $\begingroup$ well at least in this case Solve[eq == 0, HoldPattern@Times[x, z]] works, but I don't know how stable of a solution this would be in more complex cases $\endgroup$ – glS Jul 7 '17 at 13:01
2
$\begingroup$

How about introducing the extra variable as a new equation and then telling Solve to solve for 2 variables? Or use Reduce instead?

Clear[x, z, y, eq];
eq = Expand[x (z + y)];
Solve[{eq == 0, xz == x z}, {xz, y}]
Reduce[{eq == 0, xz == x z}, {xz}]
$\endgroup$
0
$\begingroup$

Perhaps:

eq = Expand[x (z+y)];
Reduce[eq == 0 && v == x z, v]

(x == 0 && v == 0) || (y == -z && v == x z)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.