user342552
user342552

Reputation:

solve expression for an equation

I'd like to solve the following expression:

enter image description here

for the following equation:

equation

How? Is there a function for that. This was just an example.

Thanks!!

Upvotes: 1

Views: 1144

Answers (2)

David Z
David Z

Reputation: 131780

As pointed out in the comments, you can't solve an expression. But I'm guessing that what you meant to ask was how you can find the value of an expression (a+b) subject to a constraining equation (a^3 + 3 a^2 b + 3 a b^2 + b^3 == c). In general, that's not possible - that is, for an arbitrary expression subject to an arbitrary constraint, there's no guarantee that the expression will have the same value at all the points satisfied by the constraint.

What you can do sometimes is this: introduce a new variable to represent the value of your expression, solve the resulting equation for one of the original variables (perhaps manually), then substitute it into the condition. For example, in this case:

  1. Let x represent the value of a + b
  2. Solve the equation a + b == x for either a or b, giving a = x - b or b = x - a
  3. Substitute either of these into the condition,

    a^3 + 3 a^2 b + 3 a b^2 + b^3 == c /. a -> x-b // FullSimplify
    

If your expression (a + b) has a value that is constant over the solution set of the condition, and if Mathematica is able to simplify it, then you'll get a result that is independent of any of the variables in the expression (a and b). In this example you get the result c == x^3, so that is the case.

Upvotes: 4

Mr.Wizard
Mr.Wizard

Reputation: 24336

It is not clear to me what you what, but I am going to take a guess and hope this helps.

expr = a + b;
eq = a^3 + 3 a^2 b + 3 a b^2 + b^3 == c;

PolynomialReduce[Subtract @@ eq, expr];

expr == FullSimplify[ -%[[2]] / %[[1, 1]] ]

Output:

a + b == c/(a + b)^2

This relies on PolynomialReduce and therefore only works with polynomial equations.

Upvotes: 3

Related Questions