1
$\begingroup$

If

a = x + y

b = x - y

u = a + b

v = a

This gives me for u/v the expression (2 x)/(x + y) But I want to get 1+b/a. How to do that when a and b are very long expressions?

$\endgroup$
7
  • $\begingroup$ Why does it matter if a and b are long expressions if you just want 1+b/a? $\endgroup$
    – lericr
    Commented Dec 21, 2023 at 6:19
  • $\begingroup$ Or are you saying you want 1 + (x-y)/(x+y)? $\endgroup$
    – lericr
    Commented Dec 21, 2023 at 6:22
  • $\begingroup$ 1+b/a is ok, I just wanted to avoid long Replace answers. I was looking for some kind of short switch (from x,y to a,b), because I have many variables to deal with. I was looking sore something like Eliminate, but that works only for equations. $\endgroup$
    – user57467
    Commented Dec 21, 2023 at 7:21
  • 3
    $\begingroup$ Does this answer your question? Can I simplify an expression into form which uses my own definitions? $\endgroup$
    – MarcoB
    Commented Dec 21, 2023 at 12:31
  • $\begingroup$ I found that the following works eq1 = a == x + y; eq2 = b == x - y; eq3 = u == a + b; eq4 = v == a; eq5 = c == u/v; sol = Eliminate[{eq1, eq2, eq3, eq4, eq5}, {x, y, u, v}]; Solve[sol, c] Which looks very clumsy. Any better ideas? $\endgroup$
    – user57467
    Commented Dec 21, 2023 at 13:44

1 Answer 1

3
$\begingroup$
u/v /. u -> a + b /. v -> a // Apart
$\endgroup$

Your Answer

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

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