### Re: Specifying occurrences of character in answer

by Bruce Yoshiwara -### Re: Specifying occurrences of character in answer

by Alex Jordan -Well, your timing is interesting. I see that behavior too, and something is broken. Meanwhile, an instructor here is writing that a batch of problems that use bizarroArithmetic suddenly no longer work (after years of behaving well).

With the last upgrade of WW, there was a lot of "perl warnings cleanup". Right now I suspect something about that hurt bizarro. Tonight I will investigate, and hopefully have it all sorted out by the end of the weekend.

Point is, bizarro is supposed to work as you've tried and I outlined. And it has worked that way for a while up until seemingly recently. So hang tight.

Alex

### Re: Specifying occurrences of character in answer

by Alex Jordan -*your*example is the sequence you are executing the commands. This block:

Context()->operators->set(

'**' => {class => 'bizarro::BOP::power', isCommand => 1, perl=>undef},

'^' => {class => 'bizarro::BOP::power', isCommand => 1, perl=>undef},

);

Needs to happen

*before*you define any Math Objects for the context. In this case, $g[0].

Now, as it turns out (and I often forget when dealing with bizarro), since your problem is about exponents, it is the

*other*relevant things that should get bizarro treatment. In this case, division. Here is what I believe to be a working version of your example. Again, note that I moved the operator settings up earlier. And I've included the custom answer checker. Also I changed the macros you loaded to what I would go with, but maybe you need the originals for what goes on with the full version of the problem.

##DESCRIPTION

## Algebra problem: Rational exponents--incubation time vs mass of egg

##ENDDESCRIPTION

##KEYWORDS('algebra', 'root', 'radical', 'exponent', 'allometry')

## DBsubject(Algebra)

## DBchapter(Functions)

## DBsection(Roots and Radicals)

## Date('2/4/2018')

## Author('Yoshiwara')

## Institution('')

## TitleText1('Modeling, Functions, and Graphs')

## EditionText1('5')

## AuthorText1('Yoshiwara')

## Section1('3.4')

## Problem1('43')

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

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"PGML.pl",

"bizarroArithmetic.pl",

);

TEXT(beginproblem());

Context("Numeric");

Context()->flags->set(reduceConstants=>0);

Context()->flags->set(limits=>[1,10]);

Context()->operators->set(

'/' => {class => 'bizarro::BOP::divide', isCommand => 1},

);

$f[0] = "-x^(1/3) / (x^(5/3)) ";

$f_display[0] = " \dfrac{ - x^{1/3}}{ x^{5/3} }";

$g[0] = Formula(" -1/x^(4/3) " );

BEGIN_PGML

a.

[` [$f_display[0]] =`][__________]

END_PGML

ANS($g[0] -> cmp(

checker=>sub{

my ( $correct, $student, $ansHash ) = @_;

return 0 if $ansHash->{isPreview} || $correct != $student;

$student = $ansHash->{student_formula};

$correct = $correct->{original_formula} if defined $correct->{original_formula};

$student = Formula("$student"); $correct = Formula("$correct");

return 0 unless ($correct == $student);

Context()->flags->set(bizarroDiv=>1);

delete $correct->{test_values};

delete $student->{test_values};

my $OK = (($correct == $student) or ($student == $correct));

Context()->flags->set(bizarroDiv=>0);

Value::Error("Your answer is correct, but please simplify it further") unless $OK;

return $OK;

}));

ENDDOCUMENT();

If you are writing this in PTX source, you wnat to put the following in your pg-code element at the end:

$evaluator[0] = $g[0] -> cmp(

checker=>sub{

my ( $correct, $student, $ansHash ) = @_;

return 0 if $ansHash->{isPreview} || $correct != $student;

$student = $ansHash->{student_formula};

$correct = $correct->{original_formula} if defined $correct->{original_formula};

$student = Formula("$student"); $correct = Formula("$correct");

return 0 unless ($correct == $student);

Context()->flags->set(bizarroDiv=>1);

delete $correct->{test_values};

delete $student->{test_values};

my $OK = (($correct == $student) or ($student == $correct));

Context()->flags->set(bizarroDiv=>0);

Value::Error("Your answer is correct, but please simplify it further") unless $OK;

return $OK;

});

And then in the statement, where you put the answer blank, put it like:

var name="$g[0]" evaluator="$evaluator[0]" width="15"

(with surrounding tag marks which I omit here because this forum eats them up and I don't know how to escape that here.)

### Re: Specifying occurrences of character in answer

by Bruce Yoshiwara -### Re: Specifying occurrences of character in answer

by Alex Jordan -Since x^(-4) is equal to 1/x^4 for regular arithmetic, a submitted answer of x^(-4) passes the first bar in the answer checker.

Since x^(-4) is not equal to 1/x^4 for bizarro arithmetic, a submitted answer of x^(-4) does not pass the second bar, and you get a special feedback message that the answer is numerically correct, but not in the required form.

Meanwhile, a submitted answer of 1/x^4 passes both bars.

You might get "correct" results for things like 1/((x^-4)^(-1)) though, and at the moment I think you have to live with that. Unfortunately just turning on bizarro ^ in addition to / will not help. The bizarro operations are a consistent field structure on R. So if you have both bizarro ^ and bizarro / turned on, then 1/x is equal to x^(-1).

But you could alter the custom checker to just turn on one, then try again with the other. And to get credit, the expression would have to pass three filters instead of just the two in the demonstration.

### Re: Specifying occurrences of character in answer

by Bruce Yoshiwara -### Re: Specifying occurrences of character in answer

by Alex Jordan -One thing: your custom checker should set bizarroPow to 0 at the end, not to 1. (Copy-paste error no doubt.) In this example here it is irrelevant. But if you use this as a template and have code that follows the answer checker, you would want that flag to have gone back to 0.

Next thing: I removed all the bizarroPow from your example (two places in the checker, and the two lines in the preamble), and it rejected -x^(-4/3) as "Your answer is equivalent, but please use the proper format". So either our systems are behaving differently (quite possible if we are on different branches) or something else was off with what you tried before.

Last thing: I'm confused why with both bizarroDiv and bizarroPow in play, that it rejects -x^(-4/3). But I confirm seeing that same behavior. If you try again and things work out without using bizarroPow, my recommendation would be to remove it. Only because if I investigate and there is something about bizarro that is inconsistent with how it is supposed to behave, I may "fix" that one day, inadvertently breaking your problems.