@@ -34,32 +34,34 @@ TEXT(beginproblem());
34
34
35
35
###################################
36
36
# Setup
37
-
38
- Context()->variables->add(y=>'Real',dx=>'Real',dy=>'Real');
39
- $a=random(-8,8,1);
40
-
41
- $f=Formula("x*cos(y)")->reduce;
42
- $g=Formula("$a*y")->reduce;
43
- $F=Formula("cos(y)-x*sin(y)*(dy/dx)")->reduce;
44
- $G=Formula("$a*(dy/dx)")->reduce;
45
- $Y=Formula("$a+x*sin(y)")->reduce;
46
- $X=Formula("cos(y)")->reduce;
47
- $dF=Formula("-sin(y)*(dy/dx)*($Y)-[sin(y)+x*cos(y)*(dy/dx)]*($X)")->reduce;
48
- $dG=Formula("($Y)^2")->reduce;
49
- $dd1=$dF/$dG;
50
- $df=Formula("(dy/dx)*[$a*sin(y)+x*sin^2(y)+x*cos^2(y)]+sin(y)*($X)")->reduce;
51
- $dd2=-$df/$dG;
52
- $DF=Formula("cos(y)*[sin(y)*($a)+x]+($X)*(sin(y)*($Y))")->reduce;
53
- $DG=Formula("($Y)^3");
54
- $dd3=$DF/$DG;
55
- $ans=Formula("-cos(y)*([2*$a*sin(y)+x*(1+sin^2(y))]/($Y)^3)")->reduce;
56
-
57
- $dydx=Formula("$X/$Y");;
37
+
38
+ Context("Numeric");
39
+ Context()->variables->add(y=>'Real');
40
+
41
+ $a=non_zero_random(-8,8,1);
42
+
43
+ # If the answer is tested at random values of x and y
44
+ # a student might substitute cos(y)->x/a in the
45
+ # implicit solution and have it marked "incorrect"
46
+ # so we'll numerically generate a series of test points along the
47
+ # implicit curve and test it on those points.
48
+
49
+ $ans=Formula("-cos(y)*([2*$a*sin(y)+x*(1+sin(y)^2)]/($a+x*sin(y))^3)")->reduce;
50
+
51
+ $ans->{test_points} = [ [0,0],
52
+ [$a*0.2, 0.19616428118783816 ],[-$a*0.2, -0.19616428118783816 ],
53
+ [$a*0.4, 0.37255949583211007], [-$a*0.4, -0.37255949583211007],
54
+ [$a*0.6, 0.5205326392380185], [-$a*0.6, -0.5205326392380185],
55
+ [$a*0.8, 0.641134282813549], [-$a*0.8, -0.641134282813549],
56
+ [$a, 0.7390851332151331 ], [-$a, -0.7390851332151331 ]
57
+ ];
58
+
58
59
###################################
59
60
# Main text
60
61
Context()->texStrings;
61
62
BEGIN_TEXT
62
- Find \(\frac{d^2y}{dx^2}\) by implicit differentiation when \[$f=$g\]
63
+ Find \(\frac{d^2y}{dx^2}\) by implicit differentiation when
64
+ \[x\cos(y)=$a y\]
63
65
64
66
$PAR
65
67
\(\frac{d^2y}{dx^2}=\) \{ans_rule(50) \}
@@ -75,8 +77,15 @@ ANS($ans->cmp);
75
77
Context()->texStrings;
76
78
SOLUTION(EV3(<<'END_SOLUTION'));
77
79
$PAR SOLUTION $PAR
78
- Differentiating gives \[$F=$G\] \[\left($Y\right)\frac{dy}{dx}=$X\] \[\frac{dy}{dx}=$dydx\]
79
- \[\frac{d^2y}{dx^2}=\frac{d}{dx}\left[$dydx\right]=$dd1\]\[=$dd2\]\[=$dd3=$ans\]
80
+ Differentiating gives
81
+ \[\cos(y)-x\sin(y)\frac{dy}{dx}=$a\frac{dy}{dx}\]
82
+ \[\left($a + x\sin(y)\right)\frac{dy}{dx}=\cos(y)\]
83
+ \[\frac{dy}{dx}=\frac{\cos(y)}{$a+x\sin(y)}\]
84
+ so
85
+ \[\frac{d^2y}{dx^2}=\frac{d}{dx}\left(\frac{\cos(y)}{$a+x\sin(y)}\right)=\frac{-\frac{dy}{dx}\sin(y)\big($a+x\sin(y)\big) - \big(\sin(y)+x\cos(y)\frac{dy}{dx}\big)\cos(y)}{($a+x\sin(y))^2}\]
86
+ \[=\frac{-\frac{dy}{dx}\big($a\sin(y)+x\sin^2(y)+x\cos^2(y)\big)-\sin(y)\cos(y)}{($a+x\sin(y))^2}\]
87
+ \[=-\frac{\cos(y)\big($a\sin(y)+x\big)}{($a+x\sin(y))^3}-\frac{\sin(y)\cos(y)}{($a+x\sin(y))^2}\]
88
+ \[=$ans\]
80
89
END_SOLUTION
81
90
Context()->normalStrings;
82
91
0 commit comments