[npl] / trunk / NationalProblemLibrary / Rochester / setAlgebra23PolynomialZeros / descartes2.pg Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

View of /trunk/NationalProblemLibrary/Rochester/setAlgebra23PolynomialZeros/descartes2.pg

Thu Aug 2 19:46:13 2012 UTC (9 months, 2 weeks ago) by jj
File size: 1709 byte(s)
```Fix bug 2380 -- improved keywords.
```

```    1 ##DESCRIPTION
2 ##KEYWORDS('Decartes rule of signs','real roots')
3 ##TYPE('word problem')
4 ##ENDDESCRIPTION
5
7
8 ## DBsubject('Algebra')
9 ## DBchapter('Polynomial and Rational Functions')
10 ## DBsection('Real Zeros of Polynomials')
11 ## Date('')
12 ## Author('')
13 ## Institution('Rochester')
14 ## TitleText1('')
15 ## EditionText1('')
16 ## AuthorText1('')
17 ## Section1('')
18 ## Problem1('')
19
20 DOCUMENT();        # This should be the first executable line in the problem.
21
23 "PG.pl",
24 "PGbasicmacros.pl",
25 "PGchoicemacros.pl",
27 "PGauxiliaryFunctions.pl",
28 "PGpolynomialmacros.pl"
29 );
30
31 TEXT(beginproblem());
33
34
35 \$degree = random(6,9,1);
36
37 foreach \$i (0..\$degree) {
38         \$poly[\$i] = non_zero_random(-20,20,1);
39 }
40
41 (\$maxpos,\$maxneg) = Descartes(~~@poly);
42
43 \$poly = PolyString(~~@poly);
44
45 BEGIN_TEXT;
46 Use Descartes' Rule of Signs to analyze the number of positive and negative real
47 roots and the number of non-real roots of the function:
48 \[h(x) = \$poly\]
49 \$BR
50 \$BR
51 There are at least \{ans_rule(5)\} and at most \{ans_rule(5)\} positive real
52 roots.
53 \$BR
54 There are at least \{ans_rule(5)\} and at most \{ans_rule(5)\} negative real
55 roots.
56 \$BR
57 There are at least \{ans_rule(5)\} and at most \{ans_rule(5)\} non-real
58 roots.
59 \$BR
60 END_TEXT
61
62 if (int(\$maxpos/2)==\$maxpos/2) {\$minpos = 0;}
63 else {\$minpos = 1;}
64 if (int(\$maxneg/2)==\$maxneg/2) {\$minneg = 0;}
65 else {\$minneg = 1;}
66 \$mincomp = \$degree-(\$maxpos+\$maxneg);
67 \$maxcomp = \$degree-(\$minpos+\$minneg);
68
69 ANS(num_cmp(\$minpos));
70 ANS(num_cmp(\$maxpos));
71 ANS(num_cmp(\$minneg));
72 ANS(num_cmp(\$maxneg));
73 ANS(num_cmp(\$mincomp));
74 ANS(num_cmp(\$maxcomp));
75
76
77 ENDDOCUMENT();        # This should be the last executable line in the problem.
78
```