Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a somewhat lengthy expression, looking like

expr = 1 + x + b + Pi + 2*a

Is there some way of generating a relationship between a and b that makes the parameters fall away? In the example above, that condition could look like a -> -b/2 or 2*a == -b, because inserting that yields the new expression

expr2 = 1 + Pi

which is independent of both a and b. Note that the relationship contains only the two variables; it leaves the terms not involving them intact (namely x), in other words: a can depend only on b in the desired solution (if there is one of course).

I tried my best using the usual suspects (Reduce, Solve, SolveAlways, ...), but couldn't come up with a solution.

Background: My expression is a physical quantity that has certain mathematical parameters left in it. Being physical, it may not depend on the choice of the leftover parameters, ergo these parameters are not independent of each other. I would like to get rid of these placeholders, and doing so will tell me something about the physics in the ansatz that lead to the whole calculation.

share|improve this question
    
In the actual problem, do you have only two parameters or more? –  Szabolcs Feb 14 '13 at 15:59
    
I currently have only two parameters. (A solution with more than that would be nice, but I don't strictly need it.) –  David Feb 14 '13 at 16:00
1  
Is any condition that gets rid of $a$ and $b$ acceptable? You could use a -> -b/2 + 1 too. It seems like in general you're looking for a relationship between $a$ and $b$, which, if satisfied, makes expr a constant (not depend on $a,b$). But it seems that Solve[expr == const, {a,b}] will do this for you no matter how you choose const. It can be 1+Pi, it can be 0 or anything else. –  Szabolcs Feb 14 '13 at 16:11
    
@Szabolcs Edited the question, should be clearer now –  David Feb 14 '13 at 23:15

2 Answers 2

I believe that

Solve[expr == const, {a,b}]

will give you such a condition for any choice of const. You can write 1+Pi in place of const to get the example condition you gave, but you can also write 0 which gives another relationship that, when substituted back, gets rid of a and b.

It seems it is just a plain Solve you need.

share|improve this answer
    
Thanks for the reply. However, this doesn't ensure a depends only on b and not on any other variables in expr, a thing I didn't write clearly enough in my question. (I edited it a little now) –  David Feb 14 '13 at 23:10
    
@David I see the edit. I think that's not possible in general, e.g. expr = 1 + a x + b. But most of the time when it is possible, I think Solve[0 == expr /. x -> const, {a,b}] should give a correct solution. It's possible to check by backsubstituting to expr. If a,b don't go away after backsubstitution and simplification, it's probably not possible. –  Szabolcs Feb 16 '13 at 0:11

Something like :

vars = {a, b};

Reduce[expr == (expr /. Thread[Rule[vars, 0]]), vars]

A bit more generally :

Simplify[expr == Total[Cases[expr, _?(Function[{x}, And @@ (FreeQ[x, #] & /@ vars)][#] &)]]]
share|improve this answer
    
Is there a way I can generalize this so that a can only depend on b and nothing else present in expr? (I edited my question to make this a bit clearer) –  David Feb 14 '13 at 23:14
    
My intention was to define all parameters you want to get rid of in vars. If you provide an example where my suggestion fails I'll try again. –  b.gatessucks Feb 15 '13 at 7:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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