1. HOME
  2. PDF (letter size)
  3. PDF (legal size)

my sympy and python cheat sheet

Nasser M. Abbasi

July 19, 2019   Compiled on July 19, 2019 at 6:49pm

Contents

1 How to solve a first oder ODE?
2 How to solve a first oder ODE with initial condition?
3 How to solve and ODE and convert the result to latex string?
4 How to solve a PDE in sympy?
5 How to check if something is derivative?
6 How to find function name and its arguments in a proc?

1 How to solve a first oder ODE?

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

2 How to solve a first oder ODE with initial condition?

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

3 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{\left (x \right )} = x^{2} + x + 3 \]

4 How to solve a PDE in sympy?

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

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

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

5 How to check if something is derivative?

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

6 How to find function name and its arguments in a proc?

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

This prints