0
|
333 Views
|
6 Replies
|
2 Total Likes
View groups...
Share
GROUPS:

Table of NSolve (and Solve) solutions creates extra unknown answers

Posted 15 days ago
 When I try to prepare a table of solution in the following way: tt=Table[z/.NSolve[{x + y + z == 0, x - y == 0.5},{y, z}],{x, 0, 3, 0.1}]  I get the full answer for z: {{0.5),{0.3},{0.1},…,(-5.5}} Applying tt//TableForm yields a column with: 0.50.30.1etc. The table can be transferred to Excell as a single column there and made use of there. However, when the expressions (equations) are more complicated I get eight columns. Columns 1-5 are unidentified (four of them complex numbers), No. 6 seems to be the answer z I am looking for and Nos. 7 and 8 contain zero only. (In a simpler problem with only two variables x, y but quite complicated expression the number of columns is reduced to 5 with only one looking to be the correct answer y.) Question: What do those 8 columns present and is one of them the correct answer z, indeed?
6 Replies
Sort By:
Posted 13 days ago
 Thank youIndeed, I accept positive solutions only.
Posted 14 days ago
 Thank you. Here it is: k2 = 7.25941*10^-11 k1 = 3.7008*10^-10 kx = 3.15569*10^-8 kvv = 0.152304 vmax = 0.32 t6 = Table[p2 /. NSolve[{vt*n^2 == (4*(vmax - vt)^3*k2 + 2*n*(vmax - vt)^2*k1 + n^2*(vmax - vt)*kx + p2*2*(vmax - vt)*kx^2*n^2/kvv)*p2, n^3 == (8*(vmax - vt)^3*k2 + 2*n*(vmax - vt)^2*k1)*p2, vt == 10^lvt}, {p2, n, vt}], {lvt, -4, -0.5, 0.05}] Out[8] {{-0.0038515 - 0.0304568 I, -0.0038515 + 0.0304568 I, 0.000199833}, {-0.00386354 - 0.0304558 I, -0.00386354 + 0.0304558 I, 0.000224192}, {-0.00387704 - 0.0304546 I, -0.00387704 + 0.0304546 I, 0.000251516}, {-0.00389219 - 0.0304534 I, -0.00389219 + 0.0304534 I, 0.000282167}, {-0.00390917 - 0.030452 I, -0.00390917 + 0.030452 I, 0.000316546}, {-0.00392823 - 0.0304504 I, -0.00392823 + 0.0304504 I, 0.000355107}, {-0.0039496 - 0.0304488 I, -0.0039496 + 0.0304488 I, 0.000398354}, {-0.00397356 - 0.0304469 I, -0.00397356 + 0.0304469 I, 0.000446855}, etc.... t6//TableForm Out[9] {{-3.49461*10^6, -2.44888*10^6 - 1.74943*10^6 I, -2.44888*10^6 + 1.74943*10^6 I, 594461. - 821951. I, 594461. + 821951. I, 0.419391, 0., 0.}, {-3.49528*10^6, -2.44938*10^6 - 1.74884*10^6 I, -2.44938*10^6 + 1.74884*10^6 I, 595306. - 821454. I, 595306. + 821454. I, 0.592224, 0., 0.}, {-3.49604*10^6, -2.44995*10^6 - 1.74817*10^6 I, -2.44995*10^6 + 1.74817*10^6 I, 596254. - 820897. I, 596254. + 820897. I, 0.836248, 0., 0.}, {-3.49689*10^6, -2.45059*10^6 - 1.74742*10^6 I, -2.45059*10^6 + 1.74742*10^6 I, 597319. - 820274. I, 597319. + 820274. I, 1.18076, 0., 0.}, etc... 
Posted 14 days ago
 What do you mean by "unidentified"? You have a system of nonlinear polynomial equations, you can expect multiple solutions. In every row you get different solutions for a given value of lvt, I am not sure in what order. I supplied numerical values for vtn and p22: k2 = 7.25941*10^-11; k1 = 3.7008*10^-10; kx = 3.15569*10^-8; kvv = 0.152304; vmax = 0.32; vtn = 1; p22 = 1; t6 = Table[p2 /. NSolve[{vtn^2 == (4 (vmax - vt)^3 k2 + 2 n (vmax - vt)^2 k1 + n^2 (vmax - vt) kx + p22 (vmax - vt) kx^2 n^2/kvv) p2, n^3 == (8 (vmax - vt)^3 k2 + 2 n (vmax - vt)^2 k1)*p2, vt == 10^lvt}, {p2, n, vt}], {lvt, -4, -0.5, 0.05}] Perhaps you are looking for real solutions only? If so, give NSolve the option Reals.
Posted 14 days ago
 Thank you. This answers my question.
Posted 14 days ago
 If you accept only positive solution, you can add the condition to the equations: t6 = Table[ p2 /. NSolve[{vt* n^2 == (4*(vmax - vt)^3*k2 + 2*n*(vmax - vt)^2*k1 + n^2*(vmax - vt)*kx + p2*2*(vmax - vt)*kx^2*n^2/kvv)*p2, n^3 == (8*(vmax - vt)^3*k2 + 2*n*(vmax - vt)^2*k1)*p2, vt == 10^lvt, p2 > 0}, {p2, n, vt}], {lvt, -4, -0.5, 0.05}] 
Posted 15 days ago
 There are no special hidden meanings to the result of NSolve. But if you want help understanding the results you're going to need to provide us with the actual example.