WeBWorK Problems

Parenthesis disappearing in Formula class

Re: Parenthesis disappearing in Formula class

by Davide Cervone -
Number of replies: 0

> The other method was creating the extra parenthesis for negative numbers (-(f(x+c)) format)

You can change that using

Context()->operators->set(fn => {parenPrecedence => 6.5});

If you want students to be able to provide answers that include function like f(x), then you probably want to use parserFunction.pl to define the function so that it can be used in student answers. For example

parserFunction(f => "sqrt(sin(3x) + 1)");

Use a function that is unlikely to be something they student will enter by accident.

You may need to set

  reduceConstantFunctions => 0,
  formatStudentAnswer => 'parsed'

so that the student's answer will not produce a strange-looking number if they enter something like f(3).