mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-03-14 10:50:05 +01:00
Merge branch 'main' of https://github.com/janishutz/eth-summaries
This commit is contained in:
@@ -224,4 +224,8 @@ Complete code (with many visualisations), also for topics not covered in this su
|
|||||||
\input{parts/06_python/02_scipy.tex}
|
\input{parts/06_python/02_scipy.tex}
|
||||||
\input{parts/06_python/03_sympy.tex}
|
\input{parts/06_python/03_sympy.tex}
|
||||||
|
|
||||||
|
\newsection
|
||||||
|
\section{Notes on the exam}
|
||||||
|
\input{parts/07_exam/00_intro.tex}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ falls $F(x^*) = 0$ und $F^(x^*) \neq 0$
|
|||||||
\begin{code}{python}
|
\begin{code}{python}
|
||||||
def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
|
def newton_method(f, df, x: float, tol=1e-12, maxIter=100):
|
||||||
""" Use Newton's method to find zeros, requires derivative of f """
|
""" Use Newton's method to find zeros, requires derivative of f """
|
||||||
iter = 0
|
k = 0
|
||||||
while (np.abs(df(x)) > tol and iter < maxIter):
|
while (np.abs(f(x)) > tol and k < maxIter):
|
||||||
x -= f(x)/df(x); iter += 1
|
x -= f(x) / df(x)
|
||||||
|
k += 1
|
||||||
|
|
||||||
return x, iter
|
return x, k
|
||||||
\end{code}
|
\end{code}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import sympy as sp
|
import sympy as sp
|
||||||
|
|
||||||
a, b = (0, 1);
|
a, b = (0, 1)
|
||||||
x, y = sp.symbols("x, y") # Create sympy symbols
|
x, y = sp.symbols("x, y") # Create sympy symbols
|
||||||
f = x**2 + 3 * x - 2 # Create your function
|
f = x**2 + 3 * x - 2 # Create your function
|
||||||
# In the below, for 1D differentiation, we can omit the symbol and just use sp.diff(f)
|
# In the below, for 1D differentiation, we can omit the symbol and just use sp.diff(f)
|
||||||
@@ -13,5 +13,10 @@ roots = sp.roots(f) # Computes the roots of function f analytically
|
|||||||
sp.hermite_poly(5) # Creates hermite poly of degree 5
|
sp.hermite_poly(5) # Creates hermite poly of degree 5
|
||||||
sp.chebyshevt_poly(5) # Creates chebychev T (first kind) poly of degree 5
|
sp.chebyshevt_poly(5) # Creates chebychev T (first kind) poly of degree 5
|
||||||
sp.chebyshevu_poly(5) # Creates chebychev U (second kind) poly of degree 5
|
sp.chebyshevu_poly(5) # Creates chebychev U (second kind) poly of degree 5
|
||||||
|
system = [f + y, x**3 + 2 * y, 3 * y - 2 * x] # A system of equations
|
||||||
|
sp.solve(system) # Solves a system of equations algebraically
|
||||||
|
sp.nsolve(
|
||||||
|
system, [x, y], (0, 1)
|
||||||
|
) # Input the system, the variables to solve in and interval
|
||||||
# To print nicely rendered math expressions, you can use
|
# To print nicely rendered math expressions, you can use
|
||||||
sp.init_printing()
|
sp.init_printing()
|
||||||
|
|||||||
13
semester3/numcs/parts/07_exam/00_intro.tex
Normal file
13
semester3/numcs/parts/07_exam/00_intro.tex
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
A few example questions that might show up in the exam are:
|
||||||
|
\begin{itemize}
|
||||||
|
\item Reused homework tasks from the Moodle Quizzes and Code Expert (e.g. the GPS task)
|
||||||
|
\item Reused tasks from the mock exam
|
||||||
|
\item Doing quadrature on an $\arctan$ function, for which you have to use Gauss-Newton quadrature
|
||||||
|
\end{itemize}
|
||||||
|
Knowing \texttt{sympy} and having read through the docs of it (at least partially) can help tremendously.
|
||||||
|
Additionally, try to use the script with a horrible (i.e. slow and not context-aware (i.e. it start search from the start)) PDF reader to get used to that.
|
||||||
|
You can get such a search function in a PDF reader by installing Firefox ESR 72 (on which to my knowledge, Safe Exam Browser is based).
|
||||||
|
|
||||||
|
For the multiple-choice tasks, if applicable, use properties of the formulas
|
||||||
|
(e.g. for the Radau quadrature, use the fact that one of the edges of the interval has to be included and the weight computation is different for it)
|
||||||
|
or otherwise use the Jupyter notebook to run functions that are already implemented in the script, or better yet, \texttt{sympy}.
|
||||||
Reference in New Issue
Block a user