Solving 3rd order equation by solve.



Thank you, Stavros.

Now I think that I can consider about the problem that I encountered.

Thank you very much, Villate-san and Macrakis-san
-
ICHIKAWA, Yuji

On 2013/02/24, at 23:59, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> If your goal is to get accurate numerical roots, it is generally better to use a numerical rootfinder, such as realroots or allroots.
> 
> A symbolic solution with specific numeric parameters substituted in is not in general a good way to get accurate numeric results, even for simple cases.  Some interesting reading about this includes George Forsythe's classic "How do you solve a quadratic equation" and W. Kahan's "On the Cost of Floating-Point Computation Without Extra-Precise Arithmetic" (which is mostly about the quadratic formula).  You will see from those articles that even in the simple case of the quadratic formula, considerable cleverness is needed to ensure accurate numerical results -- there is no one formula that gives good results in all cases.
> 
> This is not to say that symbolic results aren't useful even when a numeric final result is wanted, just that it's not as easy as using the appropriate Maxima functions (rectform, float, etc.) in the appropriate order.
> 
>             -s
> 
> 
> On Sun, Feb 24, 2013 at 8:54 AM, ?? ?? <ichikawa.yuji at gmail.com> wrote:
> 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 <villate at fe.up.pt> 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
> >
> 
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>