Skip to content

Commit b28fd60

Browse files
committed
One last comment
1 parent 6623830 commit b28fd60

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

‎Week_8_calculus/lec_act_8_calculus.ipynb‎

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"source": [
3535
"# Create the function\n",
3636
"\n",
37-
"Write the Python function for the above equation"
37+
"TODO: Write the above equation as a function named \"my_func\""
3838
]
3939
},
4040
{
@@ -45,7 +45,7 @@
4545
},
4646
"outputs": [],
4747
"source": [
48-
"# Do the imports"
48+
"# Do the imports - you'll need fminbound from scipy.iptimize and quad from scipy.integrate in addition to the usual numpy/matplotlib"
4949
]
5050
},
5151
{
@@ -67,6 +67,7 @@
6767
},
6868
"outputs": [],
6969
"source": [
70+
"# Check my_func is returning the correct answer for a couple x values\n",
7071
"print(f\"Func at 1.0 is {my_func(1.0)}, expected -2.433333\")\n",
7172
"print(f\"Func at 2.0 is {my_func(2.0)}, expected -4.02694589\")"
7273
]
@@ -90,9 +91,11 @@
9091
"editable": false
9192
},
9293
"source": [
93-
"# Plot the function, along with the bounds and an x at minima and maxima\n",
94+
"# Minima/maxima and Plot\n",
9495
"\n",
95-
"Use 0.5 and 3.0 as the integration bounds"
96+
"Find the minima/maxima within the bounds **a=0.5** and **b=3.0**\n",
97+
"\n",
98+
"Plot the function, along with the minima/maxima\n"
9699
]
97100
},
98101
{
@@ -103,7 +106,7 @@
103106
},
104107
"outputs": [],
105108
"source": [
106-
"# Integration limits\n",
109+
"# Integration limits and the boundaries of the search for minima and maxima\n",
107110
"a = 0.5\n",
108111
"b = 3.0"
109112
]
@@ -116,11 +119,14 @@
116119
},
117120
"outputs": [],
118121
"source": [
119-
"# Find the x locations of the two bends\n",
120-
"#\n",
122+
"# TODO Find the x locations of the two bends (minima and maxima)\n",
123+
"# Use fminbound for both of these\n",
124+
"# Reminder that the maximum can be found by negating\n",
125+
"# You might find a lambda function useful\n",
126+
"# Use the ability to set bounds to keep the search to just the \"bump\" around the minima or maxima (you can hardwire these bounds)\n",
127+
"# I'd suggest plotting the function and/or looking at the plot in the slides to find reasonable bounds\n",
121128
"first_max = ...\n",
122129
"first_min = ...\n",
123-
"# END PROMPT \"\"\"\n",
124130
"\n",
125131
"print(f\"Max {first_max}, expected 0.94813, Min {first_min}, expected 2.091114\")"
126132
]
@@ -133,7 +139,8 @@
133139
},
134140
"outputs": [],
135141
"source": [
136-
"..."
142+
"# TODO Plot the function from a to b\n",
143+
"# TODO Put a green x at the first maxima, and a red x at the first minima"
137144
]
138145
},
139146
{
@@ -169,9 +176,9 @@
169176
},
170177
"outputs": [],
171178
"source": [
179+
"# TODO: Numerically calculate the derivative at the minima/maxima\n",
172180
"deriv_max = ...\n",
173-
"deriv_min = ...\n",
174-
"# END PROMPT\"\"\""
181+
"deriv_min = ..."
175182
]
176183
},
177184
{
@@ -195,7 +202,7 @@
195202
"source": [
196203
"# Integration\n",
197204
"\n",
198-
"TODO Calculate the area under the curve using trapz or quad, whichever you perfer."
205+
"TODO Calculate the area under the curve using **trapz** or **quad**, whichever you perfer."
199206
]
200207
},
201208
{
@@ -206,10 +213,8 @@
206213
},
207214
"outputs": [],
208215
"source": [
209-
"...\n",
210216
"\n",
211-
"area_under_curve = ...\n",
212-
"# END PROMPT\"\"\""
217+
"area_under_curve = ..."
213218
]
214219
},
215220
{
@@ -319,7 +324,7 @@
319324
"name": "python",
320325
"nbconvert_exporter": "python",
321326
"pygments_lexer": "ipython3",
322-
"version": "3.11.4"
327+
"version": "3.11.0"
323328
},
324329
"otter": {
325330
"OK_FORMAT": true,

0 commit comments

Comments
 (0)