comparison scripts/polynomial/roots.m @ 6850:9398f6a81bdf

[project @ 2007-08-31 17:29:22 by jwe]
author jwe
date Fri, 31 Aug 2007 17:29:55 +0000
parents a9a95bb1bf9e
children 93c65f2a5668
comparison
equal deleted inserted replaced
6849:c118ea1823f1 6850:9398f6a81bdf
27 ## $$ 27 ## $$
28 ## v_1 z^{N-1} + \cdots + v_{N-1} z + v_N. 28 ## v_1 z^{N-1} + \cdots + v_{N-1} z + v_N.
29 ## $$ 29 ## $$
30 ## @end tex 30 ## @end tex
31 ## @end iftex 31 ## @end iftex
32 ## @ifinfo 32 ## @ifnottex
33 ## 33 ##
34 ## @example 34 ## @example
35 ## v(1) * z^(N-1) + ... + v(N-1) * z + v(N) 35 ## v(1) * z^(N-1) + ... + v(N-1) * z + v(N)
36 ## @end example 36 ## @end example
37 ## @end ifinfo 37 ## @end ifnottex
38 ##
39 ## As an example, the following code finds the roots of the quadratic
40 ## polynomial
41 ## @iftex
42 ## @tex
43 ## $$ p(x) = x^2 - 5. $$
44 ## @end tex
45 ## @end iftex
46 ## @ifnottex
47 ## @example
48 ## p(x) = x^2 - 5.
49 ## @end example
50 ## @end ifnottex
51 ## @example
52 ## c = [1, 0, -5];
53 ## roots(c)
54 ## @result{} 2.2361
55 ## @result{} -2.2361
56 ## @end example
57 ## Note that the true result is
58 ## @iftex
59 ## @tex
60 ## $\pm \sqrt{5}$
61 ## @end tex
62 ## @end iftex
63 ## @ifnottex
64 ## @math{+/- sqrt(5)}
65 ## @end ifnottex
66 ## which is roughly
67 ## @iftex
68 ## @tex
69 ## $\pm 2.2361$.
70 ## @end tex
71 ## @end iftex
72 ## @ifnottex
73 ## @math{+/- 2.2361}.
74 ## @end ifnottex
75 ## @seealso{compan}
38 ## @end deftypefn 76 ## @end deftypefn
39 77
40 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> 78 ## Author: KH <Kurt.Hornik@wu-wien.ac.at>
41 ## Created: 24 December 1993 79 ## Created: 24 December 1993
42 ## Adapted-By: jwe 80 ## Adapted-By: jwe