Trouble displaying function expressions inputted by student

This CL correctly creates a simpleFunction when the student enters “N(m)=2m+1” or “2m+1”. in the first case, the RHS is properly displayed as a pointLabel, but when just the RHS is entered, parseEquation(fun).rhs doesn’t work and “undefined” is shown at the end of the pointLabel.

fun=FormulaInput.latex
function(`N`): simpleFunction(fun,"m")
expression=parseEquation(fun).rhs
number(`n`): FormulaGraph.number(`n_{fun}`)

nn=FormulaGraph.number(`n`)
mm=FormulaGraph.number(`m_{0}`)
pointLabel("R_ule"): "`CircularRule(k)``=``${mm}k````mod````${nn}`"
pointLabel(`n_funLabel`): "`n = ${nn}````(n=${expression})`"

Thanks

You can use isDefined to intercept this - so something like

pointLabel(...): when isDefined(expression) ".....${expression}" otherwise "....${fun}"
2 Likes

Essentially you can’t parse an equation that doesn’t exist, which is why you get undefined when just the expression is entered; thus @pirsquared’s solution.