simplify not working properly with complex numbers

14 views
Skip to first unread message

Julia Goedecke

unread,
Jun 15, 2022, 4:26:35 AM6/15/22
to Numbas Users
Hello,
I have searched through the back catalogue of numbas-users emails, but
not found what I'm looking for (I have the vague memory of seeing it
before, but perhaps I've just come across a similar problem before)

When I use simplify with some complex number variables in an expression,
the "minus" signs are not resolved properly so I get things like - -2i z.

Has anyone come across this before and knows a workaround?

Julia
--
www.julia-goedecke.de

Ben Brawn

unread,
Jun 16, 2022, 3:08:47 AM6/16/22
to Numbas Users
This sounds like something Christian would want to see an example of in a question. I haven't heard or seen the double negative thing before.

Julia Goedecke

unread,
Jun 23, 2022, 10:08:12 AM6/23/22
to numbas...@googlegroups.com
Hello,
I have made a question which demonstrates the problem and a possible
workaround for some cases:

https://numbas.mathcentre.ac.uk/question/share/view/93699eff-c5ae-418d-8eeb-2d0186261c6b

Julia
> www.julia-goedecke.de <http://www.julia-goedecke.de>
>
> --
> 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
> <mailto:numbas-users...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/numbas-users/e9cb8752-3207-4c33-836f-dc9861fffd0en%40googlegroups.com
> <https://groups.google.com/d/msgid/numbas-users/e9cb8752-3207-4c33-836f-dc9861fffd0en%40googlegroups.com?utm_medium=email&utm_source=footer>.

Christian Lawson-Perfect

unread,
Jun 23, 2022, 10:09:12 AM6/23/22
to numbas...@googlegroups.com
Thanks, Julia.
I'm sorry I haven't had time to look at this yet - the EAMS conference and stuff at Newcastle have taken up all my time this week. Hopefully I'll have a moment next week!

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/71c7e087-2cea-368d-ddd0-dda346b8d0e6%40cantab.net.

Christian Lawson-Perfect

unread,
Jun 29, 2022, 8:01:12 AM6/29/22
to numbas...@googlegroups.com
OK, I've sorted these out. The examples were very helpful, thanks Julia.

The problem was that the rule for pulling negation to the outside of a string of multiplications didn't deal with negative imaginary numbers. Complex numbers are quite finicky: they can either be represented algebraically, as an abstract expression of the form `a+b*i`, or as a single "complex number" token - typically this happens when you substitute a number into an expression.
I think I've made the right change to the simplification rules to make it deal with these cases.
Reply all
Reply to author
Forward
0 new messages