def derMatrix(Bulk_Operators, Bdy_Operators, s=1):
    """
		Generates a matrix in the same vein as Eq (2.10) of 1502.07217
		First n_bulk elements are coefficients of p_k's
		Next n_bdy elements are coefficients of q_l's
		Last element is coefficient of a_1*a_2

		Note that this matrix contains a mix of expressions and numbers

		FOLLOWING VARIABLES MUST BE DEFINED GLOBALLY BEFORE CALLING:
		table1, delta_1, delta_2, delta_12
		"""
    Matrix = []
    for i in range(1, M_max + 1):
        row = []
        for Bulk_Op in Bulk_Operators:
            table_call = table1.table[0, i].subs({
                "Delta": Bulk_Op,
                "Delta_12": delta_12,
                "Xi": 1.00
            })
            row.append(table_call)
        for Bdy_Op in Bdy_Operators:
            table_call = table1.table[1, i].subs({"Delta": Bdy_Op, "Xi": 1.00})
            row.append(table_call)
        Xi = symbols('Xi')
        if s == 1:
            last_expr = Xi**((delta_1 + delta_2) / 2)
            last_elem = diff(last_expr, Xi, i).subs({"Xi": 1.00}).evalf()
            row.append(last_elem)
        Matrix.append(row)
    return np.array(Matrix)
def inhomoCoeffs(Bulk_Operators, Bdy_Operators, s=1):
    """
		Generates the first equation as Eq (2.10) of 1502.07217
		This is needed to calculate CFT data once dimensions
		are found.
		First n_bulk elements are coefficients of p_k's
		Next n_bdy elements are coefficients of q_l's
		Last element is coefficient of a_1*a_2

		FOLLOWING VARIABLES MUST BE DEFINED GLOBALLY BEFORE CALLING:
		table1, delta_1, delta_2, delta_12
		"""
    Row = []
    for Bulk_Op in Bulk_Operators:
        table_call = table1.table[0, 0].subs({
            "Delta": Bulk_Op,
            "Delta_12": delta_12,
            "Xi": 1.00
        })
        Row.append(table_call)
    for Bdy_Op in Bdy_Operators:
        table_call = table1.table[1, 0].subs({"Delta": Bdy_Op, "Xi": 1.00})
        Row.append(table_call)
    if s == 1:
        Xi = symbols('Xi')
        last_expr = Xi**((delta_1 + delta_2) / 2)
        last_elem = last_expr.subs({"Xi": 1.00}).evalf()
        Row.append(last_elem)

    return np.array(Row)
 def identity_block(self):
     identity_array = [-1]
     Xi = symbols("Xi")
     identity_expr = -1 * Xi**((delta_1 + delta_2) / 2)
     for n in range(1, M_max + 1):
         eval = diff(identity_expr, Xi, n).subs({"Xi": 1.00}).evalf()
         identity_array.append(eval)
     return identity_array
def define_3by3_matrix_inv_and_determinant(file_name):
    """
    Constructs a 3 x 3 matrix and calculates the form of the determinant and inverse. 
    """
    A = sy.Matrix(3, 3, symbols('A:3:3'))
    A_inv = A.inv()
    A_det = A.det()
    df = pd.DataFrame({'A': [A], 'Determinant': [A_det], 'Inverse': [A_inv]})
    df.to_csv(file_name + '.csv', index=True)
    return A, A_det, A_inv
 def __init__(self, dim, M_max):
         self.dim = dim
         self.m_order = list(range(M_max+1))
         Delta, Delta_12, Xi = symbols('Delta Delta_12 Xi')
         Bulk_expr = -1*(Xi**(Delta/2))*hyper([(Delta + Delta_12)/2 , (Delta - Delta_12)/2], [Delta + 1 - (dim/2)],-Xi)
         Bdy_expr = (Xi**(-Delta + (delta_1 + delta_2)/2))*hyper([Delta, Delta + 1 - (dim/2)], [2*Delta + 2 - (dim)], -Xi**(-1))
         # if dim == 3:
         #         Bdy_expr = (0.5/(Xi**0.5))*((4/(1 + Xi))**(Delta - 0.5))*(1 + (Xi/(1+Xi))**(0.5))**(-2*(Delta - 1))
         Bulk_array = [Bulk_expr]
         Bdy_array = [Bdy_expr]
         for n in range(1, M_max + 1):
                 Bulk_array.append(diff(Bulk_expr, Xi, n))
                 Bdy_array.append(diff(Bdy_expr, Xi, n))
         self.table = np.array([Bulk_array, Bdy_array])      
def define_6by6_matrix_inv_and_determinant(file_name):
    """
    Constructs a 4 x 4 matrix and calculates the form of the determinant and inverse. 
    """
    time_start = time.time()
    A = sy.Matrix(6, 6, symbols('A:6:6'))
    A_inv = A.inv()
    A_det = A.det()
    time_end = time.time()
    df = pd.DataFrame({'A': [A], 'Determinant': [A_det], 'Inverse': [A_inv]})
    df.to_csv(file_name + '.csv', index=True)
    print('Time taken to invert and calculate determinant : {}'.format(
        time_start - time_end))
    return A, A_det, A_inv
from numanalysis.variational_proective.utilities.util import plotter
from numanalysis.variational_proective.methods.methods import BubnovGalerkin
from sympy import lambdify
from numanalysis.variational_proective.functional.fun_sys import EvenOddBasis, BasisFunction, AnotherSystem
from numpy import linspace
from numpy.linalg import norm
from sympy.abc import symbols
from sympy.parsing.sympy_parser import (
    parse_expr,
    standard_transformations,
    implicit_multiplication,
)

transformations = standard_transformations + (implicit_multiplication, )

variable = symbols("x")
a, b = 2, 5
b1, b2, b3 = 1, 2, 1
k1, k2 = 6, 3
c1, c2, c3 = 1, 2, 1
p1, p2 = 2, 1
d1, d2, d3 = 1, 1, 1
q1, q2 = 1, 0
a1, a2, a3, a4 = 6, 3, 1, 1
n1, n2, n3 = 2, 1, 4
alpha = a1 * (a**n1) + a2 * (a**n2) + a3 * (a**n3) + a4
beta = a1 * n1 * (a ** (n1 - 1)) + a2 * n2 * \
    (a ** (n2 - 1)) + a3 * n3 * (a ** (n3 - 1))
gamma = a1 * (b**n1) + a2 * (b**n2) + a3 * (b**n3) + a4
delta = a1 * n1 * (b ** (n1 - 1)) + a2 * n2 * \
    (b ** (n2 - 1)) + a3 * n3 * (b ** (n3 - 1))
"""
Created on Thu Mar 12 16:29:10 2020

@author: SR917
"""
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
import pandas as pd
import ast
import ThreeHiggsModel_Analayse as THMA
from sympy.abc import symbols
import time

#import according to how many variables are needed - Ex: for 1D import x, a, b
t,x,y, z, w, h, a,b,c,d, e, f, g,h, l, m,n = symbols('t,x,y, z, w, h, a,b,c,d, e,f,g,h,l,m,n', real = True)

def tidy_up(string):
    """
    Format the strings of arrays to lists of lists
    """
    temp1 = string.replace("array(","")
    temp2 = temp1.replace(")", "")
    
    output = ast.literal_eval(temp2)
    return output


def obtained_roots(filename):
    """
    Obatain roots from our homotopy continuation in format required
Пример #9
0
from sympy.integrals.transforms import inverse_laplace_transform
from sympy.abc import symbols
t, s = symbols('t,s', positive=True)

ans1 = inverse_laplace_transform((1 / (s + 3)**3), s, t)
print("18MEC24006-DENNY JOHNSON P")
print(ans1)

ans2 = inverse_laplace_transform((3 * s**2 + 10 * s - 6) / s**4, s, t)
print(ans2)

ans3 = inverse_laplace_transform(s / (s - 3)**5, s, t)
print(ans3)

ans4 = inverse_laplace_transform((2 * s - 11) / (s**2 + 4 * s + 8), s, t)
print(ans4)
Пример #10
0
def define_4by4_matrix_inv_and_determinant():
    A = sy.Matrix(4, 4, symbols('A:4:4'))
    return A, A.det(), A.inv()
Пример #11
0
"""

#import functions
import numpy as np
import sympy as sy
import scipy.integrate as spi
from sympy.abc import symbols
from sympy.utilities.lambdify import lambdify 
import itertools as it
import time
import iminuit as im
import pandas as pd


#import according to how many variables are needed - Ex: for 1D import x, a, b
t,x,y, z, w, h, a,b,c,d, e, f, g,h = symbols('t,x,y, z, w, h, a,b,c,d, e,f,g,h', real = True)

#construct homotopy
def Homotopy(t, G, F, gamma):
    """
    Constructs the Homotopy from the function to determine F, and the intial easy function G
    Gamma must be a complex number with absolute value 1
    """
    return [(1 - t)*G[i] + gamma*t*F[i] for i in range(len(G))]

#construct starting polynomial
def G(input_variables):
    """
    Constructs easy starting polynomial with known roots depending on the dimensions of the input variables
    
    Parameters: