WeBWorK Problems

52 flavours of triangle problems - fyi

52 flavours of triangle problems - fyi

by Hedley Pinsent -
Number of replies: 2
52 flavours of triangle problems - FYI
The list itself is interesting.
The randomization can be improved.

Code as text file is attached: the output is controlled by @case
Regards - hp

# case 0 - LL90 pythagoras
# case 0.1 - LL90 pythagoras - small sides
# case 0.2 - LL90 pythagoras - large sides
# case 0.3 - LL90 pythagoras - scientific notation
# case 1 - HL90 pythagoras
# case 1.1 - HL90 pythagoras - small sides
# case 1.2 - HL90 pythagoras - large sides
# case 1.3 - HL90 pythagoras - scientific notation
# case 2 - LL90 solve
# case 2.1 - LL90 solve - small numbers
# case 2.2 - LL90 solve - large numbers
# case 2.3 - LL90 solve - scientific notation
# case 3 - HL90 solve
# case 3.1 - HL90 solve - small numbers
# case 3.2 - HL90 solve - large numbers
# case 3.3 - HL90 solve - scientific notation
# case 4 - AL90 solve
# case 4.1 - AL90 solve - small numbers
# case 4.2 - AL90 solve - large numbers
# case 4.3 - AL90 solve - scientific notation
# case 5 - AH90 solve
# case 5.1 - AH90 solve - small numbers
# case 5.2 - AH90 solve - large numbers
# case 5.3 - AH90 solve - scientific notation
# case 6 - sss - random largest angle
# case 6.1 - sss - random largest angle - small numbers
# case 6.2 - sss - random largest angle - large numbers
# case 6.3 - sss - random largest angle - scientific notation
# case 6.4 - sss - one angle obtuse
# case 6.5 - sss - one angle obtuse - small numbers
# case 6.6 - sss - one angle obtuse - large numbers
# case 6.7 - sss - one anngle obtuse - scientific notation
# case 7 - sas cosine law acute
# case 7.1 - sas cosine law acute small sides
# case 7.2 - sas cosine law acute large sides
# case 7.3 - sas cosine law acute scientific notation
# case 8 - sas cosine law obtuse
# case 8.1 - sas cosine law obtuse small sides
# case 8.2 - sas cosine law obtuse large sides
# case 8.3 - sas cosine law obtuse scientific notation
# case 9 - ass acute
# case 9.1 - ass acute - small sides
# case 9.2 - ass acute - large sides
# case 9.3 - ass acute - scientific notation
# case 10 - ass obtuse
# case 10.1 - ass obtuse - small sides
# case 10.2 - ass obtuse - large sides
# case 10.3 - ass obtuse - scientific notation
# case 11 - asa
# case 11.1 - asa - small sides
# case 11.2 - asa - large sides
# case 11.3 - asa - scientific notation
In reply to Hedley Pinsent

Re: 52 flavours of triangle problems - fyi

by Hedley Pinsent -
Well, here it is - version 2

In so far as the @caseList needs to be modified, to have anything practical, it is more of a "kit" than a problem.
However all the bugs are assembled in the one place

To have a mixture of pythagoras: solve for hyp/ solve for leg:

@caseList = (0,0,1,1);
@caseList = @caseList [NchooseK(scalar @caseList,scalar @caseList)];

would give 2 of each, randomized.

I have assigned from preliminary versions: no complaints yet.
However, I only have 40 math students ( and not all "cases" are addressed)
I am not scheduled to teach triangles again until next fall.

If you use it, let me know where the bugs are.

hp



## Example from here to end vvvvvvvvvvvvvvvvvvvvvvv

##DESCRIPTION
## DBsubject('Trigonometry')
## DBchapter('Triangles')
## DBsection('')
## KEYWORDS('Pythagoras', 'Law of Sines','Law of Cosines')
## Author('Hedley Pinsent')
## Institution('College of the North Atlantic')
##
## This program is more of a KIT than a problem
## To have anything practical you need to adjust the contents of "@caseList"
## After it becomes as "good as it can be" it should be split into
## more manageable, ready-to-use pieces.
##
##ENDDESCRIPTION

DOCUMENT();

loadMacros(
"PG.pl",
"PGbasicmacros.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
"PGauxiliaryFunctions.pl",
"PGgraphmacros.pl",
"PGasu.pl",
"unionTables.pl","unionMacros.pl"
);
#######################
TEXT($BEGIN_ONE_COLUMN,beginproblem()) ;
$refreshCachedImages = 1;
$showPartialCorrectAnswers = 1;
###############
# case 0 - LL90 pythagoras
# case 0.1 LL90 pythagoras - small numbers
# case 0.1 LL90 pythagoras - large numbers
# case 0.1 LL90 pythagoras - scientific notation
# case 1 - HL90 pythagoras
#etc
#
# case 2 - LL90 solve
# case 3 - HL90 solve
# case 4 - AL90 solve
# case 5 - AH90 solve
# case 6 - sss - random largest angle
# case 7 - sss - one angle obtuse
# case 8 - sas cosine law acute -random
# case 9 sas cosine law acute with unknown obtuse
# case 10 - sas cosine law - given obtuse
# case 11 - ass acute
# case 12 - ass obtuse
# case 13 - asa

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

@caseList = (0,0.1,0.2,0.3,1,2,3,4,5,6,7,8,9,10,11,12,13);
#@caseList = @caseList [NchooseK(scalar @caseList,scalar @caseList)];

$trial = 0;
$deg = "".sprintf("%c",0xb0);
@n3k = NchooseK(3,3);

foreach my $caseList (@caseList) {
# do something for each frame
$trial = $trial + 1;
$TABLEoverride = 0;

$case = @caseList[$trial - 1];
$fact =1;
$numberType = round (10* ($case - int($case)));

if ($numberType == 1){$fact = list_random (0.01,0.001,0.0001)}
if ($numberType == 2){$fact = list_random (100,1000,10000)}
if ($numberType == 3){$fact = list_random (10**30,10**31,10**-21,10**-20)}

$case = int($case);

if( scalar (@list) <2){@list = (5,6,7,8,9,10,11,12,13,14,15);
@list = @list [NchooseK(11,11)];
@list = (@list,@list[0,2,4,6,8,10,1,3,5,7,9])
}

if( scalar (@listsd) <1){@listsd = (4,5,6,7,8,9);
@listsd = @listsd [NchooseK(6,6)];
@listdd = (11,12,13,14,15,16);
@listdd = @listdd [NchooseK(6,6)];

@listsd = (@listsd, @listsd,@listsd);
@listdd = (@listdd,@listdd[1,2,3,4,5,0], @listdd[2,3,4,5,0,1])
}
if( scalar (@AcuteList) <2){@AcuteList = (20,30,40,55,65,75);
@AcuteList = @AcuteList [NchooseK(6,6)];
@AcuteList = (@AcuteList,@AcuteList[0,1,3,5,2,4])}

if( scalar (@SmallAcuteList) <2){@SmallAcuteList = (10,15,20,25,30,35);
@SmallAcuteList = @SmallAcuteList [NchooseK(6,6)];
@SmallAcuteList = (@SmallAcuteList,@SmallAcuteList[0,1,3,5,2,4])}

if( scalar (@ObtuseList) <2){@ObtuseList = (110,130,140,155 ,115,135);
@ObtuseList = @ObtuseList [NchooseK(6,6)];
@ObtuseList = (@ObtuseList,@ObtuseList[0,1,3,5,2,4])}

@listSingleDigit = (4,5,6,7,8,9);
@listDoubleDigit = (11,12,13,14,15,16);

@n3k = @n3k[1,2,0];
if($trial/3 == int($trial/3)){@n3k = @n3k[0,2,1]}

@n3k_mix_letters = NchooseK(3,3);

# Sets of labels vvvvvvvvvvvvvvvvvvvv
@Angles = ("A","B","C","W","X","Y","X","Y","Z","I","J","K");
@Sides = ("a","b","c","w","x","y","x","y","z","i","j","k");
$tmpSTART = random(0,9,3);
$AL = @Angles[$tmpSTART + $n3k_mix_letters[0]];
$LL[$n3k[0]] = $AL;
$BL = @Angles[$tmpSTART + $n3k_mix_letters[1]];
$LL[$n3k[1]] = $BL;
$CL = @Angles[$tmpSTART + $n3k_mix_letters[2]];
$LL[$n3k[2]] = $CL;
$aL = @Sides[$tmpSTART + $n3k_mix_letters[0]];
$ll[$n3k[0]] = $aL;
$bL = @Sides[$tmpSTART + $n3k_mix_letters[1]];
$ll[$n3k[1]] = $bL;
$cL = @Sides[$tmpSTART + $n3k_mix_letters[2]];
$ll[$n3k[2]] = $cL;
# Sets of labels ^^^^^^^^^^^^^^^^^^^

if ($case == 0){ ###LL90 find hyptoneuse only, large numbers

$x[1] = pop @listsd;
$X[0] = 90;
$x[2] = pop @listdd; # the other leg

$x[0] = sqrt($x[1]**2 + $x[2]**2 ); #the hypotenuse
$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact} #scale the problem

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ".sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "= ". sprintf("%G",$x[2]);

$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TableOverRide = 1;
##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);


$table .= AlignedRow(["The length of side $ll[0] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[0], tolType => "absolute", tolerance=>0.03 * $x[0] ) ;

$table .= EndTable();
}

if ($case == 1){ ###HL90 missing side only

$x[1] = pop @list;
$X[0] = 90;

$x[0] = random(int(1.2 * $x[1] + 1),int(5 * $x[1])); # the hypotenuse

$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];

$x[2] = sqrt($x[0]**2 - $x[1]**2 );

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TableOverRide = 1;
##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$table = BeginTable(spacing => 3);


$table .= AlignedRow(["The length of side $ll[2] is ",NAMED_ANS_RULE("answer".$trial,6)]);


push @namedCmp , "answer".$trial=>num_cmp( $x[2],tolType => "absolute", tolerance=>0.03 * $x[2] ) ;




$table .= EndTable();
}

if ($case == 2){ ###LL90 solve scientific notation

$x[1] = pop @listsd;
$X[0] = 90;
$x[2] = pop @listdd; # the other leg
$x[0] = sqrt($x[1]**2 + $x[2]**2 ); #the hypotenuse
$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "= ". sprintf("%G",$x[2]);
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($ll[0] => $x[0],$LL[1] => $X[1], $LL[2] => $X[2] );
}

if ($case == 3){ ###HL90 solve scientific notation

$x[1] = pop @listsd;
$X[0] = 90;

$x[0] = pop @listdd; # the hypotenuse

$X[1] = 180 / $PI * asin( $x[1] / $x[0] );
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 - $x[1]**2 );

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";

$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;

#%QA = ($LL[2] => $X[2],$LL[1] => $X[1], $ll[2] => $x[2] );

%QA = ($ll[2] => $x[2], $LL[1]=>$X[1] , $LL[2]=>$X[2]);
}

if ($case == 4){ ###as90 scientific notation

# given vvvvvvvvvvvvvvv
$x[1] = pop @list;
$X[0] = pop @AcuteList;

$X[2] = 90;
# given ^^^^^^^^^^^^^^^^^^^^^^
$X[1] = 180 - $X[0] - $X[2] ;
$x[2] = $x[1] / sin ($PI / 180 * $X[1]);
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] / sin ($PI / 180 * $X[1]);


for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=".$X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($ll[0] => $x[0],$ll[2] => $x[2], $LL[1] => $X[1] );

}

if ($case == 5){ ###ah90 -scientific notation

# given vvvvvvvvvvvvvvv
$x[1] = pop @list;
$X[0] = pop @AcuteList;

$X[1] = 90;
# given ^^^^^^^^^^^^^^^^^^^^^^

$X[2] = 180 - $X[0] - $X[1] ;
$x[2] = sin ($PI / 180 * $X[2]) * $x[1] ;
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] ;

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = " = ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = " = ".$X[1].$deg;
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = " = ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($ll[0] => $x[0],$ll[2] => $x[2], $LL[2] => $X[2] );
}
if ($case == 6){ ###sss random largest angle - scientific notation

@printtest = @list;
$x[0] = pop @list;
$x[1] = pop @list;
$x[2] = random( abs($x[0] - $x[1])+2, $x[0] + $x[1] - 2 );

#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));

$X[2] = 180 - $X[0] - $X[1] ;

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] =" = ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = " = ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = " = ". sprintf("%G",$x[2]);
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($LL[0] => $X[0],$LL[1] => $X[1], $LL[2] => $X[2] );

}

if ($case == 7){ ###sss obtuse angle - scientific notation

$x[0] = pop @list;
$x[1] = pop @list;

#forcing longest side longer than would-be hypotenuse vvvvvvvvvvvvvvvvv
$shortest = int (1.2 * sqrt ($x[0] **2 + $x[1]**2) +1);
$longest = $x[0] + $x[1] -2;
$x[2] = random ($shortest, $longest,1);
#forcing longest side longer than would-be hypotenuse ^^^^^^^^^^^^^^^^^^


#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2- $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2- $x[1]**2)/(2*$x[0]*$x[2]));

$X[2] = 180 - $X[0] - $X[1] ;
for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}


$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] =" = ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = " = ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = " = ". sprintf("%G",$x[2]);
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TableOverRide = 0;
%QA = ($LL[0] => $X[0],$LL[1] => $X[1], $LL[2] => $X[2] );


##Constructing the data table vvvvvvvvvvvvvvvvvvvvvvvvvvvvv

}
if ($case == 8){ ###sas acute angle#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = pop @list;
$x[1] = pop @list;
$X[2] = pop @AcuteList;

$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));
for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TableOverRide = 0;
%QA = ($LL[0] => $X[0],$LL[1] => $X[2], $ll[2] => $x[2]);

} #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if ($case == 9){ ###sas acute angle#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = pop @listdd;
$lower = pop @listsd;
$X[2] = pop @SmallAcuteList;

$x[1] = random( $lower, round (sqrt ($x[0]**2 - ($x[0] * $X[2]*$PI / 180)**2))-2) ;

$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));
for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];
$TableOverRide = 0;
%QA = ($LL[0] => $X[0],$LL[1] => $X[1], $ll[2] => $x[2] );
}

if ($case == 10){ ###sas obtuse ###vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

$x[0] = pop @list;
$x[1] = pop @list;
$X[2] = pop @ObtuseList;

$x[2] = sqrt ($x[0]**2 + $x[1]**2 - 2 * $x[0] * $x[1] * cos($PI / 180 * $X[2]));
#use cosine law to find angles
$X[0] = (180/$PI)*acos (( $x[1]**2 + $x[2]**2 - $x[0]**2)/(2*$x[1]*$x[2]));
$X[1] = (180/$PI)*acos (( $x[0]**2 + $x[2]**2 - $x[1]**2)/(2*$x[0]*$x[2]));
for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "";
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "= ". $X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($LL[0] => $X[0],$LL[1] => $X[1], $ll[2] => $x[2] );
} # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


if ($case == 11){ ###ass acute

$x[1] = pop @list;
$X[0] = pop @SmallAcuteList;

# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 *$x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 / $PI * asin(sin ($PI / 180 * $X[0]) / $x[0] * $x[1]);
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI / 180 * $X[2]));

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}


$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "(acute)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($LL[1] => $X[1],$LL[2] => $X[2], $ll[2] => $x[2] );
}

if ($case == 12){ ###ass obtuse

$x[1] = pop @list;
$X[0] = pop @SmallAcuteList;

# for the other given side vvvvvvvvvvv
$minLength = int( 1.1 *$x[1]* sin ($PI / 180 * $X[0]) + 1);
$maxLength = int(0.7 * $x[1]);
$x[0] = random ($minLength, $maxLength);
#for the other given side ^^^^^^^^^^^^

$X[1] = 180 - (180 / $PI) * asin(sin ($PI / 180 * $X[0]) / $x[0] * $x[1]);
$X[2] = 180 - $X[0] - $X[1];
$x[2] = sqrt($x[0]**2 + $x[1]**2 - 2 * $x[0]*$x[1] * cos($PI / 180 * $X[2]));

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "(obtuse)";
$C = $X[$n3k[2]];
$Given[2] = "";
$a = $x[$n3k[0]];
$given[0] = "= ". sprintf("%G",$x[0]);
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];

$TableOverRide = 0;
%QA = ($LL[1] => $X[1],$LL[2] => $X[2], $ll[2] => $x[2] );

}

if ($case == 13){ ###asa

# given vvvvvvvvvvvvvvv
$x[1] = pop @list;
$X[0] = pop @SmallAcuteList;

$X[2] = random(30,160 - $X[0],5);
# given ^^^^^^^^^^^^^^^^^^^^^^

$X[1] = 180 - $X[0] - $X[2] ;
$x[2] = sin ($PI / 180 * $X[2]) * $x[1] / sin ($PI / 180 * $X[1]);
$x[0] = sin ($PI / 180 * $X[0]) * $x[1] / sin ($PI / 180 * $X[1]);

for ($i = 0; $i <3; $i++) {$x[$i] *= $fact}

$A = $X[$n3k[0]];
$Given[0] = "= ". $X[0].$deg;
$B = $X[$n3k[1]];
$Given[1] = "";
$C = $X[$n3k[2]];
$Given[2] = "=".$X[2].$deg;
$a = $x[$n3k[0]];
$given[0] = "";
$b = $x[$n3k[1]];
$given[1] = "= ". sprintf("%G",$x[1]);
$c = $x[$n3k[2]];
$given[2] = "";
$Alabel = $AL.$Given[$n3k[0]];
$Blabel = $BL.$Given[$n3k[1]];
$Clabel = $CL.$Given[$n3k[2]];
$alabel = $aL.$given[$n3k[0]];
$blabel = $bL.$given[$n3k[1]];
$clabel = $cL.$given[$n3k[2]];


$TableOverRide = 0;
%QA = ($LL[1] => $X[1],$ll[0] => $x[0], $ll[2] => $x[2] );

}

if ($TableOverRide == 0){
@sortedKey = ();
foreach $key (keys %QA)
{
push @sortedKey , $key;
}
@sortedKey = lex_sort(@sortedKey);

@xxxPrint = @sortedKey;

$table = "";
$table = BeginTable(spacing => 3);

$cycle = 0 ; # named answer is not case sensitive - a eq A
foreach $key (@sortedKey){
$cycle = $cycle + 1;
if ($key eq uc($key)){$QLabel = "\( \angle \)". $key . " = "}
else {$QLabel = "side ".$key . " = "}
$table .= AlignedRow([$QLabel ,NAMED_ANS_RULE($trial.$cycle,10)]);
$answer = $QA{$key};
push @namedCmp ,$trial.$cycle=>num_cmp( $answer, tolType => "absolute", tolerance=>0.03 * $answer ) ;
}


$table .= EndTable();
@sortedKey = ( );
%QA = ();
}

$AX = $b * cos ($PI * $C / 180);
$AY = $b * sin ($PI * $C / 180);


$dimX = max (max ($a, $a - $AX), $AX);
$dimY = $AY ;
#$size = 1.5 * max ($dimX, $dimY);
#$sizeX = 1.5 * $dimX; #world units
$sizeX = $dimX + 0.5 * max($dimX,$dimY ); #plus borders in world units
#$sizeY = 1.5 * $dimY; #world units
$sizeY = $dimY + 0.5 * max($dimX,$dimY ); #plus borders in world units
$marginX = 0.5 * ($sizeX - $dimX); #world units
$marginY = 0.5 * ($sizeY - $AY); #world units

$xmin = min(0,$AX ) - $marginX; #world units
$xmax = $sizeX + $xmin; #world units
$ymin = -1 * $marginY; #world units
$ymax = $sizeY - $marginY; #world units


if ($sizeX >= $sizeY ){
$xPixels = 600;
$yPixels = $xPixels *($ymax - $ymin)/($xmax - $xmin);
}

if ($sizeX < $sizeY ){
$yPixels = 600;
$xPixels = $yPixels *($xmax - $xmin)/($ymax - $ymin);
}

$pic = init_graph($xmin,$ymin,$xmax,$ymax,'pixels'=>[$xPixels,$yPixels]);


$lab=new Label(0,0,$Clabel,'black','top','center');
$pic->lb($lab);

$lab=new Label($AX,$AY,$Alabel,'black','bottom','left');
$pic->lb($lab);

$lab=new Label($a,0,$Blabel);
$pic->lb($lab);

$lab=new Label($a/2,0,$alabel,'black','center','top');
$pic->lb($lab);

$lab=new Label($AX/2- abs(0.03 *$AX),$AY/2 + 0.03*$AX,$blabel,'black','right','middle');
$pic->lb($lab);

$lab=new Label(($AX + $a) / 2 + abs(0.03 *$a), $AY /2 +0.03*($a - $AX) ,$clabel, 'black','left','middle');
$pic->lb($lab);

# $pic->new_color("lightblue", 240,240,240);
$pic->new_color("lightblue", random(200,240),random(200,240),random(200,240));
$pic->moveTo(0,0);
$pic->lineTo($AX,$AY,1);
$pic->lineTo($a,0,1);
$pic->lineTo(0,0,1);
$pic->fillRegion([($a / 2 + $AX)/2,$AY/2,'lightblue']);

BEGIN_TEXT


$HR $HR Number $trial $BR

\{ image(insertGraph($pic), width=>$xPixels, height=>$yPixels) \}


$PAR
$table $BR

END_TEXT

NAMED_ANS(@namedCmp);

}
TEXT($END_ONE_COLUMN);
ENDDOCUMENT();
In reply to Hedley Pinsent

Re: 52 flavours of triangle problems - fyi

by Hedley Pinsent -
Report on Triangles FYI only

a) Tolerances:
Originally tolerances were set to 3% (angles and sides).
No problems have been detected with this for the sides.
However, with the angles, 180-160.4-10.4 may be taken by the student to be 180-160-10 = 10 instead of 9.2 - a about 8%
A constant 1 degree absolute tolerence fixes this.,
TOLERANCES FOR ANGLES NEED TO BE TREATED DIFFERENT FROM THAT OF SIDES.
Also, using the sine and cosine law, angles are determined by acos(ratio) , and asin(ratio). Upon reflection, and given the "student bill of rights" - three digits, the ratio can involve a value such as 100.5 that gets rounded to 100; this is one part in 200 or 5 parts in 1000. For a true value of asin(1) = 90 degrees, the student might calculate asin(0.995) = 84.3 degrees - an almost 6 degree discrepency.

Well this is only a second reason to stay away from 90 degrees (also 0 and 180), the first being that calculating a 90 degree angle when studying oblique triangles might just confuse the student.

The tolerances in the code below makes some adjustment as the angles approach 85 and 96 degrees (about 2.5 degrees tolerance). Without gettng too carried away it is an aproximation based on the derivatives of acos and asin.

All the tolerance stuff is located in the same place near the end.

b) What really caused a complete rewrite of the algorithms is when another instructor (teaching, basically, high school) said "I want simple - no complications". Translated this meant, for him, no obtuse angles.

Generally, the algorithms determine the two shorter sides; calculate the could-be hypotenuse; and then, for the third, longest side, stay away from it. A third side that is shorter than the hypotenuse gives acute angles; a third side longer than the hypotenuse gives an obtuse angle.

c) Drill problems:
Pythagorean Theorem
#1 Given LL find H
#2 Given HL find other L
#3 Given HL find other L

Student A says to student B ; add for #1 and subtract for #s 2 and 3

In the code below the randomness can be accomplished by writing the question as three parts of question 1. However, from the students point of view, he has done a lot of work to only have finished question 1.

We could say #1 random type; #2 random type ; #3 random type
In this case student A may get three questions of type: Given LL find H; and will always add for the rest of his life.
Student B may be given HL in all cases; this person will subtract for the rest of her life.

An idea that just may be too awkward: sky variables
Problems 1,2,3 (above) may have the same code

if (^@mylist does not exist){make a random list; put in in the sky}
$type = pop ^@mylist;
if ($type == 1){give the student LL}
if ($type == 2){give the student HL}


Code is attached