3

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]
  • What about /. x -> z? Notice that x z is a multiplication. – Kuba Jul 07 '17 at 08:28
  • @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 – LLlAMnYP Jul 07 '17 at 08:31
  • @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. – Kuba Jul 07 '17 at 08:35
  • @Kuba I should have been more clear. I was asking if there was a way to treat xz as a new variable, one that is different from both x or z. – I should change my Username Jul 07 '17 at 08:38
  • @LLIAMnYP Is there anyway that this could be done without using replacements? – I should change my Username Jul 07 '17 at 08:38
  • How about Solve[equations && var == x z, var]? – LLlAMnYP Jul 07 '17 at 08:39
  • OTOH that wouldn't work, a second equation seems to require a second variable to solve for, i.e. Solve[..., {x, var}] or such. – LLlAMnYP Jul 07 '17 at 08:44
  • @Kuba or, in other words, for a b c - d e f == 0 we have no idea what a, b, and c are, but we know that their product, a b c is equal to d e f. – LLlAMnYP Jul 07 '17 at 08:47
  • 1
    see: https://mathematica.stackexchange.com/a/3825/5478 – Kuba Jul 07 '17 at 08:48
  • @Kuba it's a nice question, but quite sure, it's a dupe, maybe not of your link, but of those therein, what do you think? – LLlAMnYP Jul 07 '17 at 08:58
  • @LLlAMnYP maybe one of those links is better but the question asks about replacing z x with var while the linked one a / b with k, I'd say it is close enough. But I don't have time to focus on details so I will leave the link for people judgement. – Kuba Jul 07 '17 at 09:03
  • why do you need to do it without using replacements? Because that seems the natural method to do this kind of things – glS Jul 07 '17 at 11:07
  • @glS I was just wondering if there was another or a shorter way to do it. I'm familiar with replacements so I am curious if the same behavior could be achieve with something I didn't know about – I should change my Username Jul 07 '17 at 11:21
  • 1
    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 – glS Jul 07 '17 at 13:01

2 Answers2

2

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}]
Sjoerd Smit
  • 23,370
  • 46
  • 75
0

Perhaps:

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

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

Carl Woll
  • 130,679
  • 6
  • 243
  • 355