# import symbolic capability to Python
from sympy import *
# print things all pretty
from sympy.abc import *
init_printing()
# Need to define variables as symbolic for sympy to use them.
x, y= symbols("x, y", real = True)
diff((3*x**4+5)**3,x)
laplace_transform(sinh(b*t),t,s)
laplace_transform?
Signature: laplace_transform(f, t, s, **hints) Docstring: Compute the Laplace Transform `F(s)` of `f(t)`, .. math :: F(s) = \int_0^\infty e^{-st} f(t) \mathrm{d}t. For all "sensible" functions, this converges absolutely in a half plane `a < \operatorname{Re}(s)`. This function returns ``(F, a, cond)`` where ``F`` is the Laplace transform of ``f``, `\operatorname{Re}(s) > a` is the half-plane of convergence, and ``cond`` are auxiliary convergence conditions. If the integral cannot be computed in closed form, this function returns an unevaluated :class:`LaplaceTransform` object. For a description of possible hints, refer to the docstring of :func:`sympy.integrals.transforms.IntegralTransform.doit`. If ``noconds=True``, only `F` will be returned (i.e. not ``cond``, and also not the plane ``a``). >>> from sympy.integrals import laplace_transform >>> from sympy.abc import t, s, a >>> laplace_transform(t**a, t, s) (s**(-a)*gamma(a + 1)/s, 0, -re(a) < 1) See Also ======== inverse_laplace_transform, mellin_transform, fourier_transform hankel_transform, inverse_hankel_transform File: ~/anaconda3/lib/python3.6/site-packages/sympy/integrals/transforms.py Type: function
diff((5*x**3+2)**4,x)
simplify(diff((3*x-2)/(2*x+1),x))
simplify(diff((1-x)/(2*x+1),x))
simplify(diff((0*x-2)/(3-x**2),x))
simplify(diff((-1)/(2*x**2+1)**3,x))
simplify(diff((x+1)**3/(x-1)**3,x))
simplify(diff(sqrt(6*x-2),x))
simplify(diff(2*x*sqrt(3*x-1),x))
diff(sqrt(x)+1/2/sqrt(x),x)
simplify(diff(x**(5/2),x))
simplify(diff(sqrt(t+sqrt(t)),t))
simplify(diff((3-2*x+x**3)*(x**4+7),x))
simplify(diff((t**3+1)*(t**2+t+1),t))
(diff((-3*x**5+1)**4*(2-x**3)**5,x))
simplify(diff((t**2-5)/(t**2+5),t))
simplify(diff((x**3-2*x+5)/(x**2+4),x))
simplify(diff((2*x-7)**3/(x-1)**5,x))
simplify(diff(((2*t+1)/(2*t-1))**3,t))
a = simplify(diff((-3)/(3*x**5-2*x+7)**11,x))
a
a == 33*(3*x**5-2*x+7)*(15*x**4-2)/(3*x**5-2*x+7)**22
False
but that was way too easy.
We could compare them, just to be sure they are the same
simplify(diff(y,x))==simplify(diff(ln(y),x)*y)
True
Or plot this monstrosity
plot((diff(y,x),(x,0.2,10)), (y, (x,0.5,10)))
/Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/experimental_lambdify.py:230: UserWarning: The evaluation of the expression is problematic. We are trying a failback method that may still work. Please report this as a bug. warnings.warn('The evaluation of the expression is'
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/experimental_lambdify.py in __call__(self, args) 193 #The result can be sympy.Float. Hence wrap it with complex type. --> 194 result = complex(self.lambda_func(args)) 195 if abs(result.imag) > 1e-7 * abs(result): /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/core/expr.py in __complex__(self) 230 re, im = result.as_real_imag() --> 231 return complex(float(re), float(im)) 232 /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/core/expr.py in __float__(self) 225 raise TypeError("can't convert complex to float") --> 226 raise TypeError("can't convert expression to float") 227 TypeError: can't convert expression to float During handling of the above exception, another exception occurred: AttributeError Traceback (most recent call last) <ipython-input-12-2321e2b00f70> in <module>() ----> 1 plot((diff(y,x),(x,0.2,10)), (y, (x,0.5,10))) /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/plot.py in plot(*args, **kwargs) 1282 plots = Plot(*series, **kwargs) 1283 if show: -> 1284 plots.show() 1285 return plots 1286 /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/plot.py in show(self) 183 self._backend.close() 184 self._backend = self.backend(self) --> 185 self._backend.show() 186 187 def save(self, path): /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/plot.py in show(self) 1016 1017 def show(self): -> 1018 self.process_series() 1019 #TODO after fixing https://github.com/ipython/ipython/issues/1255 1020 # you can uncomment the next line and remove the pyplot.show() call /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/plot.py in process_series(self) 895 # Create the collections 896 if s.is_2Dline: --> 897 collection = self.LineCollection(s.get_segments()) 898 self.ax.add_collection(collection) 899 elif s.is_contour: /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/plot.py in get_segments(self) 501 list_segments.append([p, q]) 502 --> 503 f_start = f(self.start) 504 f_end = f(self.end) 505 sample([self.start, f_start], [self.end, f_end], 0) /Users/jslater/Library/Python/3.5/lib/python/site-packages/sympy/plotting/experimental_lambdify.py in __call__(self, args) 231 ' problematic. We are trying a failback method' 232 ' that may still work. Please report this as a bug.') --> 233 if abs(result.imag) > 1e-7 * abs(result): 234 return None 235 else: AttributeError: 'Symbol' object has no attribute 'imag'
# To change colors
# show = False delays the plot until we can set all of the parameters
# legend turns on the legend and uses the labels we have later.
p = plot((diff(y,x),(x,0.2,10)), (y, (x,0.5,10)), show = False, legend = True)
p[0].line_color = 'blue'
p[0].label = '$\\frac{dy}{dx}$'
p[1].line_color = 'green'
p[1].label = '$y$'
p.show()
What if we wanted to make a substitution?
y.subs(x,alpha)