No BSD License  

Highlights from
Improved Algebra files

3.2

3.2 | 5 ratings Rate this file 3 Downloads (last 30 days) File Size: 91.8 KB File ID: #1530

Improved Algebra files

by Dingyu Xue

 

22 Mar 2002 (Updated 04 Apr 2002)

Comput roots and polynomial functions with high accuracy.

| Watch this File

File Information
Description

Improved algorithms for finding the roots (direct method for first order quadratic, cubic and Quartic) are used for low order equations.
Fadeev algorithm for finding the characteristic polynomial is implemented to ensure high accuracy.
These files can be used as a replacement of original MATLAB files.
PDFversion of technical note is included to show the algorithm and examples.

MATLAB release MATLAB 6.1 (R12.1)
Other requirements Can be used in any version of MATLAB, although tested under 6.1
Tags for This File  
Everyone's Tags
general, high accuracy, mathematics, poly, roots
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
06 Oct 2007 Felix D

With bugs....

See
u = [2.0000 0 0.0625 -0.0187]
roots(u)
roots1(u)

20 Nov 2006 Santhosh Kodipaka

bug]: Try this:
% roots1.m is kind of buggy here
P = [ 0.9159 0.6020 0.2536 0.8735 0.5134];
roots1( P )
roots(P )

04 Aug 2006 Ryan Bennink

The algorithm switches to matlab's less accurate ROOTS function in the case of complex coefficients. If you take the switch out, the algorithms are not quite suitable for complex numbers because they don't always use the right sign of the root. The code below, which replaces lines 50 and 51, yields the correct sign in all cases:

if abs(rr(1))>abs(rr(2))
u=rr(1)^(1/3);
else
u=rr(2)^(1/3);
end
v=-p/u;

In theory, either rr(1) or rr(2) gives the same set of roots, but the larger one will contain relatively less roundoff error.

27 Oct 2005 Raymond Kan

To fix the problem, change lines 50 and 51 to
u=sign(rr(1))*abs(rr(1))^(1/3);
v=sign(rr(2))*abs(rr(2))^(1/3);

31 Mar 2005 Marcelo Pisani

There is an error for 3rd degree polynomials solving using ROOT1. I just tryied this:
---
a=[3 -2 3 -4];
r=roots(a)
r1=roots1(a)
polyval(a,r)
polyval(a,r1)
---

14 Oct 2004 Roger Crouch

this is such a neat compact script! thank you!

Contact us