In this trimmed down question (to illustrate the issue), I've created the same function "5x^(2/3) if x>2 else 5x^(4/5)" four different ways (labeled g1-g4).
Only g2 displays the function correctly with fractional exponents.
It looks like g1 receives the two functions created in Context("Fractions") as
"5x^2/3 if x>2 else 5x^4/5" - which is how BOTH g1 and g2 display if included as text.
g3 and g4 display the same - with decimal exponents.
So it seems like g2 is the best choice - it reports "5x^2/3 if x>2 else 5x^4/5" as wrong, BUT "5x^(2/3) if x>2 else 5x^(4/5)" give a warning Formulas from different contexts can't be compared.
## DBsubject(Algebra)
## DBchapter(Functions)
## DBsection(Piecewise functions)
## Institution(UWEC)
## Author(Andrew Swanson)
## MO(1)
## TitleText1()
## AuthorText3()
## EditionText3()
## Section1()
## KEYWORDS('functions','piecewise functions')
####################################
# Initialization
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"contextFraction.pl",
"contextPiecewiseFunction.pl",
"PGcourse.pl",
);
TEXT(beginproblem());
Context("Fraction");
# Set up two functions with fractional exponents for the two regions
$f1 = Compute("5x^(2/3)");
$f2 = Compute("5x^(4/5)");
Context("PiecewiseFunction");
#These should be the same function
$g1 = PiecewiseFunction("$f1 if x>2 else $f2");
$g2 = PiecewiseFunction("x>2"=>$f1, $f2);
#As should these
$g3 = PiecewiseFunction("5x^(2/3) if x>2 else 5x^(4/5)");
$g4 = PiecewiseFunction("x>2" => "5x^(2/3)", "5x^(4/5)");
#NOTE: Piecewise functions look better as TeX equations [` `] than as calculator equations [: :] in PGML
BEGIN_PGML
Here are some piecewise functions:
[` g_1(x) = [$g1]`] written [$g1]
[` g_2(x) = [$g2]`] written [$g2]
[` g_3(x) = [$g3]`] written [$g3]
[` g_4(x) = [$g4]`] written [$g4]
Enter function [:g_1:] here: [:g_1(x)=:] [_______________________________]{$g1}
Enter function [:g_2:] here: [:g_2(x)=:] [_______________________________]{$g2}
Enter function [:g_3:] here: [:g_3(x)=:] [_______________________________]{$g3}
Enter function [:g_4:] here: [:g_4(x)=:] [_______________________________]{$g4}
END_PGML
ENDDOCUMENT();