# Differential calculus 


```python
from sympy import Symbol
from sympy.core.containers import Tuple
from sympy import symbols
from sympy import IndexedBase
from sympy import Matrix
from sympy import Function
from sympy import pi, cos, sin
from sympy import srepr
from sympy import expand
from sympy import Function
from sympy import Integer, Float, Rational
from sympy.physics.quantum import TensorProduct

from sympde.core import Constant
from sympde.calculus import grad, dot, inner, outer, cross, rot, curl, div
from sympde.calculus import laplace, hessian, bracket, convect, D, conv
from sympde.calculus import ArgumentTypeError
from sympde.calculus import jump, avg, Dn, minus, plus
from sympde.topology import Domain
from sympde.topology import ScalarFunctionSpace, VectorFunctionSpace
from sympde.topology import ProductSpace
from sympde.topology import H1Space, HcurlSpace, HdivSpace, L2Space, UndefinedSpace
from sympde.topology import TestFunction, ScalarTestFunction, VectorTestFunction
from sympde.topology import ScalarField, VectorField
from sympde.topology import element_of, elements_of
```


```python
domain = Domain('Omega', dim=3)

V = ScalarFunctionSpace('V', domain)
W = VectorFunctionSpace('W', domain)

alpha, beta, gamma = [Constant(i) for i in ['alpha','beta','gamma']]

f,g,h = [element_of(V, name=i) for i in ['f','g','h']]
F,G,H = [element_of(W, i) for i in ['F','G','H']]
```

### Gradient properties

$ \nabla (f+g) = \nabla f + \nabla g $

$ \nabla (\alpha f) = \alpha \nabla f$

$ \nabla (\alpha f+ \beta g) = \alpha \nabla f + \beta \nabla g $

$ \nabla (fg) = f\nabla g + g\nabla f $

$ \nabla (\frac{f}{g}) = -\frac{f}{g^2} \nabla g + \frac{1}{g} \nabla f$


```python
assert( grad(f+g) == grad(f) + grad(g) )
assert( grad(alpha*f) == alpha*grad(f) )
assert( grad(alpha*f + beta*g) == alpha*grad(f) + beta*grad(g)  )

assert( grad(f*g) == f*grad(g) + g*grad(f) )
assert( grad(f/g) == -f*grad(g)/g**2 + grad(f)/g )

assert( expand(grad(f*g*h)) == f*g*grad(h) + f*h*grad(g) + g*h*grad(f) )
```

### Curl properties


```python
assert( curl(F+G) == curl(F) + curl(G) )
assert( curl(alpha*F) == alpha*curl(F) )
assert( curl(alpha*F + beta*G) == alpha*curl(F) + beta*curl(G)  )

assert( curl(cross(F,G)) == F*div(G) - G*div(F) - convect(F, G) + convect(G, F) )
assert( curl(f*F) == f*curl(F) + cross(grad(f), F) )
```

### Laplace properties


```python
assert( laplace(f+g) == laplace(f) + laplace(g) )
assert( laplace(alpha*f) == alpha*laplace(f) )
assert( laplace(alpha*f + beta*g) == alpha*laplace(f) + beta*laplace(g)  )
assert( laplace(f*g) == f*laplace(g) + g*laplace(f) + 2*dot(grad(f), grad(g)) )
```

### Divergence properties


```python
assert( div(F+G) == div(F) + div(G) )
assert( div(alpha*F) == alpha*div(F) )
assert( div(alpha*F + beta*G) == alpha*div(F) + beta*div(G)  )

assert( div(cross(F,G)) == -dot(F, curl(G)) + dot(G, curl(F)) )
assert( div(f*F) == f*div(F) + dot(F, grad(f)))
```

### Other properties


```python
assert( curl(grad(f)) == 0 )
assert( div(curl(F)) == 0 )
assert( div(cross(grad(f), grad(g))) == 0 )
assert( curl(curl(F)) == grad(div(F)) - laplace(F))
assert( curl(f*grad(g)) == cross(grad(f), grad(g)) )
```


```python

```

9b3a7ace898ffdc9b8c2b5ade2502f87d2ec7f4e
ipynb
Jupyter Notebook
notebooks/differential_culculus.ipynb
pyccel/sympde
69e6a6634b2045d46286a0453cb66deab5f2e76c
MIT
2018-09-02T17:50:19.000Z
2022-03-08T01:26:47.000Z
notebooks/differential_culculus.ipynb
pyccel/sympde
69e6a6634b2045d46286a0453cb66deab5f2e76c
MIT
2019-08-18T14:50:01.000Z
2021-09-16T13:54:58.000Z
notebooks/differential_culculus.ipynb
pyccel/sympde
69e6a6634b2045d46286a0453cb66deab5f2e76c
MIT
2019-10-04T18:05:48.000Z
2020-10-17T02:15:10.000Z
Qwen/Qwen-72B
1. YES
2. YES