Error multiplying functions

4 views
Skip to first unread message

Martin Jones

unread,
May 18, 2023, 7:28:41 AM5/18/23
to Numbas Users
I have been using the expression command to create randomised algebraic expressions. But it doesn't behave correctly in the way I expect expressions to work.

For example f is defined expression(2+"t+"+5) then it shows as 2t+5 as expected.

But if I try to evaluate t*{f} or t*({f}) then the answer is 2t^2+5 instead of 2t^2+5t.


Thanks.

Timur Zaripov

unread,
May 19, 2023, 10:19:55 AM5/19/23
to numbas...@googlegroups.com
Dear Martin,

Not sure is by design, but what happens is more like a string substitution, where {f} is replaced by expression f, rather then algebraic substitutions, where {f} is replaced by expression (f).

As a workaround you could use t*({f}) which will do what you expect.

With best regards,
Timur Zaripov.

--
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/06853777-2991-449e-95df-b5afe8974eedn%40googlegroups.com.

Martin Jones

unread,
May 19, 2023, 10:26:00 AM5/19/23
to Numbas Users
Hi Timur,
I did try using t*({f}) and the result is the same.
Martin

Timur Zaripov

unread,
May 19, 2023, 10:35:15 AM5/19/23
to numbas...@googlegroups.com
Dear Martin,

I get the result shown in screenshot below:
SCR-20230519-ntea-2.png

I have given you access to my test question to see if we do anything differently.

With best regards,
Timur Zaripov.

Christian Lawson-Perfect

unread,
May 22, 2023, 4:29:25 AM5/22/23
to numbas...@googlegroups.com
I think this is a bug, sorry! I'll see try to fix it now.

Timur: Martin put "t*({f})" in the expected answer field for a mathematical expression part. Fortunately, it looks like your method of defining another variable would do as a work-around for now.

And I need to find out why there seem to be two different methods of substituting into expressions!

Martin Jones

unread,
May 22, 2023, 4:39:21 AM5/22/23
to Numbas Users
Christian,
We have a few tests in https://numbas.mathcentre.ac.uk/question/142579/substitution-test/ some of which work and some don't. May help with your diagnosis.
Martin

Christian Lawson-Perfect

unread,
May 22, 2023, 6:05:11 AM5/22/23
to numbas...@googlegroups.com
I think I've now fixed this. Thanks for the useful test cases!

Martin Jones

unread,
May 22, 2023, 6:12:34 AM5/22/23
to Numbas Users
Thanks, that is indeed looking better.

There is just perhaps the puzzling preview that appears in the marking settings:
Screenshot 2023-05-22 111123.png

Christian Lawson-Perfect

unread,
May 22, 2023, 6:13:41 AM5/22/23
to numbas...@googlegroups.com
Can you try reloading the page? I think MathJax has failed to load for you. It looks OK on my PC.

Reply all
Reply to author
Forward
0 new messages