0
|
8889 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

# [?] Select specific values from Solve function?

Posted 7 years ago
 Hello guys! I want to solve a 4th order equation, and to find its solutions. This procedure is straightforward but, after this, I want to select only the last 2 roots, and to store them as variables, say w1 and w2. sol1 = Solve[equ[t, x, j1] == 0, {t}, Reals]; {{t -> -0.241908}, {t -> -0.173627}, {t -> 0.173627}, {t -> 0.241908}}  If I write w1 = sol1[[3]]; w2 = sol1[[4]]; Print[w1, w2]  I get this thing {t->0.173627}{t->0.241908}  But I want only the numerical values, without those useless arrows and letters. HOW CAN I FIX THIS? Thank you in advance!
4 Replies
Sort By:
Posted 7 years ago
 A possible approach: sol1 = Values@Solve[t^4 + t^3 - 2 t^2 - t + 1 == 0, {t}, Reals]; w1 = sol1[[3, 1]]; w2 = sol1[[4, 1]]; Print["w1 =", w1, ", w2 =", w2] w1 =1/2 (-1-Sqrt[5]), w2 =1/2 (-1+Sqrt[5]) 
Posted 7 years ago
 Va multumesc mult pentru solutie. Functioneaza :)Toate cele bune!
Posted 7 years ago
 Cu pl?cere!
Posted 7 years ago
 Sure, there are other approaches, too. E.g.: sol1 = Flatten@Solve[t^4 + t^3 - 2 t^2 - t + 1 == 0, {t}, Reals]; w1 = sol1[[3, 2]] w2 = sol1[[4, 2]] or w1 = t /. sol1[[3]] w2 = t /. sol1[[4]] 
Community posts can be styled and formatted using the Markdown syntax.