#! /usr/bin/env python3 # def sympy_derivative ( ): from sympy import diff from sympy import exp from sympy import symbols print ( '' ) print ( 'sympy_derivative():' ) print ( ' Demonstrate the computation of derivatives.' ) print ( '' ) x = symbols ( 'x' ) humps = 100 / ( ( 10 * x - 3 )**2 + 1 ) \ + 100 / ( ( 10 * x - 9 )**2 + 4 ) \ - 6 dhumpsdx = diff ( humps, x ) print ( ' d humps /dx = ', dhumpsdx ) d2humpsdx2 = diff ( humps, x, 2 ) print ( ' d2 humps /dx2 = ', d2humpsdx2 ) print ( '' ) print ( ' z = x * e^(x*t)' ) t = symbols ( 't' ) z = x * exp ( x * t ) dzdx = diff ( z, x ) print ( ' dzdx = ', dzdx ) dzdt = diff ( z, t ) print ( ' dzdt = ', dzdt ) dz2dt2 = diff ( z, t, 2 ) print ( ' d2zdt2 = ', dz2dt2 ) dz2dtdx = diff ( z, t, x ) print ( ' d2zdtdx = ', dz2dtdx ) return if ( __name__ == "__main__" ): sympy_derivative ( )