5

Suppose that I have two linear functions

f[x_] := f0 + f1 x
g[x_] := g0 + g1 x

and a (possibly rather complicated) set of conditional expressions, obtained through Reduce. For example, we might have something like this:

conditions = (f0 == f1 && g0 == 0) || (f0 == g1 && g0 == f1)

What I would like to do is write something like

{f[x],g[x]} /. conditions

and receive as output the set of pairs of $f$ and $g$ adhering to that formula. In this case we'd have

{{a + ax, bx}, {a + bx, b + ax}}

(or maybe {{f0 + f0x, g1x}, {f0 + f1x, f1 + f0x}} to stick with original variable names).

How can I do this?

Alexander Gruber
  • 1,237
  • 9
  • 18

2 Answers2

4

First convert your conditions to a list of Rules

myrules = Apply[List, conditions /. {Equal -> Rule}, {0, 1}]

which gives

enter image description here

Then Apply those Rules to your List using a pure function and Map (/@)

ReplaceAll[{f[x], g[x]}, #] & /@ myrules

which produces

enter image description here

TransferOrbit
  • 3,547
  • 13
  • 26
2
Assuming[#, Simplify[{f[x], g[x]}]] & /@ List @@ conditions
{{f1 (1 + x), g1 x}, {g1 + g0 x, g0 + g1 x}}

Which, technically but with switched constants, is what is desired.

Kuba
  • 136,707
  • 13
  • 279
  • 740