I am making a Django App that is using Sympy.
Basically users need to be able to do calculations. I don't know how to give them access to shell type commands and it doesn't seem safe to do so.
So I've made a sort of markup language that I parse.
INTEGRATE( x ^ 2 + 2, x ) for example will be parsed. An Expression Tree is made where the node is basically just filled with the Sympy results.
I do NOT currently make an Expression Tree for what is inside a function such as INTEGRATE.
As I build out more and more Algebra, PreCalc, Calc 1 2 3, etc, type questions, I start finding edge cases.
Currently the system can easily handle many things, including Double Definite Integrals as long as the bounds are like infinity, 0, 5, 2PI.
But once I have a bound such as SQRT(x + 2) things go bonkers. Sin Cos etc seem solid though.
Another problem is the system can properly solve things like Integrals that take and send e / EXP etc.
However when checking the student answer, it will mark the answer as incorrect when it is correct.
Finally, another I ran in to last night, is trying to get students to change LN(7/5) to LN(7) - LN(5). I don't yet have a good way to see if their answer is equal to the correct answer.
Then even things like "Change to a+bi form: (2+3i)(7-2i)", well in this case the student can literally copy the question mathy text, paste it in as the answer, and get it correct!
Background out of the way - Direct Questions - Please explain like I'm 5, I'm ME/AE not CS
1) What considerations do I need to make with Sympify and Eval?
sympy.integrate( sympify( {user_input_string} ), {variable} )
The incoming string is manipulated to clean user mathy input. For example "the text" would be turned into "the*text". I know Eval in general is a security issue.
2) Good/safe way to create instances of Django models incorporating a sort of Sympy Shell in browser? I doubt it but worth asking just in case.
3) Good intuitive way to handle my SQRT problem? I've read real=True positive=True type arguments can help.
I don't know of a good way to get a user to straight up make a sympy.sqrt(), put in all needed arguments, etc, in a intuitive way.
4) Know what might be the issue with answers never coming out as correct when they involve things like (E - 1) * exp(-1) etc?
Thanks for any help!
Keith