市川 雄二
ichik****@gmail*****
2013年 2月 24日 (日) 22:54:17 JST
Thank you, Jaime. It works! How about this problem? (I change an equation just a little.) Executing float(rectform(solve(x^3-3*x^2-2*x+1,x))); results [x=.3433795689528897-2.220446049250313*10^-16*%i,x=2.220446049250313*10^-16*%i-.8342431843139217,x=1.110223024625157* 10^-16*%i+3.490863615361032] though realroots(x^3-3*x^2-2*x+1); is [x=-27992557/33554432,x=11521907/33554432,x=117133945/33554432]. I want to know general methods to avoid a small imaginary error. Thanks, - ICHIKAWA, Yuji On 2013/02/24, at 21:49, Jaime Villate <villa****@fe*****> wrote: > On 02/24/2013 11:24 AM, 市川 雄二 wrote: >> >> Executing >> solution: solve(x^3-x^2+1=0, x), rectform; >> ... >> >> The second one in solution is a real root. >> To know the concrete value, executing >> solution, float; >> results >> [x=0.744861766619749*%i+.8774388331233485,x=-.7548776662466969,x=.8774388331233485-0.744861766619749*%i]. >> >> I want to get this result by single command. >> But executing >> solution: solve(x^3-x^2+1=0, x), rectform, float; >> results >> [x=.7448617666197254*%i+.8774388331233376,x=-8.480870326997723*10^-17*%i-.7548776662466756,x=.8774388331233378- >> .7448617666197253*%i]. >> >> The second one includes a very small imaginary part. >> >> How can I avoid it? > > Hi, > try > solution: float( rectform( solve( x^3-x^2+1=0, x))); > > which allows you to make the three things in the order you want them to be made. In your original command > > solution: solve(x^3-x^2+1=0, x), rectform, float; > > you used function ev(), which is more unpredictable in the way the modifiers rectform and float will be applied. > > Regards, > Jaime >