How to use the symengine.exp 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 neurophysik / jitcdde / tests / test_past_from_function.py View on Github external
def test_exp(self):
		f_1 = lambda time: [np.exp(time),0.5*np.exp(2*time)]
		f_2 = [symengine.exp(t),symengine.exp(2*t)/2]
		
		results = []
		for function in (f_1,f_2):
			self.DDE.purge_past()
			self.DDE.past_from_function(function)
			self.DDE.step_on_discontinuities()
			times = np.arange( self.DDE.t, self.DDE.t+1000, 10 )
			result = np.vstack([ self.DDE.integrate(time) for time in times ])
			results.append(result)
		
		assert_allclose(results[0],results[1],atol=0.01,rtol=1e-5)
github neurophysik / jitcdde / tests / test_neutral.py View on Github external
sech = lambda x: 2/(exp(x)+exp(-x))
eps = 1e-5
github exa-analytics / exatomic / exatomic / algorithms / basis.py View on Github external
ys (np.ndarray): 1D-array of y values
        zs (np.ndarray): 1D-array of z values
        arr (np.ndarray): additional 1D-array to multiply expression by
        alpha (float): multiply expression by gaussian with exponent alpha

    Note:
        See :meth:`exatomic.algorithms.orbital_util.numerical_grid_from_field_params`
        for grid construction details.
    """
    subs = {_x: 'xs', _y: 'ys', _z: 'zs'}
    # Multiply with an additional array (angular term)
    if arr is not None:
        return evaluate('arr * ({})'.format(str(expr.subs(subs))))
    # Multiply by an exponential decay factor
    if alpha is not None:
        expr = str((expr * exp(-alpha * _r ** 2)).subs(subs))
        return evaluate(expr)
    # Just evaluate the expression numerically
    return evaluate(str(expr.subs(subs)))
github exa-analytics / exatomic / exatomic / algorithms / basis.py View on Github external
def _hermite_gaussians(lmax):
    """Symbolic hermite gaussians up to order lmax.

    Args:
        lmax (int): highest order angular momentum quantum number
    """
    order = 2 * lmax + 1
    hgs = OrderedDict()
    der = exp(-_x ** 2)
    for t in range(order):
        if t: der = der.diff(_x)
        hgs[t] = (-1) ** t * der
    return hgs
github exa-analytics / exatomic / exatomic / algorithms / basis.py View on Github external
def _radial(self, x, y, z, alphas, cs, rs=None, pre=None):
        """Generates the symbolic radial portion of a basis function.
        Substitutes symbolic (_i) -> (_i - iA) for i in [x, y, z]."""
        if pre is not None:
            return sum((pre * self._expnt ** r * c * exp(-a * self._expnt)
                        for c, a, r in zip(cs, alphas, rs))
                        ).subs({_x: _x - x, _y: _y - y, _z: _z - z})
        return sum((c * exp(-a * self._expnt)
                    for c, a in zip(cs, alphas))
                    ).subs({_x: _x - x, _y: _y - y, _z: _z - z})
github exa-analytics / exatomic / exatomic / algorithms / basis.py View on Github external
def _radial(self, x, y, z, alphas, cs, rs=None, pre=None):
        """Generates the symbolic radial portion of a basis function.
        Substitutes symbolic (_i) -> (_i - iA) for i in [x, y, z]."""
        if pre is not None:
            return sum((pre * self._expnt ** r * c * exp(-a * self._expnt)
                        for c, a, r in zip(cs, alphas, rs))
                        ).subs({_x: _x - x, _y: _y - y, _z: _z - z})
        return sum((c * exp(-a * self._expnt)
                    for c, a in zip(cs, alphas))
                    ).subs({_x: _x - x, _y: _y - y, _z: _z - z})
github neurophysik / jitcdde / examples / neutral.py View on Github external
sech = lambda x: 2/(exp(x)+exp(-x))
eps = 1e-5