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/
That's not entirely true since the edit here was about another substitution, the other one was about solving for a variable which gave me an answer where the variable is not isolated.
Ok, it was not clear to me. Post-editing a question once it is answered creates a mess. Indeed, some other people could benefit from your question but may get lost in reading answers not connected to the newly edited question. If another case of the same question appears, perhaps could you add it after the current one, starting by an *EDIT* statement, so that it is clear that it is a new case, this will help readers to understand what is the current status of the question.
Or perhaps write "case 1" (the first one that actually worked), "case 2" (which i answered), and then "case 3" (your new substitution problem), with an *EDIT* between each stage. The thing is that your question is of interest to any one falling into such problem in the future and come into this page after searching on the web, ask.sagemath.org is not only about answering questions to individuals, but also maintaining a kind of FAQ. This helps avoiding duplicate questions.
Yeah, I understand, but I wanted to avoid making 1000 threads