Is it possible to create a (graphical) interface with Mathematica so that instead of having a Mathematica document where I change definitions and so on, I can just input values and it will use my code to compute things and display the results?

This would be helpful in an exam situation, where one is time-pressed. It is allowed in my situation (I have asked).

I am going to use this myself for my own written exams.


I input a function and it computes the partial derivatives, gradient and directional derivative.

If you have other ideas, please tell me!


Please continue telling about your exam workflow/interface/ideas, even though I have accepted an answer!

  • $\begingroup$ This seems ideally suited for the Computable Document Format $\endgroup$
    – Jason B.
    Commented Jan 8, 2016 at 14:50
  • $\begingroup$ @JasonB That seems promising. I need several sections for computing different things. $\endgroup$
    – macurie
    Commented Jan 8, 2016 at 14:52
  • $\begingroup$ How much do you need to lock it down? You could just put all your code into a cell that is not open, not editable, and has the property of being an initialization cell, so that it is evaluated as soon as any other cell in the notebook is evaluated. But, I think if they wanted to, they could click on the cell icon on the right, seen here: i.imgur.com/e6tlqOp.png, and make it editable and open. $\endgroup$
    – Jason B.
    Commented Jan 8, 2016 at 14:57
  • $\begingroup$ @JasonB If you mean "obfuscate" by "lock down" I don't need to lock it down at all, what matters is that it's practical and fast to use. $\endgroup$
    – macurie
    Commented Jan 8, 2016 at 15:03
  • $\begingroup$ This and this and this can help on how to hide cells and use a regular notebook in making a test - but if they go looking they will always be able to find the underlying code, I don't see how to password protect the code. $\endgroup$
    – Jason B.
    Commented Jan 8, 2016 at 15:04

1 Answer 1


You could take some code like this (with a nod to this answer)

 resultlabels = (Subscript["\[PartialD]", ToString@#] & /@ varlist)~
 results = (D[f, #] & /@ varlist)~Join~{Grad[f, varlist]};
    ConstantArray["f =", Length@varlist + 1],
 {{f, x^3 Sin[x - y], "f="}, InputField},
 {{varlist, {x, y}, "Variables"}, InputField}, {{update, 0}, None}, 
 Button["update", update++], TrackedSymbols :> {update}

Then click on the cell brackets beside it, go to Cell Propterties and uncheck "Open" and check "Initialization Cell"

Next, put some cell at the top where they enter their name or something, save it.

When they open it, it will look like this: enter image description here

Have them enter their name and hit Shift+Enter, this will pop up,

enter image description here

Hit Yes, and then you see the Dynamic object,

enter image description here

You can do whatever you like in the Dynamic, there are plenty of cool examples around.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.