Ask Your Question

wzawzdb's profile - activity

2019-02-16 14:08:36 -0600 received badge  Notable Question (source)
2019-02-16 14:08:36 -0600 received badge  Popular Question (source)
2017-06-16 11:13:54 -0600 received badge  Notable Question (source)
2017-04-04 16:19:12 -0600 received badge  Popular Question (source)
2016-02-28 10:13:46 -0600 received badge  Popular Question (source)
2015-03-26 22:09:38 -0600 marked best answer Use a symbolic solved variable in another later equation

So I just started using sage but I can't find this (or I don't know how to formulate it).

I have an equation that I solved and I want to use that solved variable in a new equation:

a, b, c, d = var('a b c d')
eq1=a+b==d
eq2=solve([eq1],b)
eq3=c/eq2

but this doesn't work and of course I can do c/b but then it just gives me c/b and I want c/(d-a) as an answer.

2014-09-02 10:18:30 -0600 commented answer Solve for variable but variable is still in answer

Why do you subtract eq7c rhs from lhs **=^

2014-08-29 14:53:25 -0600 received badge  Supporter (source)
2014-08-29 12:21:31 -0600 commented answer Solve for variable but variable is still in answer

And there are no other options to solve this? I know there are two solutions (quadratic rule) but I take only one with the eq6[0].rhs() right?

2014-08-29 10:50:42 -0600 commented question complex substitution

Yeah, I understand, but I wanted to avoid making 1000 threads

2014-08-29 10:12:33 -0600 commented question complex substitution

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.

2014-08-29 08:48:42 -0600 commented question Solve for variable but variable is still in answer

I forgot to copy that line or something, sorry about that

2014-08-28 15:39:48 -0600 commented question Solve for variable but variable is still in answer

It looks like it sees P3 and P3 as different variables?

2014-08-28 15:39:15 -0600 received badge  Commentator
2014-08-28 12:49:41 -0600 asked a question Solve for variable but variable is still in answer

I try to solve for variable P3. Sage gives me an answer for P3 but it still contains P3 on the right hand side (see last equation after the solve in the beginning of sqrt?

sage: A1, A2, A3, P1, P2, P3, u1, u2, u3, r1, r2, r3, g, C, M1, M2, M3 = var('A1 A2 A3 P1 P2 P3 u1 u2 u3 r1 r2 r3 g C M1 M2 M3')
sage: eq1=A3*(P1-P3)==A3*r3*u3^2-(A2*r2*u2^2+A1*r1*u1^2)
sage: eq2=A3*u3*r3==A2*u2*r2+A1*r1*u1
sage: eq5a=solve([eq2],r3)
sage: eq5b=u3^2+2*g/(g-1)*(P3/(eq5a[0].rhs()))-2*C==0
sage: eq6=solve([eq5b],u3)
sage: eq7a=eq1/A3
sage: eq7b=eq7a.subs(-A3*r3*u3^2 == -(A2*u2*r2+A1*r1*u1)*u3)
sage: eq7b
P1 - P3 == -(A1*r1*u1^2 + A2*r2*u2^2 + (A3*P3*g + sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))*(A1*r1*u1 + A2*r2*u2)/(A1*(g - 1)*r1*u1 + A2*(g - 1)*r2*u2))/A3

sage: eq7c=eq7b.subs(u3==eq6[0].rhs()) 
sage: eq7=solve([eq7c],P3)
sage: eq7
[P3 == (A1*r1*u1^2 + A2*r2*u2^2 + A3*P1 - (A1*r1*u1^2 + A2*r2*u2^2 + A3*P1)*g - sqrt(A3^2*P3^2*g^2 + 2*((g^2 - 2*g + 1)*A1^2*r1^2*u1^2 + 2*(g^2 - 2*g + 1)*A1*A2*r1*r2*u1*u2 + (g^2 - 2*g + 1)*A2^2*r2^2*u2^2)*C))/A3]
2014-08-28 09:18:53 -0600 commented answer complex substitution

Ah okay I think I get it! Great thanks for the elaborate answer! What is the difference between .subs and .subs_expr?

2014-08-27 17:05:30 -0600 received badge  Student (source)
2014-08-27 14:53:29 -0600 edited question 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

2014-08-27 08:28:19 -0600 commented question complex substitution

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?

2014-08-26 16:00:15 -0600 commented question complex substitution

When I use the .subs_expr it doesn't give me back anything

2014-08-26 15:42:14 -0600 received badge  Scholar (source)