[LON-CAPA-users] Imaginary Numbers

Harding, Gene L glhardin at purdue.edu
Thu Feb 18 10:06:43 EST 2016

Hi Stuart, et al,

Thanks, that was very helpful.  After reviewing that web page last night, I was able to complete the calculation portion of a problem successfully.  

I am still having trouble with the response portion.  Is there a way to get "numericalresponse" to handle a complex number?  If not, is the technique Justin suggested using Maxima a good route?  Or is it best to just break the response into two "numericalresponses", one for the real part and one for the imaginary part?

Best regards,

Gene L. Harding, PE
Associate Professor of ECET

-----Original Message-----
From: lon-capa-users-bounces at mail.lon-capa.org [mailto:lon-capa-users-bounces at mail.lon-capa.org] On Behalf Of Stuart Raeburn
Sent: Wednesday, February 17, 2016 4:15 PM
To: lon-capa-users at mail.lon-capa.org
Subject: Re: [LON-CAPA-users] Imaginary Numbers


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.

$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);


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

LON-CAPA-users mailing list
LON-CAPA-users at mail.lon-capa.org

More information about the LON-CAPA-users mailing list