maths / moodle-qtype_stack

Stack question type for Moodle
GNU General Public License v3.0
142 stars 149 forks source link

Problem with polarform_simp #1307

Closed bgailer closed 1 week ago

bgailer commented 1 week ago

Hello,

when creating STACK tasks with complex numbers, the simplification always tends to the Cartesian form. I discovered the function polarform_simp which really helps a lot for this.

In one of the tasks, the polarform_simp throws an error ("part: argument must be a non-atomic expression") when using it on a purely imaginary number, where cabs(%i/2) is less than one. I tried some other numbers, and it seems the function has problems with r being less than one.

Those for example throw an error

simp: false;
{@polarform_simp(%i/2)@}
{@polarform_simp(1/2*%e^(%i*%pi))@}

and for {@polarform_simp(1/(2*%pi)*%e^(%i*%pi))@} the function outputs a different result.

I made an attempt to fix this, but I am not sure if this is the way to go (see the attached file). Polarformsimp_new.zip

sangwinc commented 1 week ago

I'm really sorry about this. The issue was already fixed here https://github.com/maths/moodle-qtype_stack/blob/dev/stack/maxima/assessment.mac#L510 and will be in the next release. I very much appreciate your code, and I've added in your test cases for good measure.