Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Erik Strand
nmm_2020_site
Commits
f8eb49e4
Commit
f8eb49e4
authored
Apr 20, 2020
by
Erik Strand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update notes
parent
00355e04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
5 deletions
+25
-5
_notes/differentiable_simulation.md
_notes/differentiable_simulation.md
+25
-5
No files found.
_notes/differentiable_simulation.md
View file @
f8eb49e4
...
...
@@ -34,9 +34,18 @@ $$
By differentiating both sides of this relation and applying the chain rule, we find that
$$
\f
rac{
\p
artial}{
\p
artial y_0}
y_{n+1}
=
\f
rac{
\p
artial}{
\p
artial y_n}
g
(n
\D
elta t, y_n)
\f
rac{
\p
artial}{
\p
artial y_0}
y_n
\f
rac{
\p
artial
y_{n+1}
}{
\p
artial y_0} =
\f
rac{
\p
artial
g
}{
\p
artial y_n} (n
\D
elta t, y_n)
\f
rac{
\p
artial
y_n
}{
\p
artial y_0}
$$
Note that we can take the partial derivative of any component of $$y_n$$ with respect to any
component of $$y_0$$. So the equation above relates Jacobian matrices. The left hand side is the
Jacobian of of $$y_{n + 1}$$ as a function of $$y_0$$. The right hand side is the product of the
Jacobian of $$g$$ as a function of $$y_n$$ with the Jacobian of $$y_n$$ as a function of $$y_0$$.
Note that $$g$$ necessarily involves the gradient of $$y$$ as a function of time (i.e. $$f$$, the
object that normal non-differential simulation integrates forward), so the Jacobian of $$g$$ will
involve second order derivatives of $$y$$ (first evaluated with respect to time, then with respect
to the prior state).
Assuming that we can compute $$
\p
artial g /
\p
artial y$$ on demand, this gives a convenient
recurrence relation for $$
\p
artial y_{n+1} /
\p
artial y_0$$ in terms of $$
\p
artial y_{n} /
\p
artial
y_0$$. So to differentiate through such a simulation, all we need to do is figure out $$
\p
artial g /
...
...
@@ -48,15 +57,26 @@ the values $$y_n$$.
As mentioned above, for Euler integration $$g(x, y) = y + (
\D
elta x) f(x, y)$$. Thus
$$
\f
rac{
\p
artial}{
\p
artial y}
g
(x, y) = 1 + (
\D
elta x)
\f
rac{
\p
artial}{
\p
artial y}
f
(x, y)
\f
rac{
\p
artial
g
}{
\p
artial y} (x, y) = 1 + (
\D
elta x)
\f
rac{
\p
artial
f
}{
\p
artial y} (x, y)
$$
And
$$
\b
egin{aligned}
\f
rac{
\p
artial}{
\p
artial y_0}
y_{n+1}
&=
\f
rac{
\p
artial}{
\p
artial y_n}
g
(n
\D
elta t, y_n)
\f
rac{
\p
artial}{
\p
artial y_0}
y_n
\\
&=
\l
eft( 1 + (
\D
elta x)
\f
rac{
\p
artial}{
\p
artial y}
f
(x, y)
\r
ight)
\f
rac{
\p
artial}{
\p
artial y_0}
y_n
\\
\f
rac{
\p
artial
y_{n+1}
}{
\p
artial y_0}
&=
\f
rac{
\p
artial
g
}{
\p
artial y_n} (n
\D
elta t, y_n)
\f
rac{
\p
artial
y_n
}{
\p
artial y_0}
\\
&=
\l
eft( 1 + (
\D
elta x)
\f
rac{
\p
artial
f
}{
\p
artial y} (x, y)
\r
ight)
\f
rac{
\p
artial
y_n
}{
\p
artial y_0}
\\
\e
nd{aligned}
$$
### N-Body Problem
A simple test case is the n-body problem. Let's take our phase space coordinates to be position and
velocity. Given positions $$x_i$$ and masses $$m_i$$, Newton's law of universal gravitation (along
with Newton's second law of motion) tells us how to compute the acceleration experienced by a
particular particle.
$$
a_i =
\s
um_{j
\n
eq i} G m_j
\f
rac{x_j - x_i}{|x_j - x_i|^3}
$$
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment