```python
from IPython.display import display, Latex
from sympy import *
init_printing(use_latex='mathjax')

x, y = symbols('x y')
display(x,y)

int_x = Integral(cos(x)*exp(x), x)
result ="$${} = {}$$".format(latex(int_x), latex(int_x.doit()))
display(Latex(result))

derv_x = Derivative(cos(x)*exp(x), x)
result ="$${} = {}$$".format(latex(derv_x), latex(derv_x.doit()))
display(Latex(result))
```


$\displaystyle x$



$\displaystyle y$



$$\int e^{x} \cos{\left(x \right)}\, dx = \frac{e^{x} \sin{\left(x \right)}}{2} + \frac{e^{x} \cos{\left(x \right)}}{2}$$



$$\frac{d}{d x} e^{x} \cos{\left(x \right)} = - e^{x} \sin{\left(x \right)} + e^{x} \cos{\left(x \right)}$$



```python
from IPython.display import display

def show(a, fmt='png'):
    import PIL.Image
    from io import BytesIO
    import IPython.display
    import numpy as np
    f = BytesIO()
    PIL.Image.fromarray(np.uint8(a)).save(f, fmt)
    IPython.display.display(IPython.display.Image(data=f.getvalue()))
    
from sympy import *
init_printing()
3+4j, Rational(1,3), sqrt(8), sqrt(-1), pi, E**2, oo, -oo
import IPython.display
display(3+4j, Rational(1,3), sqrt(8), sqrt(-1), pi, E**2, oo, -oo)
# x = symbols('x')
# a = Integral(cos(x)*exp(x), x)
# Eq(a, a.doit())
```


```python
alpha, beta, nu = symbols('alpha beta nu')
display(alpha, beta, nu)
```


```python
alpha, beta
```


```python
3+4j, Rational(1,3), sqrt(8), sqrt(-1), pi, E**2, oo, -oo
```




    ((3+4j), 1/3, 2*sqrt(2), I, pi, exp(2), oo, -oo)




```python
diff(sin(x)*exp(x),x)
```


```python
integrate(exp(x)*sin(x)+exp(x)*cos(x),x)
```


```python
integrate(sin(x**2),(x,-oo,oo))
```


```python
import sympy
from sympy import init_printing, Integral, Symbol

x = Symbol('x')
expr1 = 2*x**2 + 3*x + 2

init_printing(use_latex='mathjax')
print("Here is an integral ")
Integral(expr1, x), sympy.integrate(expr1)
```

    Here is an integral 





$\displaystyle \left( \int \left(2 x^{2} + 3 x + 2\right)\, dx, \  \frac{2 x^{3}}{3} + \frac{3 x^{2}}{2} + 2 x\right)$




```python
import sympy
from sympy import init_printing, Integral, Symbol

x = Symbol('x')
expr1 = 2*x**2 + 3*x + 2

init_printing(use_latex='mathjax')
print("Here is list")
expr = Limit(sin(x)/x,x,0)
[expr,expr.doit()]
```

    Here is list





$\displaystyle \left[ \lim_{x \to 0^+}\left(\frac{\sin{\left(x \right)}}{x}\right), \  1\right]$




```python
import sympy
from sympy import init_printing, Integral, Symbol

x = Symbol('x')
expr1 = 2*x**2 + 3*x + 2

init_printing(use_latex='mathjax')
print("Here is list")
expr = Limit(sin(x)/x,x,0)
expr,expr.doit()
```

    Here is list





$\displaystyle \left( \lim_{x \to 0^+}\left(\frac{\sin{\left(x \right)}}{x}\right), \  1\right)$




```python
solve(x**2+1, x)
```




$\displaystyle \left[ - i, \  i\right]$




```python
solve(x**2 - 2, x)
```




$\displaystyle \left[ - \sqrt{2}, \  \sqrt{2}\right]$




```python
y = Function('y')
t = symbols('t')
expr = Eq(y(t).diff(t,t) - y(t), exp(t))
expr,y(t)
```




$\displaystyle \left( - y{\left(t \right)} + \frac{d^{2}}{d t^{2}} y{\left(t \right)} = e^{t}, \  y{\left(t \right)}\right)$




```python
dsolve(expr,y(t))
```




$\displaystyle y{\left(t \right)} = C_{2} e^{- t} + \left(C_{1} + \frac{t}{2}\right) e^{t}$




```python
latex(expr)
```




    '- y{\\left(t \\right)} + \\frac{d^{2}}{d t^{2}} y{\\left(t \\right)} = e^{t}'




```python
from sympy.plotting import plot
x = symbols('x')
p = plot(2*x+3, 3*x+1, legend=True, show=False)
p.show()
```


```python
i = tensor.Idx('i',3)
j = tensor.Idx('j',3)
k = tensor.Idx('k',3)
l = tensor.Idx('l',3)

F = MatrixSymbol('F', 3, 3)
i,j,k,l,F
```




$\displaystyle \left( Idx\left(i, \left( 0, \  2\right)\right), \  Idx\left(j, \left( 0, \  2\right)\right), \  Idx\left(k, \left( 0, \  2\right)\right), \  Idx\left(l, \left( 0, \  2\right)\right), \  F\right)$




```python
from sympy.tensor.array import *
var("a,b,c,d,e,f")
X = Array([[a, b, c], [d, e, f]])
X
var("w1,w2,w3")
W = Array([w1, w2, w3])
W
tp = tensorproduct(X, W)
tp
```




$\displaystyle \left[\begin{matrix}\left[\begin{matrix}a w_{1} & a w_{2} & a w_{3}\\b w_{1} & b w_{2} & b w_{3}\\c w_{1} & c w_{2} & c w_{3}\end{matrix}\right] & \left[\begin{matrix}d w_{1} & d w_{2} & d w_{3}\\e w_{1} & e w_{2} & e w_{3}\\f w_{1} & f w_{2} & f w_{3}\end{matrix}\right]\end{matrix}\right]$




```python
stc = sum(tensorcontraction(tp, (1, 2)))
stc
```




$\displaystyle a w_{1} + b w_{2} + c w_{3} + d w_{1} + e w_{2} + f w_{3}$




```python
derive_by_array(stc, W)
```




$\displaystyle \left[\begin{matrix}a + d & b + e & c + f\end{matrix}\right]$




```python
X = IndexedBase("X")
W = IndexedBase("W")
var("i,j,M,K", integer=True)
s = Sum(X[i, j]*W[j], (i, 1, M), (j, 1, K))
s
```




$\displaystyle \sum_{\substack{1 \leq i \leq M\\1 \leq j \leq K}} {W}_{j} {X}_{i,j}$




```python
s.diff(W[j])
```




$\displaystyle \sum_{\substack{1 \leq i \leq M\\1 \leq j \leq K}} {X}_{i,j}$




```python
s.diff(W[k])
```




$\displaystyle \sum_{\substack{1 \leq i \leq M\\1 \leq j \leq K}} \delta_{j Idx\left(k, \left( 0, \  2\right)\right)} {X}_{i,j}$




```python
# https://docs.sympy.org/latest/modules/tensor/array.html

Array([[[1,2,3],[2,3,4],[3,4,5]],[[1,2,3],[2,3,4],[3,4,5]]])
)
```




$\displaystyle \left[\begin{matrix}\left[\begin{matrix}1 & 2 & 3\\2 & 3 & 4\\3 & 4 & 5\end{matrix}\right] & \left[\begin{matrix}1 & 2 & 3\\2 & 3 & 4\\3 & 4 & 5\end{matrix}\right]\end{matrix}\right]$




```python
from sympy.physics.mechanics import *
a = Array([1,2,3,4])
b = Array([2,3,4,5])
c=tensorproduct(a,b)
d=tensorproduct(b,a)
#dot(a,b)
```


```python
expr = sin(x**2)
expr, integrate(expr,(x,-oo,oo))
```




$\displaystyle \left( \sin{\left(x^{2} \right)}, \  \frac{\sqrt{2} \sqrt{\pi}}{2}\right)$




```python
solve(x**2+1,x)
```




$\displaystyle \left[ - i, \  i\right]$




```python

```

e6f8051a1868ce87bafacb614b5ae5142cae06ae
ipynb
Jupyter Notebook
knowledge/tmp.ipynb
partnernetsoftware/openlab
faa4e58486a7bc4140ad3d56545bfb736cb86696
MIT
2020-09-26T05:27:30.000Z
2020-09-26T05:27:30.000Z
knowledge/tmp.ipynb
partnernetsoftware/openlab
faa4e58486a7bc4140ad3d56545bfb736cb86696
MIT
knowledge/tmp.ipynb
partnernetsoftware/openlab
faa4e58486a7bc4140ad3d56545bfb736cb86696
MIT
Qwen/Qwen-72B
1. YES
2. YES