import sympy as sym # Defining symbols: x, a = sym.symbols('x, a') # Defining the function: f = a*x**2 # Calculating the derivatives: df_x = sym.diff(f, x, 1) # First order derivative ddf_x = sym.diff(f, x, 2) # Second order derivative print('df_x =', df_x) print('ddf_x =', ddf_x)