-
-
Notifications
You must be signed in to change notification settings - Fork 436
Expand file tree
/
Copy pathBCIT_ehqw.pg
More file actions
150 lines (126 loc) · 3.36 KB
/
BCIT_ehqw.pg
File metadata and controls
150 lines (126 loc) · 3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
## DESCRIPTION
## Parametric equations: graphing a polar curve
## ENDDESCRIPTION
## DBsubject(Calculus - multivariable)
## DBchapter(Differentiation of multivariable functions)
## DBsection(Differentiability, linearization and tangent planes)
## Date(11/23/2021)
## Institution(British Columbia Institute of Technology)
## Author(Stefan Lukits)
## KEYWORDS('newtons method')
## supported by the BCcampus Open Homework Systems Project Grant
###########################
# Initialization
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGgraphmacros.pl",
"unionTables.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
$refreshCachedImages = 1;
$discriminant=0;
while ($xs<=0)
{
while ($discriminant<=0)
{
$a=random(2,5,1);
$b=random(8,11,1);
$c=random(16,19,1);
$d=random(12,15,1);
$e=random(41,49,1);
$discriminant=(1-((2*$a*$d*$e)/($c**2)))**2-(4*(($a*$d**2)/($c**2))*((($a*$e**2)/($c**2))-$b));
}
$xs=((((2*$a*$d*$e)/($c**2))-1)+sqrt($discriminant))/((2*$a*$d**2)/($c**2));
}
$x=sqrt($xs);
$y=(($d*$x**2)-$e)/$c;
$xr=(int(($x*100)+0.5))/100;
$yr=(int(($y*100)+0.5))/100;
$fabx=$xr**2+$a*$yr**2-$b;
$faby=$c*$yr-$d*$xr**2+$e;
$J11=2*$xr;
$J12=2*$a*$yr;
$J21=(-2)*$d*$xr;
$J22=$c;
$con1=$J11*$xr+$J12*$yr-$fabx;
$con2=$J21*$xr+$J22*$yr-$faby;
$det=($J11*$J22)-($J12*$J21);
$detC1=($con1*$J22)-($J12*$con2);
$detC2=($J11*$con2)-($con1*$J21);
$x1=$detC1/$det;
$y1=$detC2/$det;
$x1r=(int(($x1*100000)+0.5))/100000;
$y1r=(int(($y1*100000)+0.5))/100000;
##########################
# Setup
Context("Numeric")->variables->are(t=>"Real");
$gr = init_graph(-4,-3,4,3,axes=>[0,0],grid=>[4,4],size=>[300,300]);
$gr->new_color("lightblue", 198,217,253); # RGB
$gr->new_color("darkblue", 77,137,249);
$gr->new_color("lightred", 255,127,127);
$gr->new_color("darkred", 255, 55, 55);
$gr->new_color("lightorange", 255,204,127);
$gr->new_color("darkorange", 255, 153, 0);
$gr->new_color("lightgreen", 187, 255, 153);
$gr->new_color("darkgreen", 0, 208, 0);
$x = Formula("sqrt($b)*cos(t)");
$y = Formula("sqrt($b/$a)*sin(t)");
$f = new Fun( $x->perlFunction, $y->perlFunction, $gr );
$f->domain(0,2*pi);
$f->steps(90);
$f->color('darkgreen');
$f->weight('2');
$x = Formula("t");
$y = Formula("(1/$c)*($d*(t*t)-$e)");
$w = new Fun( $x->perlFunction, $y->perlFunction, $gr );
$w->domain(-4,4);
$w->steps(90);
$w->color('darkorange');
$w->weight('2');
##########################
# Main Text
Context()->texStrings;
BEGIN_TEXT
Use Newton's method to solve the system
\[
\begin{array}{l}
x^{2}+$a y^{2} = $b \\
$c y-$d x^{2} = -$e \\
\end{array}
\]
$BR
\(($xr,$yr)\) is close to the solution. Consider it your first estimate \((x_{0},y_{0})\). What are \(x_{1}\) and \(y_{1}\) after one iteration of using Newton's method? Provide at least six significant digits.
$BR
$BR
\(x_{1}\)=\{ans_rule(20)\}
$BR
\(y_{1}\)=\{ans_rule(20)\}
$BR
$BCENTER \{image(insertGraph($gr),width=>300,height=>300 )\}
$BR
Graph of \( x^{2}+$a y^{2} = $b \) and \( $c y-$d x^{2} = -$e\)$ECENTER
END_TEXT
Context()->normalStrings;
########################
# Answer Evaluation
$showPartialCorrectAnswers = 1;
ANS(num_cmp($x1,
tolType => 'absolute',
tolerance => .0001,
));
ANS(num_cmp($y1,
tolType => 'absolute',
tolerance => .0001,
));
############################
# Solution
Context()->texStrings;
BEGIN_SOLUTION
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;
;
ENDDOCUMENT();