Search code examples
pythonmathsympy

Issue with sympy


Why when I try to get this diff:

enter image description here

I get not expected result

enter image description here

The result was meant to be:

enter image description here

I try diff(sin(x)**tan(x)) and simplify is there any way to get The value I expected Above


Solution

  • You can get the form that you expected if you simplify and then rewrite the cos to sec:

    In [7]: diff(sin(x)**tan(x), x).trigsimp().rewrite(cos, sec)
    Out[7]: 
    ⎛               2       ⎞    tan(x)   
    ⎝log(sin(x))⋅sec (x) + 1⎠⋅sin      (x)