More notation?!

7 views
Skip to first unread message

svda...@gmail.com

unread,
Sep 6, 2021, 1:09:13 PMSep 6
to Numbas Users
Hi all,

Anyone know a good way to include scalar and vector products in a mathematical expression answer? 

E.g. if I am asking about the acceleration of a charged particle moving in a magnetic field, the answer might be (q/m)*(vec:v x vec:B) where 'x' is a cross/vector product. 

I've seen plenty of examples for evaluating the components of a vector product, or the value of a scale product. Just none where the answer is expressed as a product. 

[cross(vec:v, vec:B) is a valid JME expression. But this is not a valid mathematical expression for a gap fill answer.]

Cheers,

Simon

Christian Lawson-Perfect

unread,
Sep 7, 2021, 8:09:10 AMSep 7
to numbas...@googlegroups.com
Can you explain what you mean by "this is not a valid mathematical expression for a gap fill answer"?
I've just made a question with a mathematical expression part whose answer is "cross(vec:a, vec:b)", and it looks like it works fine: https://numbas.mathcentre.ac.uk/question/share/view/8f3c0c1b-f5f8-4ce4-b3ea-db9e81c60e8f

--
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/75d97787-ee6d-479d-85ab-2c72ba58c916n%40googlegroups.com.

Simon Vaughan

unread,
Sep 7, 2021, 12:21:31 PMSep 7
to numbas...@googlegroups.com
HI Christian,

Thanks. Ok, that worked easier than I thought. 

I had previously tried dot( , ) and cross( , ) in a gap fill just to see if they parsed. E.g. I put 'dot(vec:a, vec:b)' or cross(vec:a, vec:b)' into a box expecting 'x^2' and got the error 'Your answer is not a valid mathematical expression. No definition of 'dot' of correct type found..'. As it was marked invalid, not incorrect, I assumed there must be another convention to use. Something about setting the answer to include a cross( , ) or dot( , ) must ensure these get recognised. 

Cheers,

Simon



--
Cheers,

Simon

Christian Lawson-Perfect

unread,
Sep 8, 2021, 3:29:18 AMSep 8
to numbas...@googlegroups.com
Ah, the problem is that Numbas has to pick a type for the free variables in the answer, in order to do the numerical comparison. It uses the expected answer for this, so when it's 'x^2', vec:a and vec:b aren't used, so it uses the default type: real number. I suppose that it could use the annotation as a hint!
I think we need to show a more useful error message. Adding a bit to explain the type of the free variables would help the question author, e.g. "No definition of 'dot' of correct type found; The variables are interpreted as: vec:a - number; vec:b - number.". That's too technical for a student though.

I thought I already had an open issue on GitHub about error messages produced by the mathematical expression part, but apparently not. I've made one now: https://github.com/numbas/Numbas/issues/848. I'd really like to improve them, because I think it's an important part of the student's interaction with Numbas.

Reply all
Reply to author
Forward
0 new messages