Hi everyone,

For those who are interested, I finally figured out what the gnuplot issue was, 
and I am stunned. It did not like using 1/4 and 1/2 as coefficients for the 
sin() functions. When I replaced them with 0.25 and 0.5 the plots work fine.

These would not work:
   $fnct_rms_halfwave="1/sqrt(pi) * sqrt(1/2*(pi-x*pi/180) + 
1/4*sin(2*x*pi/180))";
   $fnct_rms_fullwave="sqrt(2/pi) * sqrt(1/2*(pi-x*pi/180) + 
1/4*sin(2*x*pi/180))";

These work fine:
   $fnct_rms_halfwave="1/sqrt(pi) * sqrt(0.5*(pi-x*pi/180) + 
0.25*sin(2*x*pi/180))";
   $fnct_rms_fullwave="sqrt(2/pi) * sqrt(0.5*(pi-x*pi/180) + 
0.25*sin(2*x*pi/180))";

Just thought I'd share what I found in case anyone else runs across this 
problem. Although I don't know the "why", at least I know the "what" that 
caused it. If anyone knows the why, I'd love to know...

BR,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://polytechnic.purdue.edu/south-bend/

-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
raeb...@msu.edu
Sent: Wednesday, April 8, 2020 8:27 AM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] gnuplot problem

Hello Gene,

>
> "/home/httpd/perl/tmp/glhardin_purdue_1586186312_6039374_plot.data",
> line 13: expecting ':'
>

Line 13 refers to the line number in the *_plot.data file, which would have 
been in /home/httpd/perl/tmp on the LON-CAPA server from where ITaP retrieved 
the error log information.

Of course by now, nightly clean-up scripts will have removed the *_plot.data 
files from /home/httpd/perl/tmp, so you need to regenerate the error, and have 
ITaP provide you with the *_plot.data file which corresponds with the (new) 
error logged in the web server error logs.

Once you have the *_plot.data file then you could also experiment with that 
outside LON-CAPA, by using it with a version of gnuplot installed locally on 
your own computer.  If you wanted to experiment within the Linux environment, 
but don't use Linux as your primary OS, you could set up a Linux VM using 
VirtualBox (or similar), if you have the memory available to allocate to a VM, 
and install gnuplot there.

Stuart Raeburn
LON-CAPA Academic Consortium
________________________________________
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> on behalf of 
Harding, Gene L <glhar...@purdue.edu>
Sent: Tuesday, April 7, 2020 7:33 PM
To: Discussion list for LON-CAPA users
Subject: Re: [LON-CAPA-users] gnuplot problem

Hi Stuart,

Wouldn't taking the absolute value of the expression inside the sqrt function 
also work? I tried this, thinking it would remove the negative number problem, 
but it did not work:
     $fnct_rms_halfwave="1/sqrt(pi) * sqrt( abs(1/2*(pi-x*pi/180) + 
1/4*sin(2*x*pi/180)) )"; I checked my gnuplot manual, and abs() appears to be 
the correct syntax for absolute value. Wouldn't that fix the negative number 
issue?


These are the lines IT sent me from the error log:
[Mon Apr 06 10:59:07 2020] [error] [client 128.210.56.177] 
"/home/httpd/perl/tmp/glhardin_purdue_1586185147_62400672_plot.data", line 13: 
expecting ':', referer: 
https://urldefense.com/v3/__https://loncapa.purdue.edu/priv/purdue/ecet_purdue/Topics/Power_Electronics/Thyristors/Calc_FiringAngle_using_Graphs_GeogebraInteractive_Multipart.problem__;!!HXCxUKc!gG78S6Qp2qDtQFc0NrfUKzJ4BmC7aOLMiBQ-9GfMLhgv8M9GqPiE0mgQfYzpVQ$

[Mon Apr 06 11:17:06 2020] [error] [client 128.210.56.177] 
"/home/httpd/perl/tmp/glhardin_purdue_1586186225_6003521_plot.data", line 13: 
expecting ':', referer: 
https://urldefense.com/v3/__https://loncapa.purdue.edu/priv/purdue/ecet_purdue/Topics/Power_Electronics/Thyristors/Calc_FiringAngle_using_Graphs_GeogebraInteractive_Multipart.problem__;!!HXCxUKc!gG78S6Qp2qDtQFc0NrfUKzJ4BmC7aOLMiBQ-9GfMLhgv8M9GqPiE0mgQfYzpVQ$

[Mon Apr 06 11:18:32 2020] [error] [client 128.210.56.177] 
"/home/httpd/perl/tmp/glhardin_purdue_1586186312_6039374_plot.data", line 13: 
expecting ':', referer: 
https://urldefense.com/v3/__https://loncapa.purdue.edu/priv/purdue/ecet_purdue/Topics/Power_Electronics/Thyristors/Calc_FiringAngle_using_Graphs_GeogebraInteractive_Multipart.problem__;!!HXCxUKc!gG78S6Qp2qDtQFc0NrfUKzJ4BmC7aOLMiBQ-9GfMLhgv8M9GqPiE0mgQfYzpVQ$

[Mon Apr 06 14:42:22 2020] [error] [client 128.210.56.177] 
"/home/httpd/perl/tmp/glhardin_purdue_1586198542_65331252_plot.data", line 13: 
expecting ':', referer: 
https://urldefense.com/v3/__https://loncapa.purdue.edu/priv/purdue/ecet_purdue/Topics/Power_Electronics/Thyristors/Calc_FiringAngle_using_Graphs_GeogebraInteractive_Multipart.problem__;!!HXCxUKc!gG78S6Qp2qDtQFc0NrfUKzJ4BmC7aOLMiBQ-9GfMLhgv8M9GqPiE0mgQfYzpVQ$

Do they make sense to you? Line 13 in the LON-CAPA code is part of a 
<startouttext /> statement, so I don't think that's the line the errors are 
referring to. I looked through the code again, and do not know where it might 
be expecting to see a ":" character, although I have done many versions of this 
during troubleshooting, and I wonder if this error came from a version when I 
was using the ternary operator to limit the plot interval.

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://urldefense.com/v3/__https://polytechnic.purdue.edu/south-bend/__;!!HXCxUKc!gG78S6Qp2qDtQFc0NrfUKzJ4BmC7aOLMiBQ-9GfMLhgv8M9GqPiE0mgtNE-WWg$

-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
raeb...@msu.edu
Sent: Tuesday, April 7, 2020 8:50 AM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] gnuplot problem

Gene,

>
>  Two of them work fine, and the other two, which both have sine 
> expressions inside a sqrt function, do not.
>

My guess would be that gnuplot is encountering an issue because floating point 
arithmetic results in evaluation of the square root of a negative number (very 
close to zero), which should really be 0.

In that case an alternative would be to explicitly evaluate the components of 
the function within a perl script block in LON-CAPA, and test that they will 
not result in a negative number before applying LON-CAPA's sqrt() function to 
the result (rom which you would then add the value to an array (@Y) of y values 
for the plot).  The array (@X) will contain the corresponding x values, which 
you would have generating within the loop you use to generate the y values (in 
the @Y) array.

You would then replace use of the <function></function> tag with 
<data>@X</data> <data>@Y</data>

where @X and @Y are arrays containing x and y values for the points on the plot.

See the: "Data Plot with Numerical Response" example in the problem templates.

Stuart Raeburn
LON-CAPA Academic Consortium
________________________________________
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> on behalf of 
Harding, Gene L <glhar...@purdue.edu>
Sent: Monday, April 6, 2020 7:35 PM
To: Discussion list for LON-CAPA users
Subject: Re: [LON-CAPA-users] gnuplot problem

Thanks Stuart. I do not have access to those directories (as far as I can 
tell), so have reached out to some IT folks to see if they can help me. I 
realized later that, apparently, "dynamically generated plot" is just the alt 
tag for the gnuplot.

I am baffled about what is going on. I have four functions for this problem. 
Two of them work fine, and the other two, which both have sine expressions 
inside a sqrt function, do not. I have tried using the ternary operator to zero 
out values outside of the axis limits. In all of the playing/troubleshooting I 
have done, it appears to not like the sqrt(bla bla sin(stuff)). I am not sure 
what version of gnuplot we are using.

I think I am just going to do the problem using Geogebra and forget about 
gnuplot, but it would be nice to know what's going on with the gnuplot. 
Hopefully, my IT guys can help...

BR,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://urldefense.com/v3/__https://polytechnic.purdue.edu/south-bend/__;!!HXCxUKc!jTjoyEwsimPmL2daj4jh1wXvO-ThMXDm58g_FiI6994pTe0-lVckSwwcNawAEA$

-----Original Message-----
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> On Behalf Of 
Raeburn, Stuart
Sent: Monday, April 6, 2020 3:11 PM
To: Discussion list for LON-CAPA users <lon-capa-users@mail.lon-capa.org>
Subject: Re: [LON-CAPA-users] gnuplot problem

Hello Gene,

If the text: "dynamically generated plot" is displayed instead of an image, 
when using gnuplot, then it means gnuplot was unable to process the data file 
generated by LON-CAPA for your plot.

That data file will have been written to /home/httpd/perl/tmp/ on your server's 
filesystem with a file name that includes your username, and ends _plot.data. 
and there will also be an error message in the web server's error log file, 
e.g., /var/log/httpd/ssl_error_log, with your problem listed as the referer.  
(You'd need to ask your system administrator to look in the log files).

I was able to successfully generate plots for both functions:
$fnct_rms_halfwave="1/$pi * &sqrt(1/2*($pi-x) + 1/4*sin(2*x))";
$fnct_rms_fullwave="&sqrt(2/$pi) * &sqrt(1/2*($pi-x) + 1/4*sin(2*x))";

in a problem in my Authoring Space (gnuplot version: 4.4.2).

You might double check that there is not a typo in the problem XML, where you 
refer to the function, e.g., <function>$fnct_rms_halfwave</function>

Otherwise, there could be an issue with other attributes defined for the plot, 
aside from the functions themselves (although in most cases, LON-CAPA replaces 
invalid values with valid ones, before creating the _plot.data file passed to 
gnuplot).

Stuart Raeburn
LON-CAPA Academic Consortium
________________________________________
From: LON-CAPA-users <lon-capa-users-boun...@mail.lon-capa.org> on behalf of 
Harding, Gene L <glhar...@purdue.edu>
Sent: Monday, April 6, 2020 11:22 AM
To: Discussion list for LON-CAPA users
Subject: [LON-CAPA-users] gnuplot problem

Hi everyone,

I am having trouble generating a gnuplot using the following two functions in 
LON-CAPA:
   $fnct_rms_halfwave="1/$pi * &sqrt(1/2*($pi-x) + 1/4*sin(2*x))";
   $fnct_rms_fullwave="&sqrt(2/$pi) * &sqrt(1/2*($pi-x) + 1/4*sin(2*x))";

Instead of rendering a plot, LON-CAPA just displays a message that says 
"dynamically generated plot". It plots fine in Geogebra. Does anyone know 
what's going on with the gnuplot?

Best regards,

Gene L. Harding, PE
Associate Professor of ECET
Purdue University
574-520-4190
https://urldefense.com/v3/__https://polytechnic.purdue.edu/south-bend/__;!!HXCxUKc!jTjoyEwsimPmL2daj4jh1wXvO-ThMXDm58g_FiI6994pTe0-lVckSwwcNawAEA$

_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
_______________________________________________
LON-CAPA-users mailing list
LON-CAPA-users@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-users

Reply via email to