How to use the symengine.var function in symengine

To help you get started, we’ve selected a few symengine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github exa-analytics / exatomic / exatomic / algorithms / basis.py View on Github external
from collections import OrderedDict, Counter, defaultdict
from itertools import combinations_with_replacement as cwr
import numpy as np
import pandas as pd
from numexpr import evaluate
try:
    from symengine import var, exp, cos, sin, Integer, Float
except ImportError:
    from sympy import symbols as var
    from sympy import exp, cos, sin, Integer, Float
from exa import Series
from exatomic.algorithms.overlap import _cartesian_shell_pairs, _iter_atom_shells
from exatomic.algorithms.numerical import fac, _tri_indices, _triangle, _enum_spherical


_x, _y, _z = var("_x _y _z")
_r = (_x ** 2 + _y ** 2 + _z ** 2) ** 0.5

lorder = ['s', 'p', 'd', 'f', 'g',
          'h', 'i', 'k', 'l', 'm']
lmap = OrderedDict()
rlmap = OrderedDict()
spher_ml_count = OrderedDict()
cart_ml_count = OrderedDict()
spher_lml_count = OrderedDict()
cart_lml_count = OrderedDict()
enum_cartesian = OrderedDict()
for i, L in enumerate(lorder):
    lmap[L] = i
    rlmap[i] = L
    spher_ml_count[L] = 2 * i + 1
    cart_ml_count[L] = (i + 1) * (i + 2) // 2
github symengine / symengine.py / benchmarks / legendre1.py View on Github external
def fact(n):
    if n in [0, 1]:
        return 1
    else:
        return n*fact(n-1)

def diff(e, x, n):
    for i in range(n):
        e = e.diff(x)
    return e

def legendre(n, x):
    e = Integer(1)/(Integer(2)**n * fact(Integer(n))) * diff((x**2-1)**n, x, n)
    return e.expand()

var("x")
for n in range(10):
    print n, legendre(n, x)

t1 = clock()
e = legendre(500, x)
t2 = clock()
print "Total time for legendre(500, x):", t2-t1, "s"
github symengine / symengine.py / benchmarks / expand1.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z w")
e = (x+y+z+w)**60
t1 = clock()
g = e.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine / benchmarks / expand3.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z")
f = (x**y + y**z + z**x)**100
print f
t1 = clock()
g = f.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine / benchmarks / expand4.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x")
e = 1
for i in range(1, 351):
    e *= (i+x)**3
#print e
t1 = clock()
f = e.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine.py / benchmarks / expand3.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z")
f = (x**y + y**z + z**x)**100
print f
t1 = clock()
g = f.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine / benchmarks / expand5.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z")
e = (x+y+z+1)**15
f = e*(e+1)
print f
t1 = clock()
g = f.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine / benchmarks / expand1.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z w")
e = (x+y+z+w)**60
t1 = clock()
g = e.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine / benchmarks / expand2.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x y z w")
e = (x+y+z+w)**15
f = e*(e+w)
print f
t1 = clock()
g = f.expand()
t2 = clock()
print "Total time:", t2-t1, "s"
github symengine / symengine.py / benchmarks / expand4.py View on Github external
import sys
sys.path.append("..")
from timeit import default_timer as clock
from symengine import var
var("x")
e = 1
for i in range(1, 351):
    e *= (i+x)**3
#print e
t1 = clock()
f = e.expand()
t2 = clock()
print "Total time:", t2-t1, "s"