complex substitution
Im working on a loooooooooooooong formula. I want to replace (substitute?) certain combination of variables for another simpeler combination of variables (like for example F=m*a), anywhere in the formula where this combination exists.
Case 1 (Works): I have a formula let say
sage: eq1=m*a==(b+c)*k
sage: eq2=d==a*m+f
sage: eq3=eq2.subs(eq1)/g
(doesnt work with the multiplication? just gives me the same answer as i had without the substitution)
Edit: Case 2 (solved): so it does some kind of operation on equation 2 but I want to replace the a in equation 2 for equation 1 my code:
sage: A1, A2, A3, P1, P3, u1, u2, u3, r1, r2, r3 = var('A1 A2 A3 P1 P3 u1 u2 u3 r1 r2 r3')
sage: eq7a = P1 - P3 == -(A1*r1*u1^2 + A2*r2*u2^2 - A3*r3*u3^2)/A3
sage: eq7a.subs_expr(A3*r3*u3^2 == (A2*u2*r2 + A1*r1*u1)*u3)
sage: A1, A2, A3, P1, P3, u1, u2, u3, r1, r2, r3 = var('A1 A2 A3 P1 P3 u1 u2 u3 r1 r2 r3')
sage: eq7a = P1 - P3 == -(A1*r1*u1^2 - A2*r2*u2^2 + A3*r3*u3^2)/A3
sage: eq7a.subs_expr(A3*r3*u3^2 == (A2*u2*r2 + A1*r1*u1)*u3)
The last one i want to turn the a3r3u3 into the longer one, but it just gives me back a3r3u3
When I use the .subs_expr it doesn't give me back anything
It is not clear to me which expression do you want to substitute in which. It seems to work for me, for ``eq3`` i got : ``d/g == ((b + c)*k + f)/g``. Which result did you expect ?
I expected that result, but if i try this with my own formula it gives me back (a*m+f)/g And im doing it the exact same way except that there are more variables involved. Does sage see that if something is squared or multiplied with something else it can be taken apart?
Since this example works well, how can we understand your problem. Could you please provide the exact formulas that lead to an actual problem ?
I reverted your question to the state it was before you added new questions, since those additional questions are asked in http://ask.sagemath.org/question/23967/solve-for-variable-but-variable-is-still-in-answer/