Hello,
This is another feature request for the Formulas question type.
We have the function diff that allows to tell whether 2 expressions agree. But this is not sufficient in some contexts.
The php code is able to evaluate an expression after giving values to the variables. So it would be helpful to have access to this method.
Here is what I have in mind:
Input: expression, name of variable, list of values for variable [,name of other variable, other list of values of same size]
Output: list of values obtained after evaluation of the expression after substituting the variable by their values.
Example:
evaluate("2x+1","x",[0,1,2]) would return [ 1, 3, 5]
evaluate("2x+y","x",[0,1,2],"y", [-1,-1,1]) would return [ -1, 1, 5]
I may try to propose some code if I find time... and if you think this is appropriate (in particular, does the syntax look ok?)
_____
Applications I have in mind:
Question: Give a cartesion equation of the plane generated by the vectors [1,2,-3],[1,0,-1].
Possible answers: x+y+z , or more generally ax+ay+az (so there is no uniqueness of the answer).
I can ask for the coefficients in front of x,y,z, but if I want the student to gives the answer in the form of an expression, I need to evaluate this expression...