## my sympy and python cheat sheet

June 13, 2021   Compiled on June 13, 2021 at 12:22 Noon

### 1 How to solve a ﬁrst order ODE?

Solve $$y'(x)=1+2 x$$ for $$y(x)$$

### 2 How to solve a ﬁrst oder ODE with initial condition?

Solve $$y'(x)=1+2 x$$ for $$y(x)$$ with $$y(0)=3$$

### 3 How to solve a second order ODE?

Solve $$9 y{\relax (x )} + \frac {d^{2}}{d x^{2}} y{\relax (x )} = 0$$

gives

$y{\relax (x )} = C_{1} \sin {\left (3 x \right )} + C_{2} \cos {\left (3 x \right )}$

### 4 How to solve and ODE and convert the result to latex string?

Solve $$y'(x)=1+2 x$$ for $$y(x)$$ with $$y(0)=3$$

$y{\relax (x )} = x^{2} + x + 3$

### 5 How to solve a PDE in sympy?

PDE solving is still limited in sympy. Here is how to solve ﬁrst order pde

Solve $$u_t(x,t)=u_x(x,t)$$

$u{\left (x,t \right )} = F{\left (t + x \right )}$

### 6 How to check if something is derivative?

This also works, which seems to be the more prefered way

### 7 How to ﬁnd function name and its arguments in a proc?

Suppose one passes $$y(x)$$ to a function, and the function wants to ﬁnd the name of this function and its argument. Here is an example

This prints