I am still having a bit of difficulty getting "pretty" fractions to present in solutions:
I thought that the essential commands to make this happen were:
1.) Load the macro: "contextFraction.pl"
2.) initialize before the fraction variable is declared: Context("Fraction");
3.) Use this before said variable: Context()->texStrings;
4.) Use this after said variable: Context()->normalStrings;
Unfortunately the fractions are coming out in algebra strings wrapped in parentheses: (5/6) rather than the pretty tex style.
Can you see my error?
Thanks so much...
## DESCRIPTION
## Calculus
## ENDDESCRIPTION
## Tagged by tda2d
## DBsubject(Calculus - single variable)
## DBchapter(Differentiation)
## DBsection(Quotient rule (without trigonometric functions))
## Institution(ASU)
## Level(3)
## KEYWORDS('Differentiation' 'Product Rule' 'Quotient Rule')
## MO(1)
## updated 12/2014
## updated 8/2015 with solutions, Original path:
## Library/ASU-topics/setProductQuotientRule/3-5-51
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"contextFraction.pl",
"PGchoicemacros.pl",
"PGanswermacros.pl",
);
TEXT(beginproblem());
$showpartialcorrectanswers = 1;
Context("Numeric");
$a = random(2, 4, 1);
$b = random(3, 8,1);
$c = random(2,7,1);
$d = random(3,9,1);
$f = random(2,6,1);
$g = random(4, 12, 1);
$ah = $a*0.5;
$d2 = $d*2;
$ahd = $ah*$d;
$ahf = $ah*$f;
$ahg = $ah*$g;
$ad2 = $a*$d2;
$af = $a*$f;
$ta = $ahd - $ad2;
$tb = $ahf - $af;
$r1 = random(1,5,1);
$tar = $ta*$r1;
$rsq = $r1*$r1;
$fr = $f*$r1;
$drsq = $d*$rsq;
$frg = $fr - $g;
$tarb = $tar +$tb;
$den1 =$drsq+$frg;
$den2 = $den1**2;
$tarbr = $tarb*$r1;
$tarb2 = $tarbr - $ahg;
Context("Fraction");
Context()->texStrings;
$frac1 = Fraction("$tarb2/$den2");
Context()->normalStrings;
$r2 = random(-7,-1,1);
$h1 = $a*(($r1)**(.5));
$dh1 = ($a/2)*(($r1)**(-.5));
$l1 = $d*(($r1)**2) + $f*($r1) - $g;
while ($d*(($r1)**2) + $f*($r1) - $g == 0)
{
$g = random(4, 12, 1);
$l1 = $d*(($r1)**2) + $f*($r1) - $g;
}
$dl1 = 2*$d*$r1 + $f;
BEGIN_TEXT
Let
\[f(x) = \frac{$a \sqrt{x} }{$d x^2 + $f x - $g}. \]
Evaluate \(f'(x)\) at \(x = $r1\).
$BR$BR
\( f'($r1) \) = \{ans_rule(50) \}
END_TEXT
$ans = Compute("(($l1)*($dh1) - ($h1)*($dl1))/(($l1)**2)");
ANS($ans->cmp);
#ANS(num_cmp($ans));
SOLUTION(EV3(<<'END_SOLUTION'));
$PAR SOLUTION $PAR
Use the quotient rule to find the derivative of a quotient:$BR
If \( Q(x) = \frac{N(x)}{D(x)} \), then the derivative of `Q(x)` can be expressed as $BR
$BR
\( Q'(x) = \frac{N'(x) \cdot D(x) - N(x) \cdot D'(x)}{(D(x))^2} \). $BR
$BR
Convert the root to a rational exponent.$BR
$BR
\(\displaystyle{f(x) = \frac{$a x^{\frac{1}{2}} }{$d x^2 + $f x - $g}}\) $BR
$BR
Apply the prime tics for the quotient rule and square the denominator.$BR
$BR
\(\displaystyle{f'(x) = \frac{$a \left(x^{\frac{1}{2}}\right)'($d x^2 + $f x - $g) - $a x^{\frac{1}{2}}($d x^2 + $f x - $g)' }{($d x^2 + $f x - $g)^2}}\) $BR
$BR
Apply the derivative. $BR
$BR
\(\displaystyle{f'(x) = \frac{$ah x^{\frac{-1}{2}}($d x^2 + $f x - $g) - $a x^{\frac{1}{2}}($d2 x + $f - 0) }{($d x^2 + $f x - $g)^2}}\) $BR
$BR
Distribute through the numerator. $BR
$BR
\(\displaystyle{f'(x) = \frac{$ahd x^{\frac{3}{2}} +$ahf x^{\frac{1}{2}} -$ahg x^{\frac{-1}{2}} - $ad2 x^{\frac{3}{2}}- $af x^{\frac{1}{2}}}{($d x^2 + $f x - $g)^2}}\)$BR
$BR
Collect like terms. $BR
$BR
\(\displaystyle{f'(x) = \frac{($ahd -$ad2)x^{\frac{3}{2}} +($ahf -$af) x^{\frac{1}{2}} -$ahg x^{\frac{-1}{2}} }{($d x^2 + $f x - $g)^2}}\)$BR
$BR
Reduce and the result is the derivative. $BR
$BR
\(\displaystyle{f'(x) = \frac{$ta x^{\frac{3}{2}} +$tb x^{\frac{1}{2}} -$ahg x^{\frac{-1}{2}} }{($d x^2 + $f x - $g)^2}}\)$BR
$BR
Evaluate the derivative at `x = $r1`. $BR
$BR
\(\displaystyle{f'($r1) = \frac{$ta \cdot $r1^{\frac{3}{2}} +$tb \cdot $r1^{\frac{1}{2}} -$ahg \cdot $r1^{\frac{-1}{2}} }{($d \cdot $r1^2 + $f \cdot $r1 - $g)^2}}\)$BR
$BR
$BR
Reduce the `\frac{3}{2}` root, and combine denominator factors: $BR
$BR
\(\displaystyle{f'($r1) = \frac{$ta \cdot $r1\cdot $r1^{\frac{1}{2}} +$tb \cdot $r1^{\frac{1}{2}} -$ahg \cdot $r1^{\frac{-1}{2}} }{($d \cdot $rsq + $fr - $g)^2}}\)$BR
$BR
$BR
Convert rational exponents to roots, and convert the negative root to a positive root by a denominator placement:
\(\displaystyle{f'($r1) = \frac{($tar +$tb) \sqrt{$r1} -\frac{$ahg}{\sqrt{$r1}} }{($drsq + $frg)^2}}\)$BR
$BR
$BR
Combine constants: $BR
\(\displaystyle{f'($r1) = \frac{$tarb \sqrt{$r1} -\frac{$ahg}{\sqrt{$r1}} }{$den1^2}}\)$BR
$BR
$BR
Multiply each term by `\sqrt{$r1}`. $BR
$BR
\(\displaystyle{f'($r1) = \frac{$tarb \sqrt{$r1} \cdot \sqrt{$r1} -\frac{$ahg \cdot \sqrt{$r1}}{\sqrt{$r1}} }{\sqrt{$r1} \cdot $den2}}\)$BR
$BR
Reduce root factors. $BR
$BR
\(\displaystyle{f'($r1) = \frac{$tarb \cdot $r1 -$ahg }{\sqrt{$r1} \cdot $den2}}\)$BR
$BR
$BR
Combine factors. $BR
$BR
\(\displaystyle{f'($r1) = \frac{$tarbr -$ahg }{\sqrt{$r1} \cdot $den2}}\)$BR
$BR
Combine terms and separate the root. $BR
$BR
\(\displaystyle{f'($r1) = \frac{$tarb2}{ $den2}\cdot \frac{1}{\sqrt{$r1}}}\)$BR
$BR
$BR
Reduce. $BR
\(\displaystyle{f'($r1) = $frac1 \cdot \frac{1}{\sqrt{$r1}}}\)$BR
$BR
END_SOLUTION
ENDDOCUMENT();