## WeBWorK Problems by tim Payer -
Number of replies: 0
Hello Again,

I have tried your suggestion of using unicode characters instead of Latex code in
PopUp( ) answers, But I am running into some big problems.

Either my execution is wrong or perhaps version 10 does not handle unicode very well?

Any pointers would be much appreciated.

The block of code is below and the errors are removed if I take the unicode characters out.

# DESCRIPTION  11
# Probability
# WeBWorK problem written by Tim payer, <tsp1@humboldt.edu>
# ENDDESCRIPTION

## DBsubject(Probability)
## DBchapter(??)
## DBsection(??)
## Institution(Humboldt State University)
## Author(Tim Payer)

DOCUMENT();
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserFormulaUpToConstant.pl",
"niceTables.pl",
"PGunion.pl",
"parserPopUp.pl",
);

Context("Numeric");
Context()->flags->set(
tolerance => 0.0001,
tolType => "absolute",
);

# \{row("Income $", @z)\} # Table data generation: # To switch off the algorithmic table data un-comment the following 5 lines: # and then Comment (#) the random assignments. #$r = 12;
# $u = 150; #$m = 200;
# $l = 200; #$p = 50;
$r = random(12, 18,1);$r = $r + 50;$r = $r*10 + 6;$r = $r*30 - 7;$r = $r*55 + 22;$rsum = $r+$r+$r+$r+$r;$u = random(121, 161,1);
$u =$u + 121;
$u =$u*4 + 6;
$u =$u*17 - 7;
$u =$u*5 + 22;
$usum =$u+$u+$u+$u+$u;

$m = random(191, 211,1);$m = $m*4 + 22;$m = $m*10 + 17;$m = $m*6 - 24;$m = $m*2 + 51;$msum = $m+$m+$m+$m+$m;$l = random(181, 213,2);
$l =$l*2 + 89;
$l =$l*3 + 17;
$l =$l*10 + 24;
$l =$l*3 + 51;
$lsum =$l+$l+$l+$l+$l;

$p = random(41, 58,1);$p = $p + 22;$p = $p*2 + 17;$p = $p*3 - 15;$p = $p*6 + 51;$psum = $p+$p+$p+$p+$p; # Column sums:$c0 = $p+$l+$m+$u+$r;$c1 = $p+$l+$m+$u+$r;$c2 = $p+$l+$m+$u+$r;$c3 = $p+$l+$m+$u+$r;$c4 = $p+$l+$m+$u+$r;$grand = $c0+$c1+$c2+$c3+$c4 +$psum+$lsum+$msum+$usum+$rsum;

$popup1 = PopUp( ["probability notation", "P(86-88)", "P(A)", "P(B)", "P(C)", "P(D)","P(E)"], "P(B)");$ans1 =$c1/$grand;

$popup2 = PopUp( ["probability notation", "P(B U F)", "P(BF)", "P(B ~~x{2229} F)", "P(B + F)", "P(B x F)"], "P(B ~~x{2229} F)");$ans2 =$p/$grand;

# Apparently the unicode wont work here?  "~~x{2229}" wont render

BEGIN_TEXT

$PAR 4.2) Recent census data has correlated life expectancy with one's income bracket.$BR
Given a small town of $$grand$$ individuals, that is loosely based upon the US census data, determine the following probabilities using correct probability notation. Answer with fourth decimal accuracy and use the event variables declared below:
$PAR Where:$BR
$PAR$BLEFT
\{ begintable(7) \}
\{ row( "Life Expectancy", "89-95", "86-88", "81-85","77-80","74-76" ,"Row Sums") \}
\{ row( "Rich:", $r,$r,$r,$r, $r,$rsum ) \}
\{ row( "Upper Middle Class", $u,$u,$u,$u, $u,$usum) \}
\{ row( "Middle Class", $m,$m,$m,$m, $m,$msum) \}
\{ row( "Lower Middle Class", $l,$l,$l,$l, $l,$lsum) \}
\{ row( "Poor", $p,$p,$p,$p, $p,$psum) \}
\{ row( "Column Sums:", $c0,$c1,$c2,$c3, $c4,$grand) \}
\{ endtable() \}
$ELEFT$PAR
$$A$$ = Event that an individual has a life expectancy of 89 - 95 years. $BR $$B$$ = Event that an individual has a life expectancy of 86 - 88 years.$BR
$$C$$ = Event that an individual has a life expectancy of 81 - 85 years. $BR $$D$$ = Event that an individual has a life expectancy of 77 - 80 years.$BR
$$E$$ = Event that an individual has a life expectancy of 75 - 76 years. $BR $$R$$ = Event that an individual is rich.$BR
$$S$$ = Event that an individual of the upper middle class $BR $$M$$ = Event that an individual is of the middle class.$BR
$$L$$ = Event that an individual is of the lower middle class.$BR $$F$$ = Event that an individual is poor.$BR
END_TEXT

BEGIN_PGML

4.2a)  Find the probability of drawing an individual from the town that has a life expectancy of 86-88 years:

[_____]{$popup1} = [______]{$ans1}

4.2b)  Find the probability of drawing an individual from the town that has a life expectancy of 86-88 years and is poor:

[_____]{$popup2} = [______]{$ans2}

END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*
To simplify the expression to a single term with a rational denominator we first start by splitting the root between the numerator and denominator. Then find a common denominator and rationalize the denominator.

[\begin{aligned}&\\
[$c]-\sqrt{\frac{[$am] x}{[$bm]}} &=[$c] -\sqrt{\frac{[$m]\cdot[$a] x}{[$m]\cdot[$b]}} = [$c] -\frac{\sqrt{[$a] x}}{\sqrt{[$b]}} && \text{Cancel the common factor and then split the root.}\\ &=\frac{[$c]\sqrt{[$b]}}{ \sqrt{[$b]}}-\frac{\sqrt{[$a] x}}{\sqrt{[$b]}} && \text{Create a common denominator.}\\
&=\frac{[$c]\sqrt{[$b]} -\sqrt{[$a] x}}{\sqrt{[$b]}} && \text{Combine in to a single fraction.}\\
&=\frac{\left([$c]\sqrt{[$b]} -\sqrt{[$a] x}\right)\sqrt{[$b]}}{\sqrt{[$b]}\cdot\sqrt{[$b]}} && \text{Multiply the numerator and denominator by the denominator.}\\
&=\frac{\left([$c]\sqrt{[$b]\cdot [$b]}-\sqrt{[$a] \cdot [$b] x}\right)}{[$b]} && \text{Distribute through the numerator and reduce the denominator.}\\
&=\frac{\left([$c] \cdot [$b] -\sqrt{[$ab] x}\right)}{[$b]} && \text{Reduce the square root factors.}\\
&=\frac{[$cb] - \sqrt{[$ab] x}}{[\$b]} && \text{Combine numerator factors.}
\end{aligned}]

END_PGML_SOLUTION

ENDDOCUMENT();