Some questions about complex numbers

9 views
Skip to first unread message

Martin Jones

unread,
May 25, 2022, 6:49:53 AM5/25/22
to Numbas Users
I have a few issues/questions about using complex numbers in Numbas:
  • I have found that JME will happily support complex number entries in matrices, but the "Matrix entry" part will only support real number entries. Is there a way around this? Perhaps a custom part-type could be developed or the matrix entry part-type could be enhanced?
  • When solving an equation (e.g. quadratic equation) there will often be multiple solutions. The option to "sort student's answers"works well in a gapfill when real numbers are involved, but will not work for complex numbers. I have got around the issue by prompting for "solution with positive imaginary part" and "solution with negative imaginary part" but it is somewhat clumsy. I noticed the custom part-type "List of numbers" and wondered if a more generic "List of expressions" would be possible.
  • Due to the context of their training, my students usually use "j" rather than "i". I remember some discussion on this previously but don't know what the outcome was. Ideally I would like to accept inputs and display outputs with "j". I tried to define a constant j=sqrt(-1) but it did not work. (I can provide more details if needed).
Thanks
Martin

Christian Lawson-Perfect

unread,
May 26, 2022, 5:17:48 AM5/26/22
to numbas...@googlegroups.com
The hard thing about complex numbers is that there are a lot of different ways of writing them, and they all look more like mathematical expressions than numbers. So neither number entry nor matrix entry parts accept complex numbers at the moment.
I'm not completely averse to just accepting things of the form `number + number*i`, and leaving other ways of writing them for later.

There's an issue in the tracker from 2015 about parts where the answer is a set: https://github.com/numbas/Numbas/issues/391. It's really tricky! The hard part is deciding what kind of feedback you want to give when the student gives too many, or not enough, or duplicated answers.

The custom constants should be all you need to use j instead of i. Can you give me a link to your question where it doesn't work?

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/d1372b30-e3ab-427d-a25a-2ebcef8e0f5an%40googlegroups.com.

Martin Jones

unread,
May 26, 2022, 9:57:26 AM5/26/22
to Numbas Users
number + number*i would be a good start. I will bring up a+jb later!

Would the logic for a set of answers be similar to the logic for the "choose several from a list" question type? Except for duplicated answers, the student can tick too many or not enough answers, and the current options are sufficient in that question type.

I have created an issue at https://github.com/numbas/Numbas/issues/914 relating to a constant j.

Christian Lawson-Perfect

unread,
May 26, 2022, 10:37:08 AM5/26/22
to numbas...@googlegroups.com
Don't get me started on the "choose several from a list" type! It's got loads of options already, and quite often it's used incorrectly anyway. I really want to produce unsurprising, if not completely accurate, results when parts aren't configured completely correctly.

Reply all
Reply to author
Forward
0 new messages