summaryrefslogtreecommitdiff
path: root/day1/cheatsheet6.tex
blob: 2e9de974c3a54a26c81864c3f8a4b41a7a0c7faa (plain)
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
\documentclass[12pt]{article}
\title{Solving Equations \& ODEs}
\author{FOSSEE}
\begin{document}
\date{}
\vspace{-1in}
\begin{center}
\LARGE{Solving Equations \& ODEs}\\
\large{FOSSEE}
\end{center}
\section{Solving linear equations}
\begin{verbatim}
    In []: A = array([[3,2,-1],
                      [2,-2,4],                   
                      [-1, 0.5, -1]])
    In []: b = array([[1], [-2], [0]])
    In []: x = solve(A, b)
    In []: Ax = dot(A,x)
    In []: allclose(Ax, b)
    Out[]: True
\end{verbatim}
\section{Finding roots}
\begin{verbatim}
  In []: coeffs = [1, 6, 13]
  In []: roots(coeffs)
\end{verbatim}
Finding the roots of a function
\begin{verbatim}
In []: fsolve(sin(x)+cos(x)**2, 0)
\end{verbatim}
\section{ODE}
\begin{verbatim}
  In []: def epid(y, t):
  ....     k, L = 0.00003, 25000
  ....     return k*y*(L-y)
  ....
  
  In []: t = arange(0, 12, 0.2)

  In []: y = odeint(epid, 250, t)

  In []: plot(t, y)
\end{verbatim}
\end{document}