[LON-CAPA-users] Imaginary Numbers

Stuart Raeburn raeburn at msu.edu
Wed Feb 17 16:15:29 EST 2016


Hi,

LON-CAPA loads a modified version of the Math::Complex perl module  
into perl safe space (named LONCAPA::LCMathComplex), so the following  
could be used in a perl script block in a resource in LON-CAPA.

$a=&random(1,5,1);
$b=&random(5,10,1);
$c=&random(10,15,1);
$d=&random(15,20,1);
$z1 = &cplx($a, $b);
$z2 = &cplx($c, $d);
$product = $z1 * $z2;
$e = &Re($product);
$f = &Im($product);

If you want to override perl's standard sqrt() function with one that  
handles imaginary numbers, you can do so, e.g.,

$g = &LONCAPA::LCMathComplex::sqrt(-1);

See:
http://search.cpan.org/~jhi/Math-Complex-1.56/lib/Math/Complex.pm

Stuart Raeburn
LON-CAPA Academic Consortium


Quoting "Harding, Gene L" <glhardin at purdue.edu>:

> Hi,
>
> Can LON-CAPA handle imaginary and complex numbers?  I am having   
> trouble finding any info about it in the help.
>
> Thanks,
>
> Gene L. Harding, PE
> Associate Professor of ECET
> 574-520-4190



More information about the LON-CAPA-users mailing list