CoCalc Public Filessympy-1.5.ipynb
Author: Harald Schilly
Views : 130
Compute Environment: Ubuntu 18.04 (Deprecated)

# SymPy 1.5 on CoCalc

kernel: Python 3 (system-wide)

https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5

In [1]:
from sympy import *
init_printing(use_latex='mathjax')

In [2]:
x, y = symbols('x y')
plot_implicit((y > 2) & (y > x), x_var=x, y_var=y)

<sympy.plotting.plot.Plot at 0x7ff9e3b0e9b0>
In [3]:
f2 = sin(x**2)/x * Abs(1- x)
f2

$\displaystyle \frac{\sin{\left(x^{2} \right)} \left|{x - 1}\right|}{x}$
In [4]:
f2d = f2.diff(x)
f2d

$\displaystyle 2 \cos{\left(x^{2} \right)} \left|{x - 1}\right| + \frac{\left(\left(\operatorname{re}{\left(x\right)} - 1\right) \frac{d}{d x} \operatorname{re}{\left(x\right)} + \operatorname{im}{\left(x\right)} \frac{d}{d x} \operatorname{im}{\left(x\right)}\right) \sin{\left(x^{2} \right)} \operatorname{sign}{\left(x - 1 \right)}}{x \left(x - 1\right)} - \frac{\sin{\left(x^{2} \right)} \left|{x - 1}\right|}{x^{2}}$
In [5]:
plot(f2, (x, -5, 5))

<sympy.plotting.plot.Plot at 0x7ff9e3ec6ac8>
In [6]:
f3 = li(y*x**2)
f3

$\displaystyle \operatorname{li}{\left(x^{2} y \right)}$
In [7]:
Integral(f3, x).doit()

$\displaystyle \begin{cases} x \operatorname{li}{\left(x^{2} y \right)} - \frac{x \operatorname{Ei}{\left(3 \log{\left(x \right)} + \frac{3 \log{\left(y \right)}}{2} \right)}}{\sqrt{y} \sqrt{x^{2}}} & \text{for}\: y \neq 0 \\0 & \text{otherwise} \end{cases}$
In [8]:
solveset(f3, x)

$\displaystyle \left\{x \mid x \in \mathbb{C} \wedge \operatorname{li}{\left(x^{2} y \right)} = 0 \right\}$

## complex 16 in fortran 95

In [9]:
from sympy.utilities.codegen import codegen
import sympy.utilities.codegen
sympy.utilities.codegen.COMPLEX_ALLOWED = True

x = Symbol('x', real=False)
y = Symbol('y', real=True)
result = codegen(('test', x + y), 'f95', 'test', header=False, empty=False)
print(result[0][1])

COMPLEX*16 function test(x, y) implicit none COMPLEX*16, intent(in) :: x REAL*8, intent(in) :: y test = x + y end function
In [ ]: