PREP 2015 Question Authoring - Archived

Random numbers in intervals

Random numbers in intervals

by Whitney George -
Number of replies: 1
I am trying to create a few intervals with random entries. This is the set-up that I have: 
------------------------------------------------------------------------------------------
DOCUMENT();        # This should be the first executable line in the problem.

loadMacros(
  "PGstandard.pl",
  "PGunion.pl",
  "MathObjects.pl",
  "PGML.pl",
  "PGcourse.pl"
);

TEXT(beginproblem);

######################################################################
#
#  The Setup
#

Context("Interval");
$a = random(-25,5,1);
$b = random(6,34,1);
$c = random(-13,0,1);
$d = random(1,55,1);
$I1 = Interval("([$a],[$b]]");
$I2 = Interval("($c,$d)");
######################################################################
#
#  The Problem Text
#

BEGIN_PGML

This is [`[$l1]`] and this is [`[$l2]`]
END_PGML

######################################################################

ENDDOCUMENT();        # This should be the last executable line in the problem.
------------------------------------------------------------------
When I view this problem, the intervals do not show up. Do I need to do something extra so that intervals can take random variables?
In reply to Whitney George

Re: Random numbers in intervals

by Davide Cervone -
There are two issues: First, you definition for the first interval should be $I1 = Interval("($a,$b]"); (you only need the brackets around the variables inside BEGIN_PGML/END_PGML). Second, in the PGML section, you have used lower-case L's instead of upper case i's. So the variable is not the same one that you set earlier. In fact, the variable is not defined, and so PGML inserts nothing at those locations.