15.02.2015 Views

A.2.4 Counting Roots of Polynomials - Wolfram Research

A.2.4 Counting Roots of Polynomials - Wolfram Research

A.2.4 Counting Roots of Polynomials - Wolfram Research

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A.2 Implementing Mathematical Algorithms 619<br />

<strong>A.2.4</strong> <strong>Counting</strong> <strong>Roots</strong> <strong>of</strong> <strong>Polynomials</strong><br />

The packages we have discussed so far implement algorithms that basically involve<br />

only numbers or lists <strong>of</strong> numbers. You can also write Mathematica programs that<br />

implement symbolic and algebraic algorithms.<br />

Here is an example <strong>of</strong> a package that implements Sturm's method for counting<br />

the real roots <strong>of</strong> a polynomial in an interval.<br />

Count<strong>Roots</strong>::usage =<br />

"Count<strong>Roots</strong>[f,{x,a,b}] computes the number <strong>of</strong> zeroes <strong>of</strong> the real polynomial<br />

f on the interval a


620 A. Some Examples <strong>of</strong> Mathematica Packages<br />

This shows that the polynomial has three<br />

real roots in the range -2 to 2.<br />

In[3]:= Plot[poly, {x,-2,2}]<br />

10<br />

7.5<br />

5<br />

2.5<br />

-2 -1<br />

-2.5<br />

1 2<br />

-5<br />

You can check this result using<br />

Count<strong>Roots</strong>.<br />

In[4]:= Count<strong>Roots</strong>[poly, {x, -2, 2}]<br />

Out[4]= 3<br />

Web sample page from The Mathematica Book, First Edition, by Stephen <strong>Wolfram</strong>, published by Addison-Wesley Publishing<br />

Company (hardcover ISBN 0-201-19334-5; s<strong>of</strong>tcover ISBN 0-201-19330-2). To order Mathematica or this book contact <strong>Wolfram</strong><br />

<strong>Research</strong>: info@wolfram.com; http://www.wolfram.com/; 1-800-441-6284.<br />

c 1988 <strong>Wolfram</strong> <strong>Research</strong>, Inc. Permission is hereby granted for web users to make one paper copy <strong>of</strong> this page for their<br />

personal use. Further reproduction, or any copying <strong>of</strong> machine-readable files (including this one) to any server computer, is strictly<br />

prohibited.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!