-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexercise3.tex
65 lines (44 loc) · 2.1 KB
/
exercise3.tex
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
\documentclass[11pt]{article}
\input{packages}
\begin{document}
% ========== Edit your name here
%\author{Your Name}
\title{\coursename~Quiz 3: Due by \DueDate{\coursedate}{23}}
\date{}
\maketitle
\medskip
% ========== Begin answering questions here
\section*{Exercises}
\begin{enumerate}
\item Programming on paper (2 credits): \\
Write a struct for a complex number and overload the +,-, and * operator.
\item Interpreting programs (2 credits): \\
What does this program do? Please write down the value of $n$ at each occurrence of the \lstinline|std::cout| statement.
\lstinputlisting{code/exercise3-2.cpp}
\end{enumerate}
\section*{Programming exercise}
\begin{enumerate}
\item N-body problem: (6 credits)\\
In this exercise, we will implement the N-Body simulating using a direct sum to compute the forces and the Euler Method to update the positions.
\begin{itemize}
\item Datastrucutre:
\begin{enumerate}
\item Write a generic struct for a vector
\item Add a function to compute the vector's norm
\item Add a constructor which initializes the vector to zero
\item Overload the operators +,-, and == for a second vector and the operator * for multplication with a scalar
\end{enumerate}
\item Class for the $N$-body simulation
\begin{enumerate}
\item Write a function to compute the force $\mathbf{F}_i=\sum\limits_{i=0,i\neq j}^n \mathbf{F}_{ij}= \sum\limits_{i=0,i\neq j}^n g_c m_j \frac{\mathbf{r}_j-\mathbf{r}_i}{\vert \mathbf{r}_j - \mathbf{r}_i\vert^3}$ for each body using a direct sum
\item Write a function to compute the velocity $\mathbf{v}_i(t_k)=\mathbf{v}_i(t_{k-1})+\Delta t \frac{\mathbf{F}_i}{m_i}$ for each body
\item Write a function to update the new positions $\mathbf{r}_i(t_{k+1})=\mathbf{r}_i(t_k)+\mathbf{v}_i(t_k)\Delta t$ of a each body
\end{enumerate}
\end{itemize}
Note that you will get an invitation via Github classroom and you should use this repository to submit your solution. In addition, you can find the templates here\footnote{\url{https://github.com/diehlpkteaching/N-Body}}.
% ========== Continue adding items as needed
\end{enumerate}
\doclicenseThis
\end{document}
\grid
\grid