How to match functions in mathematical expressions

Skip to first unread message

Chris Jobling

May 2, 2021, 4:20:02 AMMay 2
to Numbas Users
This has had me pulling my hair out!

I am writing questions on the Fourier transform which uses the Dirac delta function \delta(t) and \delta(\omega).

If I use math expression and have a question something like:

Q: What is the inverse Fourier transform of the unit step function?

A: 2pi*delta(omega) - 2i/omega

The prompt and feedback that students see is nicely formatted as
latex("2\pi\delta(\omega) - \frac{2i}{\omega}")

But the marking algorithm complains that delta looks like a multi character function but is not defined. Even if I change this to d(omega) I get a complaint about the function d(...) not being defined.

Is there a way to incorporate arbitrarily named functions in mathematical expressions?


Chris Jobling
Swansea University

Christian Lawson-Perfect

May 2, 2021, 10:30:32 AMMay 2
Hi Chris,
The standard marking algorithm for mathematical expression parts establishes whether the student's answer is equivalent to the expected answer by evaluating them both on a randomly selected set of values for the free variables. If there are any undefined functions in either expression, this can't be done.
Occasionally it makes sense to just not do this check, for expressions where you want the answer in a very specific format, but the other way to get round it is to define the function. You could define delta(x) as a custom function in the question, and then the marking would 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
To view this discussion on the web, visit

Chris Jobling

May 3, 2021, 7:58:06 AMMay 3
to Numbas Users
Thanks Christian. That's great and clarifies the workings of mathematical expressions for me. I was sure that there must be a way to define new functions, but completely overlooked Extensions -> functions.

Another quick off-topic question, can j be used for the imaginary number i?  And does I have to be in the numerator of an imaginary fraction? I've tried to enter 1/(iomega) [or 1/(jomega as we electrical engineers usually write it] but couldn't get the marker to mark it properly.

Christian Lawson-Perfect

May 4, 2021, 6:06:45 AMMay 4
You can't use j as the imaginary unit at the moment. I have an open issue about this at
You're missing a multiplication symbol in your example. 1/(i*omega) would work. If you want to allow students to omit the multiplication symbol, or even a space, you could tick the box "Force single-letter variable names?" in the Restrictions tab - see

Reply all
Reply to author
0 new messages