## WeBWorK Problems

### Simplified Radicals with MathQuill

by Brittni Lorton -
Number of replies: 2

I am stumped on a problem I am attempting to author.

The issue is with MathQuill and the use of radicals that aren’t square roots. The intention is to require students to enter a single simplified radical as their answer. The problem is that the radical button in the MathQuill panel is read as a fractional exponent to WeBWorK, i.e. sqrt[3]{x} is read as x^(1/3).

This means that if we want to require a student to simplify by using Context(“LimitedRadical”) then students cannot use the pretty radical box from MathQuill since WW reads that as a fractional exponent even though it displays as a radical.

We can do that if we use the parserRoot.pl (as in the code example below) and then a student would have to select the textbox from MathQuill panel and then type root(3,x) to mean the cubed root of x.

What I want is to find a way to have students be required to enter a simplified radical, such as in LimitedRadical, but that they can use the MathQuill panel as well.

Any insight would be great, thanks!

#Add or Subtract Radicals

# ENDDESCRIPTION

## DBsubject()

## DBchapter()

## DBsection()

## Institution()

## Author(Brittni Lorton)

## Date(November 2020)

## KEYWORDS()

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

"contextFraction.pl",

"contextLimitedRadical.pl",

"PGcourse.pl",

"parserRoot.pl",

);

######################################

#below will force students to simplify and will only work if the student first select the text box from MathQuill and then types root(n,x) for their radical answer.

Context("LimitedRadical");

$ans1 = Formula("root(3,x)");$ans2 = Formula("2root(3,5)");

#below will not force the student to simplify but will allow students to use the 'regular' radical selection from the MathQuill panel.

Context("Numeric");

$ans3 = Formula("x^(1/3)");$ans4 = Formula("2*5^(1/3)");

BEGIN_PGML

Simplify each expression. Write as a single, simplified radical.

[-3\sqrt[3]{x}+4\sqrt[3]{x} = ][_______________]{$ans1} [-3\sqrt[3]{5}+\frac{5}{2}\sqrt[3]{40} = ][_______________]{$ans2}

[-3\sqrt[3]{x}+4\sqrt[3]{x} = ][_______________]{$ans3} [-3\sqrt[3]{5}+\frac{5}{2}\sqrt[3]{40} = ][_______________]{$ans4}

END_PGML

######################################

ENDDOCUMENT();

In reply to Brittni Lorton

### Re: Simplified Radicals with MathQuill

by Glenn Rice -
Add the cmp option
mathQuillOpts => "rootsAreExponents: false"
to the answers to have MathQuill keep the answers in radical form.
So for instance, change
[-3\sqrt[3]{x}+4\sqrt[3]{x} = ][_______________]{$ans1} to [-3\sqrt[3]{x}+4\sqrt[3]{x} = ][_______________]{$ans1->cmp(mathQuillOpts => "rootsAreExponents: false")}
In reply to Glenn Rice

### Re: Simplified Radicals with MathQuill

by Brittni Lorton -

Brilliant. This works exactly as I was hoping it would. Thank you!