Skip to content

Instantly share code, notes, and snippets.

@iydon
Created May 11, 2022 02:04
Show Gist options
  • Save iydon/92e18a62d28ea89a098875f3469e85a9 to your computer and use it in GitHub Desktop.
Save iydon/92e18a62d28ea89a098875f3469e85a9 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{physics}
\begin{document}
\def\cache{
\exp\qty[
- \frac{\xi^2}{4t\nu}
- \frac{u_0\xi}{2\nu}
+ \frac{x\xi}{2t\nu}
- \frac{Lu_0\sin^2{\left(\frac{\pi\xi}{L} \right)}}{2\pi\nu}
]
}
\[
u(x, t) = \frac{x}{t} - \frac{
\displaystyle
\int_{-\infty}^{\infty}\xi\cache\dd{\xi}
}{
\displaystyle
t\int_{-\infty}^{\infty}\cache\dd{\xi}
}
\]
\end{document}
@iydon
Copy link
Author

iydon commented May 11, 2022

from sympy import *


x, t, xi = symbols('x, t, ξ')
u0, L, nu = symbols('u₀, L, ν')

f = u0*(sin(2*pi*xi/L) + 1)
phi = integrate(
    exp(-(x-xi)**2/(4*nu*t) - integrate(f/(2*nu), (xi, 0, xi))),
    (xi, -oo, oo),
) / sqrt(4*pi*nu*t)
u = -2*nu * ln(phi).diff(x)
pretty_print(u.simplify())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment