I'm trying to create a problem using graphs. I can get my graph (a sine function) to plot but it is "janky"; not enough points are chosen for the plot to create a nice smooth graph (see below). Is there any way to increase the number of points chosen in the domain to get a smoother graph?

Here's my code for the problem:

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGgraphmacros.pl",

"PGML.pl",

"AnswerFormatHelp.pl",

"PGcourse.pl",

);

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

$refreshCachedImages = 1;

Context("Point");

$pix = 400;

# Create the canvas

#$pixels=>[2000,2000];

$gr = init_graph(-10,-10,10,10, # xmin, ymin, xmax, ymax

axes=>[0,0], grid=>[20,20], size=>[$pix,$pix]);

$gr -> lb('reset'); # remove default labels

# axes labels

$gr->lb( new Label(9.5,0,'x', 'black', 'center', 'bottom'));

$gr->lb( new Label(0.1,9.5,'y', 'black', 'left', 'middle'));

# axes labels

foreach my $i (-10..10) {

$gr->lb( new Label($i,0, $i, 'black', 'center', 'top'));

$gr->lb( new Label(-0.1,$i, $i, 'black', 'right', 'middle'));

}

# plot a function

$d = random(-9,9,1);

if (abs($d - 10) < abs($d + 10)) {

$a = random(0.5, abs($d - 10), 0.5); }

else {

$a = random(0.5, abs($d + 10), 0.5); }

$b = random(0.5,5,0.5);

$c = random(0,$b,0.25);

#$f = Formula("$a*sin(2*pi/$b * (x - $c)) + $d");

$f = Formula("3*sin(2*pi/3 * (x - 1)) + 3");

add_functions($gr, "$f for x in <-10,10> using color:blue and weight:2");

$answer = Point("(0,$b)");

BEGIN_PGML

[%What are the coordinates of the vertex of the parabola in the graph?

[____________]{$answer} [@ AnswerFormatHelp("points") @]*%]

>> [@ image(insertGraph($gr), width=>$pix, height=>$pix, tex_size=>800) @]*

A sine graph. <<

END_PGML

COMMENT("MathObject version. Uses PGML.");

ENDDOCUMENT();