Skip to content
Snippets Groups Projects
Commit 5a14d361 authored by Colbry, Dirk's avatar Colbry, Dirk
Browse files

Merge branch 'ande2472-main-patch-30494' into 'main'

Gradients

See merge request CMSE/data_science_bridge_curriculum!1
parents bd55c587 6c1d7ceb
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:fc73d74c tags:
``` python
##ANSWER##
#Install answercheck in current director
from urllib.request import urlretrieve
urlretrieve('https://raw.githubusercontent.com/colbrydi/jupytercheck/master/answercheck.py', filename='answercheck.py')
##ANSWER##
```
%% Output
('answercheck.py', <http.client.HTTPMessage at 0x7fc9a8612220>)
%% Cell type:markdown id:3c2a4f39 tags:
# Gradients
Pandas is a python library used to analyze data.
%% Cell type:markdown id:71e867d9 tags:
## Learning Goal
To _**understand**_ how to take a multivariable/partial derivative.
%% Cell type:markdown id:5d237ca9 tags:
## Training Materials
%% Cell type:markdown id:21f9b14e tags:
For a general understanding of gradients, check out the following website:
https://www.khanacademy.org/math/multivariable-calculus/multivariable-derivatives/partial-derivative-and-gradient-articles/a/the-gradient#:~:text=In%20the%20case%20of%20scalar,partial%20derivatives%20into%20a%20vector.
%% Cell type:markdown id:1e57b578 tags:
## Self Assessment
%% Cell type:markdown id:1b047470 tags:
&#9989; **<span style="color:red">Question:</span>** Find (how do I make a $\nabla$f for the following equations:
1. $f(x, y) = x^3 - y^2$
2. $f(x,y) = xy^2 + 2x^4y$
3. $f(x,y) = cos(xy) - xsin(y)$
4. $f(x,y,z) = z^3 + (x/y) - 2xz$
%% Cell type:code id:3b8e33ef tags:
``` python
#Add you answers as sympy matricies.
a1=
a2=
a3=
a4=
```
%% Cell type:code id:08acf30a tags:
``` python
##ANSWER##
x=2.2
y=2.3
a1=sym.Matrix([[3x**2] ,[-2y]])
a2=sym.Matrix([[y^2+8yx^3] ,[2xy+2x^4])
a3=sym.Matrix([-sin(xy)y -sin(y)], [-sin(xy)x - xcos(y)])
a4=sym.Matrix([(1/y)-2z],[ -x/y^2], [3z^2-2x])
##ANSWER##
```
%% Output
Input In [7]
a1=sym.Matrix([[3x**2] ,[-2y]])
^
SyntaxError: invalid syntax
%% Cell type:markdown id:dd9c7fa5 tags:
\&#9989; **<span style="color:red">Question:</span>** Example answercheck question: What is $x = 2+2$?
%% Cell type:code id:64684dfd tags:
``` python
#Put your answer here
```
%% Cell type:code id:619a2259 tags:
``` python
##ANSWER##
x = 4
##ANSWER##
```
%% Cell type:code id:9cc2b34a tags:
``` python
from answercheck import checkanswer
checkanswer.vector(x,'2cab95d1b144d663bad1ce5c51020ae0')
```
%% Output
CheckWarning: passed variable is <class 'int'> and not a numpy.matrix.
Trying to convert to a array matrix using ```A = np.matrix(A)```.
CheckWarning: passed matrix is int64 and not <class 'numpy.float64'>...
Trying to convert to float using ```A = A.astype(float)```.
Testing [[4.]]
Answer seems to be correct
%% Cell type:markdown id:44b461a0 tags:
---
Written by <<YOUR NAME HERE>>, Michigan State University
As part of the Data Science Bridge Project
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">Creative Commons Attribution-NonCommercial 4.0 International License</a>.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment