abstract mathematical expressions

14 views
Skip to first unread message

Will Morgan

unread,
Jul 16, 2025, 6:26:30 AMJul 16
to numbas...@googlegroups.com
Hi,

Hoping to get a little bit of advice using the variable type "abstract mathematical expression". I would like to create a variable where the coefficients of certain terms are randomised. I thought I could do this by having a variable called "k" (for example) that is just a random number from a range that I then called in the definition of the mathematical expression using either {k} or \var{k} but neither works. Is what I am trying to do possible?

Cheers,

Dr Will Morgan
Academic Skills Adviser (Maths)
301 Academic Skills Centre
Student & Academic Services
University of Sheffield
301 Glossop Road
Sheffield, S10 2HL

https://www.sheffield.ac.uk/mash
https://www.sheffield.ac.uk/academic-skills

My working days are Tuesday  (9am-6pm), Wednesday (8:30am-3pm) and Thursday (9am-4pm).

Christian Lawson-Perfect

unread,
Jul 16, 2025, 7:46:25 AMJul 16
to numbas...@googlegroups.com
Hi Will,
Curly braces should work. Could you give me a link to your question where it doesn't work?
I've made an example question showing two methods of substituting into an expression: https://numbas.mathcentre.ac.uk/question/177218/substitute-random-values-into-an-expression-variab/
The most robust way of substituting values into an expression variable is using the substitute function. See the documentation at https://docs.numbas.org.uk/en/latest/jme-reference.html#substitute.

--
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, visit https://groups.google.com/d/msgid/numbas-users/CAPLtq3r1PmR%3DbRxQETnnNvPUs4CEk%3DhyyyGjaHS9J1N-DcadRA%40mail.gmail.com.

Will Morgan

unread,
Jul 17, 2025, 4:37:50 AMJul 17
to numbas...@googlegroups.com
Thank you! Your example explained exactly what I was doing wrong. I wasn't aware of the "substitute" function.
 
Cheers,

Will


Reply all
Reply to author
Forward
0 new messages