TransWikia.com

How to chop complex number from solution solve using a model

Mathematica Asked by Boajj04 on December 4, 2020

Hi I have a set of 4 solution that was solved using a 4th order polynomial equation.

I have noticed that some of the real number solution occurred through the list of 4 set of solutions.

I have tried using NSolve[eq, x, Reals], but it didn’t seem to work.
which x is Voltage and eq is Model4th

May I know how can I take the real number and drop the complex number from the list of set solution that it has solved. Appreciate the help in this. Thank you.

Voltage={{0., 0.00299898, 0.0056595, 0.00846798, 0.0115275,0.0144143, 0.0172277, 0.0203354, 0.0237212, 0.0275436, 0.0342872, 0.0382636, 0.0417977, 0.0452588, 0.0486881, 0.0517215, 0.0550465, 0.0590406, 0.0627951, 0.0664531, 0.0703499, 0.0739497, 0.0777382, 0.0819091, 0.0847738, 0.0882099, 0.0926634, 0.0974154, 0.102107, 
0.106157, 0.110773, 0.116486, 0.12085, 0.125753, 0.130923, 0.133084,
0.134845, 0.14029, 0.146419, 0.149465, 0.159954, 0.165511, 0.17092,
0.176773, 0.182682, 0.186097, 0.189999, 0.196082, 0.201638, 
0.206292, 0.212185, 0.2112, 0.214292, 0.220264, 0.226487, 0.23292, 
0.239283, 0.245586, 0.252156, 0.258769, 0.265909, 0.273303, 
0.278748, 0.28593, 0.292643, 0.296605, 0.301424, 0.308663, 0.315477,
0.319692, 0.326676, 0.331786, 0.33845, 0.344443, 0.351514, 
0.357659, 0.362531, 0.368168, 0.373847, 0.376929, 0.386084, 
0.393858, 0.40109, 0.408286, 0.415489, 0.423098, 0.430943, 0.438681,
0.446199, 0.453679, 0.462002, 0.475386, 0.484045, 0.491952, 
0.502127, 0.508499, 0.514265, 0.52187, 0.529553, 0.536074, 0.543574,
0.554489, 0.561938, 0.569314, 0.578082, 0.585111, 0.594472, 
0.605794, 0.614787, 0.621441, 0.627567, 0.634201, 0.64149, 0.64866, 
0.655823, 0.662451, 0.669094, 0.676613, 0.682881, 0.686211, 
0.693435, 0.704665, 0.709921, 0.715917, 0.724835, 0.73208, 0.739558,
0.746521, 0.752433, 0.759454, 0.765712, 0.771968, 0.781281, 
0.787274, 0.796866, 0.804629, 0.81076, 0.816162, 0.821201, 0.826467,
0.832111, 0.837373, 0.842454, 0.848337, 0.853962, 0.859148, 
0.863981, 0.868538, 0.873049, 0.878037, 0.883645, 0.891245, 
0.893063, 0.897389, 0.895544, 0.897927, 0.902695, 0.907078, 
0.910918, 0.914742, 0.91868, 0.921906, 0.928085, 0.932512, 0.936506,
0.941023, 0.945111, 0.949829, 0.954348, 0.95805, 0.961658, 
0.965493, 0.969338, 0.973179, 0.980362, 0.983957, 0.987095, 
0.991231, 0.995486, 0.999121, 1.00204, 1.00537, 1.0088, 1.01342, 
1.01641, 1.01898, 1.02314, 1.02722, 1.03044, 1.03396, 1.03775, 
1.04032, 1.04263, 1.04617, 1.04947, 1.05264, 1.05578, 1.05827, 
1.06055, 1.06296, 1.06477, 1.06685, 1.06905, 1.07113, 1.07301, 
1.07518, 1.07741, 1.0815, 1.08566, 1.09019, 1.0978, 1.09798, 
1.10044, 1.10215, 1.10451, 1.10683, 1.10667, 1.10748, 1.10981, 
1.11178, 1.11393, 1.116, 1.11803, 1.11896, 1.12006, 1.12024, 
1.12146, 1.12322, 1.12488, 1.12623, 1.12757, 1.12996, 1.12666, 
1.12194, 1.12182, 1.12353, 1.12524, 1.12314, 1.12067, 1.1215, 
1.12282, 1.12341, 1.11815, 1.11866, 1.11976, 1.12068, 1.12165, 
1.1221, 1.12255, 1.12345, 1.12459, 1.12539, 1.12602, 1.12717, 
1.12712, 1.12377, 1.1232, 1.12451, 1.12629, 1.12782, 1.12872, 
1.12898, 1.12559, 1.12623, 1.1263, 1.12291, 1.12308, 1.12436, 
1.12536, 1.12619, 1.1264, 1.12725, 1.13302, 1.13315, 1.13368, 
1.13457, 1.13455, 1.13478, 1.13617, 1.13565, 1.13326, 1.13518, 
1.13589, 1.13544, 1.13542, 1.13555, 1.1364, 1.13986, 1.14335, 
1.14469, 1.1447, 1.14473, 1.14564, 1.15154, 1.15229, 1.15248, 
1.15229, 1.1554, 1.15795, 1.15796, 1.15757, 1.15691, 1.15636, 
1.15683, 1.15741, 1.15733, 1.15695, 1.15628, 1.15488, 1.15075, 
1.14763, 1.15233, 1.15251, 1.15255, 1.15264, 1.15296, 1.15369, 
1.15726, 1.15706, 1.15445, 1.15577, 1.16019, 1.16351, 1.15779, 
1.15756, 1.15794, 1.15286, 1.15048, 1.1504, 1.15018, 1.14997, 
1.14945, 1.14958, 1.14892, 1.14403, 1.14802, 1.14537, 1.14028, 
1.13815, 1.13825, 1.1381, 1.13794, 1.1371, 1.13729, 1.14097, 
1.14218, 1.13787, 1.13558, 1.13427, 1.13304, 1.13174, 1.12983, 
1.12985, 1.12967, 1.12808, 1.12754, 1.12744, 1.1273, 1.12635, 
1.12531, 1.12441, 1.12294, 1.12084, 1.12103, 1.12124, 1.12805, 
1.12839, 1.12728, 1.1259, 1.12465, 1.12412, 1.12402, 1.12361, 1.12339, 1.12705, 1.12702, 1.12701, 1.12432, 1.12599, 1.12821, 
1.12729, 1.12833, 1.13349, 1.13227, 1.13124, 1.12953, 1.12762, 
1.12629, 1.12228, 1.11888, 1.11751, 1.11699, 1.12061, 1.12398, 
1.12298, 1.12245, 1.12204, 1.12145, 1.12047, 1.11908, 1.11721, 
1.11688, 1.12039, 1.1196, 1.12005, 1.11998, 1.12118, 1.1216, 
1.12119, 1.12104, 1.11914, 1.11518, 1.11411, 1.114, 1.11539, 1.1143, 1.11409, 1.11511, 1.11502, 1.11486, 1.1146, 1.11355, 1.11307, 
1.11181, 1.11081, 1.10506, 1.10348, 1.10103, 1.09928, 1.09801, 
1.09691, 1.09584, 1.09456, 1.09328, 1.09181, 1.09137, 1.09055, 
1.0894, 1.08876, 1.08814, 1.08729, 1.08691, 1.08719, 1.08685}}


ndata2=444

Model4th = 6.61495 x - 12.491 x^2 + 6.51925 x^3 + 2.21799 x^4

Take[Table[
      NSolve[{Model4th} == {Voltage[[1, i]]}], {i, ndata2}], Reals]

One Answer

tbl0 = Table[NSolve[Model4th == Voltage[[1, i]]], {i, ndata2}];

You can use Select to remove the complex solutions from tbl0:

tbl1 = Select[FreeQ[_Complex]] /@ tbl0;

You can get the result directly using:

tbl2 = Table[NSolve[Model4th == Voltage[[1, i]], x, Reals], {i, ndata2}];

tbl1 == tbl2

True

Answered by kglr on December 4, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP