## WeBWorK Main Forum

### Smoother Dynamic Image

by Utku Demir -
Number of replies: 1
Hi all,

I have been trying to plot s smoother dynamic images, but no success so far. I found a couple of ways to possibly handle this: http://webwork.maa.org/moodle/mod/forum/discuss.php?d=3653 , but these methods didn't change anything for me. Also, here is the code I am using right now

######### (Setup section):

$gr1 = init_graph(-4,-4,4,4, axes=>[0,0], grid=>[5,5], size=>[150,150] );$form1= Formula("3*sin(2*x)");

($f1n) = plot_functions($gr1, "$form1 for x in <-4,4> using color:blue and weight:2");$f1n->steps(5000);
$fig1 = image(insertGraph($gr1),
width=>300,height=>300,tex_size=>800);

######### (Text section (After BEGIN_TEXT)):

\{ $fig1 \} I do wonder what I do wrong. Aside from changing the steps(), I had also tried a method that was given in the link I provided:$f = Formula("3*sin(2*pi/3 * (x - 1)) + 3");
add_functions($gr, "$f for x in <-10,0> using color:blue and weight:2");
add_functions($gr, "$f for x in <0,10> using color:blue and weight:2");

Could you guys help me with this?

Kind regards,
Utku Demir

In reply to Utku Demir

### Re: Smoother Dynamic Image

by Davide Cervone -
Note that you have specified an image size of 150 x 150 in
$gr1 = init_graph(-4,-4,4,4, axes=>[0,0], grid=>[5,5], size=>[150,150] );  but then ask for an image to be used at 300 x 300 pixels in $fig1 = image(insertGraph(\$gr1),
width=>300,height=>300,tex_size=>800);

So that means that the image will be forced to be displayed at twice its actual size, which will look really bad. Matching the two dimensions will help.

Also note that making the function use 5000 steps is considerable overkill, since you only have 150 pixels in either direction. You would need 5000 pixels to make 500 steps be useful. You are just wasting processing time redrawing the same pixel over and over again.